huge commit

- worked on about everything
- grid walker using plugable modules
- wifi models
- new distributions
- worked on geometric data-structures
- added typesafe timestamps
- worked on grid-building
- added sensor-classes
- added sensor analysis (step-detection, turn-detection)
- offline data reader
- many test-cases
This commit is contained in:
2016-08-29 08:18:44 +02:00
parent 99ee95ce7b
commit a2c9e575a2
94 changed files with 8298 additions and 257 deletions

43
math/Median.h Normal file
View File

@@ -0,0 +1,43 @@
#ifndef MEDIAN_H
#define MEDIAN_H
#include <vector>
#include <algorithm>
template <typename Scalar> class Median {
private:
/** all scalar values in a sorted order (ascending) */
std::vector<Scalar> sorted;
public:
/** add the given scalar value to the median calculation */
void add(const Scalar value) {
const auto idx = std::upper_bound( sorted.begin(), sorted.end(), value );
sorted.insert( idx, value );
}
/** get the median of all added values */
float get() const {
if (sorted.size() % 2 == 1) { // odd
const int idx = sorted.size()/2;
return sorted[idx];
} else { // even
const int idx0 = sorted.size()/2 - 1;
return (sorted[idx0] + sorted[idx0+1]) / 2;
}
}
};
#endif // MEDIAN_H