mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
set initial values of hist class members in constructor; add a TODO case in put() function in for warmup==0
This commit is contained in:
parent
09ea196f1e
commit
5f9009da13
1 changed files with 17 additions and 4 deletions
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <cfloat> // for DBL_MAX
|
||||
|
||||
#include <villas/utils.hpp>
|
||||
#include <villas/hist.hpp>
|
||||
|
@ -33,9 +34,17 @@ using namespace villas::utils;
|
|||
namespace villas {
|
||||
|
||||
Hist::Hist(int buckets, Hist::cnt_t wu) :
|
||||
warmup(wu),
|
||||
data(buckets)
|
||||
{ }
|
||||
warmup(wu)
|
||||
{
|
||||
for ( int i = 0; i<buckets; i++){
|
||||
data.push_back(0);
|
||||
}
|
||||
total=0;
|
||||
highest=0;
|
||||
lowest=DBL_MAX;
|
||||
higher=0;
|
||||
lower=0;
|
||||
}
|
||||
|
||||
void Hist::put(double value)
|
||||
{
|
||||
|
@ -51,11 +60,15 @@ void Hist::put(double value)
|
|||
if (total < warmup) {
|
||||
/* We are still in warmup phase... Waiting for more samples... */
|
||||
}
|
||||
else if (data.size() && total == warmup) {
|
||||
else if (data.size() && total == warmup && warmup != 0) {
|
||||
low = getMean() - 3 * getStddev();
|
||||
high = getMean() + 3 * getStddev();
|
||||
resolution = (high - low) / data.size();
|
||||
}
|
||||
else if (data.size() && (total == warmup) && (warmup == 0)){
|
||||
// there is no warmup phase
|
||||
// TODO resolution = ?
|
||||
}
|
||||
else {
|
||||
idx_t idx = std::round((value - low) / resolution);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue