Commit bbc9f483 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

removed EmpiricMeasures

parent 07904c18
#include "EmpiricMeasures.hpp"
#include "utility/Assertion.hpp"
void Sums::Update(SampleSolution &fineSolution, SampleSolution &coarseSolution) {
Cost += fineSolution.Cost;
double Qf = fineSolution.Q;
double Qc = coarseSolution.Q;
double diffQ = Qf - Qc;
Q += Qf;
Q2 += Qf * Qf;
Q3 += Qf * Qf * Qf;
Q4 += Qf * Qf * Qf * Qf;
Y += diffQ;
Y2 += diffQ * diffQ;
Y3 += diffQ * diffQ * diffQ;
Y4 += diffQ * diffQ * diffQ * diffQ;
}
void Averages::Update(Sums sums, int M) {
Cost = sums.Cost / M;
Y = abs(sums.Y / M);
Y2 = sums.Y2 / M;
Y3 = sums.Y3 / M;
Y4 = sums.Y4 / M;
Q = abs(sums.Q / M);
Q2 = sums.Q2 / M;
Q3 = sums.Q3 / M;
Q4 = sums.Q4 / M;
}
void Variances::Update(Averages avgs) {
Y = fmax(avgs.Y2 - avgs.Y * avgs.Y, 1e-10);
Q = fmax(avgs.Q2 - avgs.Q * avgs.Q, 1e-10);
}
void Kurtosis::Update(Averages avgs, Variances vars) {
Q = (avgs.Q4 - 4.0 * avgs.Q3 * avgs.Q + 6.0 * avgs.Q2 * avgs.Q * avgs.Q -
3.0 * avgs.Q * avgs.Q * avgs.Q * avgs.Q) / vars.Q / vars.Q;
Y = (avgs.Y4 - 4.0 * avgs.Y3 * avgs.Y + 6.0 * avgs.Y2 * avgs.Y * avgs.Y -
3.0 * avgs.Y * avgs.Y * avgs.Y * avgs.Y) / vars.Y / vars.Y;
if (Y > 100.0) Warning("Kurtosis of Y above 100!")
}
#ifndef EMPIRICMEASURES_HPP
#define EMPIRICMEASURES_HPP
#include "basics/Sample.hpp"
#include "Parallel.hpp"
struct Sums {
double Q = 0.0;
double Q2 = 0.0;
double Q3 = 0.0;
double Q4 = 0.0;
double Y = 0.0;
double Y2 = 0.0;
double Y3 = 0.0;
double Y4 = 0.0;
double Cost = 0.0;
// Vector U; Todo; Also be careful with instabilities of difference
//
// Vector V;
Sums() {};
Sums(double Q, double Q2, double Q3, double Q4,
double Y, double Y2, double Y3, double Y4, double Cost) :
Q(Q), Q2(Q2), Q3(Q3), Q4(Q4), Y(Y), Y2(Y2), Y3(Y3), Y4(Y4), Cost(Cost) {}
void Update(SampleSolution &fineSolution, SampleSolution &coarseSolution);
friend Logging &operator<<(Logging &s, const Sums &sums) {
return s << "Sum(Q)=" << sums.Q << " Sum(Q^2)=" << sums.Q2
<< " Sum(Q^3)=" << sums.Q3 << " Sum(Q^4)=" << sums.Q4 << endl
<< "Sum(Y)=" << sums.Y << " Sum(Y^2)=" << sums.Y2
<< " Sum(Y^3)=" << sums.Y3 << " Sum(Y^4)=" << sums.Y4 << endl;
}
};
struct Averages {
double Q = 0.0;
double Q2 = 0.0;
double Q3 = 0.0;
double Q4 = 0.0;
double Y = 0.0;
double Y2 = 0.0;
double Y3 = 0.0;
double Y4 = 0.0;
double Cost = 0.0;
Averages() {};
Averages(double Q, double Q2, double Q3, double Q4,
double Y, double Y2, double Y3, double Y4, double Cost) :
Q(Q), Q2(Q2), Q3(Q3), Q4(Q4), Y(Y), Y2(Y2), Y3(Y3), Y4(Y4), Cost(Cost) {}
void Update(Sums sums, int M);
friend Logging &operator<<(Logging &s, const Averages &avgs) {
return s << "|E[Q]|=" << avgs.Q << " |E[Y]|=" << avgs.Y << endl;
}
};
struct Variances {
double Q = 0.0;
double Y = 0.0;
Variances() {};
Variances(double Q, double Y) : Q(Q), Y(Y) {}
void Update(Averages avgs);
friend Logging &operator<<(Logging &s, const Variances &vars) {
return s << "V[Q]=" << vars.Q << " V[Y]=" << vars.Y << endl;
}
};
struct Kurtosis {
double Q = 0.0;
double Y = 0.0;
void Update(Averages avgs, Variances vars);
friend Logging &operator<<(Logging &s, const Kurtosis &kurtosis) {
return s << "K[Q]=" << kurtosis.Q << " K[Y]=" << kurtosis.Y << endl;
}
};
#endif //EMPIRICMEASURES_HPP
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment