16 #include "RollingAverage.h"
17 #include "mozzi_fixmath.h"
26 template <
class T,
int WINDOW_LENGTH>
41 _mean = rollingMean.next(x);
42 _variance = (((long)x - _previous_mean)*((long)x - _mean))>>WINDOW_LENGTH_AS_RSHIFT;
43 _previous_mean = _mean;
51 _mean = rollingMean.next(x);
52 _variance = (((int)x - _previous_mean)*((int)x - _mean))>>WINDOW_LENGTH_AS_RSHIFT;
53 _previous_mean = _mean;
78 return isqrt16(_variance);
84 T _previous_mean, _mean, _variance;
86 const uint8_t WINDOW_LENGTH_AS_RSHIFT;
93 template <
int WINDOW_LENGTH>
108 _mean = rollingMean.next(x);
109 _variance = ((x - _previous_mean)*(x - _mean))/(WINDOW_LENGTH-1);
110 _previous_mean = _mean;
134 return sqrt(_variance);
140 float _previous_mean, _mean, _variance;
142 const uint8_t WINDOW_LENGTH_AS_RSHIFT;
constexpr uint8_t trailingZerosConst(unsigned long v)
Given a power of 2, work out the number to shift right by to do a divide by the number,...