Commit 94822f0c authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

introduced EmpiricMeasuresOnLevels

parent 96abf8c0
#include "EmpiricMeasuresOnLevels.hpp"
void SampleCountersOnLevels::Update() {
}
void AveragesOnLevels::Update(const MonteCarloMap &mcMap) {
for (auto &mc: mcMap) {
Q[mc.first] = mc.second->avgs.Q;
Y[mc.first] = mc.second->avgs.Y;
Cost[mc.first] = mc.second->avgs.Cost;
}
}
void VariancesOnLevels::Update(const MonteCarloMap &mcMap) {
for (auto &mc: mcMap) {
Q[mc.first] = mc.second->vars.Q;
Y[mc.first] = mc.second->vars.Y;
}
}
void KurtosisOnLevels::Update(const MonteCarloMap &mcMap) {
for (auto &mc: mcMap) {
Q[mc.first] = mc.second->kurtosis.Q;
Y[mc.first] = mc.second->kurtosis.Y;
}
}
void Exponents::Update(const MonteCarloMap &mcMap) {
vector<double> levelList, avgsY, varsY, costs;
auto iter = mcMap.begin();
iter++;
for (; iter != mcMap.end(); iter++) {
levelList.push_back((double) iter->first);
avgsY.push_back(-log2(iter->second->avgs.Y));
varsY.push_back(-log2(iter->second->vars.Y));
costs.push_back(log2(iter->second->avgs.Cost));
}
std::pair<double, double> res = linear_fit(levelList, avgsY);
alpha = res.first;
res = linear_fit(levelList, varsY);
beta = res.first;
res = linear_fit(levelList, costs);
gamma = res.first;
}
#ifndef EMPIRICMEASURESONLEVELS_HPP
#define EMPIRICMEASURESONLEVELS_HPP
#include "EmpiricMeasures.hpp"
#include "MonteCarlo.hpp"
#include <map>
typedef std::map<int, MonteCarlo *> MonteCarloMap;
struct SampleCountersOnLevels {
std::map<int, int> M;
std::map<int, int> dM;
void Update();
};
struct AveragesOnLevels {
std::map<int, double> Q;
std::map<int, double> Y;
std::map<int, double> Cost;
void Update(const MonteCarloMap &mcMap);
};
struct VariancesOnLevels {
std::map<int, double> Q;
std::map<int, double> Y;
void Update(const MonteCarloMap &mcMap);
};
struct KurtosisOnLevels {
std::map<int, double> Q;
std::map<int, double> Y;
void Update(const MonteCarloMap &mcMap);
};
struct Exponents {
double alpha = 0.0;
double beta = 0.0;
double gamma = 0.0;
void Update(const MonteCarloMap &mcMap);
};
#endif //EMPIRICMEASURESONLEVELS_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