added support for XML reading/writing

new serialization interfaces
new helper methods
new wifi models
This commit is contained in:
2017-05-24 09:32:05 +02:00
parent 1ef3e33f2e
commit 0864f55a54
17 changed files with 1072 additions and 0 deletions

49
math/MovingStdDevTS.h Normal file
View File

@@ -0,0 +1,49 @@
#ifndef MOVINGSTDDEVTS_H
#define MOVINGSTDDEVTS_H
#include "MovingAverageTS.h"
/**
* moving stadnard-deviation using a given time-region
*/
template <typename T> class MovingStdDevTS {
private:
MovingAverageTS<T> avg;
MovingAverageTS<T> avg2;
public:
/** ctor with the window-size to use */
MovingStdDevTS(const Timestamp window, const T zeroElement) : avg(window, zeroElement), avg2(window, zeroElement) {
;
}
/** add a new entry */
void add(const Timestamp ts, const T& data) {
// E(x)
avg.add(ts, data);
// E(x^2)
avg2.add(ts, data*data);
}
/** get the current std-dev */
T get() const {
const T e = avg.get();
const T e2 = avg2.get();
const T var = e2 - e*e;
return std::sqrt(var);
}
};
#endif // MOVINGSTDDEVTS_H

View File

@@ -0,0 +1,46 @@
#ifndef RECTANGULAR_H
#define RECTANGULAR_H
#include <cmath>
#include <random>
#include "../Random.h"
#include "../../Assertions.h"
#include "Normal.h"
namespace Distribution {
/** normal distribution */
template <typename T> class Rectangular {
private:
const T mu;
const T h;
const T width;
public:
/** ctor */
Rectangular(const T mu, const T width) : mu(mu), h(1.0/width), width(width) {
}
/** get probability for the given value */
T getProbability(const T val) const {
const T diff = std::abs(val - mu);
return (diff < width/2) ? (h) : (0.0);
}
/** get the probability for the given value */
static T getProbability(const T mu, const T width, const T val) {
Rectangular<T> dist(mu, width);
return dist.getProbability(val);
}
};
}
#endif // RECTANGULAR_H