GY-63_MS5611/libraries/Statistic/Statistic.h

53 lines
1.4 KiB
C
Raw Normal View History

2011-10-09 16:06:19 -04:00
#ifndef Statistic_h
#define Statistic_h
//
2011-10-09 16:06:19 -04:00
// FILE: Statistic.h
// AUTHOR: Rob dot Tillaart at gmail dot com
2011-10-09 16:06:19 -04:00
// modified at 0.3 by Gil Ross at physics dot org
// VERSION: 0.3.4
2011-10-09 16:06:19 -04:00
// PURPOSE: Recursive Statistical library for Arduino
// HISTORY: See Statistic.cpp
//
// Released to the public domain
//
// the standard deviation increases the lib (<100 bytes)
// it can be in/excluded by un/commenting next line (compile time)
#define STAT_USE_STDEV 1
2011-10-09 16:06:19 -04:00
#include <math.h>
#define STATISTIC_LIB_VERSION "0.3.4"
2013-08-17 09:08:50 -04:00
class Statistic
2011-10-09 16:06:19 -04:00
{
public:
Statistic(); // "switches on/off" stdev run time
void clear(); // "switches on/off" stdev run time
void add(const float);
// returns the number of values added
uint32_t count() const { return _cnt; }; // zero if empty
float sum() const { return _sum; }; // zero if empty
float minimum() const { return _min; }; // zero if empty
float maximum() const { return _max; }; // zero if empty
float average() const; // NAN if empty
2011-10-09 16:06:19 -04:00
#ifdef STAT_USE_STDEV
float variance() const; // NAN if empty
float pop_stdev() const; // population stdev // NAN if empty
float unbiased_stdev() const; // NAN if empty
2011-10-09 16:06:19 -04:00
#endif
protected:
uint32_t _cnt;
float _sum;
float _min;
float _max;
2011-10-09 16:06:19 -04:00
#ifdef STAT_USE_STDEV
float _ssqdif; // sum of squares difference
2011-10-09 16:06:19 -04:00
#endif
};
#endif
2013-08-17 09:08:50 -04:00
// END OF FILE