Adaptive normalizer: normalizes values on-the-run using exponential moving averages over mean and standard deviation. More...
#include <Normalizer.h>


Public Member Functions | |
| Normalizer (Engine &engine=Engine::primary()) | |
| Default constructor. | |
| Normalizer (float timeWindow, Engine &engine=Engine::primary()) | |
| Constructor with time window. | |
| Normalizer (float mean, float stdDev, Engine &engine=Engine::primary()) | |
| Constructor with infinite time window. | |
| Normalizer (float mean, float stdDev, float timeWindow, Engine &engine=Engine::primary()) | |
| Constructor with time window. | |
| void | targetMean (float mean) |
| Sets target mean of normalized values. | |
| float | targetMean () const |
| Returns target mean. | |
| void | targetStdDev (float stdDev) |
| Sets target standard deviation of normalized values. | |
| float | targetStdDev () const |
| Returns target standard deviation. | |
| virtual void | infiniteTimeWindow () |
| Sets time window to infinite. | |
| virtual void | timeWindow (float seconds) |
| Changes the time window (expressed in seconds). | |
| virtual float | timeWindow () const |
| Returns the time window (expressed in seconds). | |
| virtual bool | timeWindowIsInfinite () const |
| Returns true if time window is infinite. | |
| virtual void | reset () |
| Resets the statistics. | |
| virtual float | put (float value) |
| Pushes value into the unit. | |
| virtual float | lowOutlierThreshold (float nStdDev=1.5f) const |
| Returns value above which value is considered to be a low outler (below average). | |
| virtual float | highOutlierThreshold (float nStdDev=1.5f) const |
| Returns value above which value is considered to be a high outler (above average). | |
| bool | isClamped () const |
| Return true iff the normalized value is clamped within reasonable range. | |
| void | clamp (float nStdDev=NORMALIZER_DEFAULT_CLAMP_STDDEV) |
| Assign clamping value. | |
| void | noClamp () |
| Remove clamping. | |
| virtual float | mapTo (float toLow, float toHigh) |
| Maps value to new range. | |
| virtual void | cutoff (float hz) |
| Changes the time window cutoff frequency (expressed in Hz). | |
| virtual float | cutoff () const |
| Returns the time window cutoff frequency (expressed in Hz). | |
| virtual void | resumeCalibrating () |
| Switches to calibration mode (default). | |
| virtual void | pauseCalibrating () |
| Switches to non-calibration mode: calls to put(value) will return filtered value without updating the normalization statistics. | |
| virtual void | toggleCalibrating () |
| Toggles calibration mode. | |
| virtual bool | isCalibrating () const |
| Returns true iff the moving filter is in calibration mode. | |
| virtual float | get () |
| Returns value in [0, 1]. | |
| virtual void | clearEvents () |
| float | seconds () const |
| Returns engine time in seconds. | |
| uint32_t | milliSeconds () const |
| Returns engine time in milliseconds. | |
| uint64_t | microSeconds () const |
| Returns engine time in microseconds. | |
| unsigned long | nSteps () const |
| Returns number of engine steps. | |
| float | sampleRate () const |
| Returns engine sample rate. | |
| float | samplePeriod () const |
| Returns enginesample period. | |
| operator float () | |
| Object can be used directly to access its value. | |
| operator bool () | |
| Operator that allows usage in conditional expressions. | |
| virtual float | mean () const |
| Returns an exponential moving average of the samples. | |
| virtual float | var () const |
| Returns an exponential moving variance of the samples. | |
| virtual float | stdDev () const |
| Returns the standard deviation of the samples. | |
| virtual float | normalize (float value) const |
| Returns the normalized value according N(0, 1). | |
| virtual float | normalize (float value, float mean, float stdDev) const |
| Returns the normalized value according to the computed statistics (mean and variance). | |
| virtual bool | isOutlier (float value, float nStdDev=1.5f) const |
| Returns true if the value is considered an outlier. | |
| virtual bool | isLowOutlier (float value, float nStdDev=1.5f) const |
| Returns true if the value is considered a low outlier (below average). | |
| virtual bool | isHighOutlier (float value, float nStdDev=1.5f) const |
| Returns true if the value is considered a high outlier (above average). | |
| virtual float | stddev () const |
Public Attributes | |
| MovingAverage | _avg |
| float | _mean2 |
Protected Member Functions | |
| virtual void | step () |
| virtual float | update (float value, float sampleRate=1) |
| Adds a value to the statistics (returns the mean). | |
| void | _init (float mean, float stdDev) |
| float | _clamp (float value) const |
| virtual void | begin () |
| virtual bool | eventTriggered (EventType eventType) |
| Returns true iff an event of a certain type has been triggered. | |
| virtual void | onEvent (EventCallback callback, EventType eventType) |
| Registers event callback. | |
| Engine * | engine () const |
| Returns the engine that owns this unit. | |
Protected Attributes | |
| float | _targetMean |
| float | _targetStdDev |
| float | _clampStdDev |
| float | _currentMeanStep |
| float | _currentMean2Step |
| bool | _isCalibrating: 1 |
| uint8_t | _nValuesStep: 7 |
| float | _value |
Adaptive normalizer: normalizes values on-the-run using exponential moving averages over mean and standard deviation.
| pq::Normalizer::Normalizer | ( | Engine & | engine = Engine::primary() | ) |
Default constructor.
Assigns infinite time window. Will renormalize data around a mean of 0.5 and a standard deviation of 0.15.
| engine | the engine running this unit |
| pq::Normalizer::Normalizer | ( | float | timeWindow, |
| Engine & | engine = Engine::primary() |
||
| ) |
Constructor with time window.
Will renormalize data around a mean of 0.5 and a standard deviation of 0.15.
| timeWindow | the time window over which the normalization applies (in seconds) |
| engine | the engine running this unit |
| pq::Normalizer::Normalizer | ( | float | mean, |
| float | stdDev, | ||
| Engine & | engine = Engine::primary() |
||
| ) |
Constructor with infinite time window.
| mean | the target mean |
| stdDev | the target standard deviation |
| pq::Normalizer::Normalizer | ( | float | mean, |
| float | stdDev, | ||
| float | timeWindow, | ||
| Engine & | engine = Engine::primary() |
||
| ) |
Constructor with time window.
| mean | the target mean |
| stdDev | the target standard deviation |
| timeWindow | the time window over which the normalization applies (in seconds) |
| void pq::Normalizer::clamp | ( | float | nStdDev = NORMALIZER_DEFAULT_CLAMP_STDDEV | ) |
Assign clamping value.
Values will then be clamped between reasonable range (targetMean() +/- nStdDev * targetStdDev()).
| nStdDev | the number of standard deviations (default: 3.333333333) |
|
inlineprotectedvirtualinherited |
Returns true iff an event of a certain type has been triggered.
Reimplemented in pq::AbstractWave, pq::Alarm, pq::Metronome, pq::PeakDetector, pq::DigitalSource, pq::Ramp, pq::StreamIn, and pq::TimeSliceField< COUNT >.
|
inlinevirtualinherited |
|
virtual |
Returns value above which value is considered to be a high outler (above average).
| nStdDev | the number of standard deviations (typically between 1 and 3); low values = more sensitive |
|
virtual |
Sets time window to infinite.
Implements pq::MovingFilter.
|
virtualinherited |
Returns true if the value is considered a high outlier (above average).
| value | the raw value to be tested (non-normalized) |
| nStdDev | the number of standard deviations (typically between 1 and 3); low values = more sensitive |
|
virtualinherited |
Returns true if the value is considered a low outlier (below average).
| value | the raw value to be tested (non-normalized) |
| nStdDev | the number of standard deviations (typically between 1 and 3); low values = more sensitive |
|
virtualinherited |
Returns true if the value is considered an outlier.
| value | the raw value to be tested (non-normalized) |
| nStdDev | the number of standard deviations (typically between 1 and 3); low values = more sensitive |
|
virtual |
Returns value above which value is considered to be a low outler (below average).
| nStdDev | the number of standard deviations (typically between 1 and 3); low values = more sensitive |
|
virtual |
Maps value to new range.
Reimplemented from pq::AnalogSource.
|
virtual |
Pushes value into the unit.
If isRunning() is false the filter will not be updated but will just return the filtered value.
| value | the value sent to the unit |
Reimplemented from pq::Chainable.
|
virtual |
Resets the statistics.
Reimplemented from pq::MovingFilter.
|
virtualinherited |
Switches to calibration mode (default).
Calls to put(value) will return filtered value AND update the normalization statistics.
|
inlinevirtualinherited |
|
protectedvirtual |
Reimplemented from pq::Unit.
|
inline |
Sets target mean of normalized values.
| mean | the target mean |
|
inline |
Sets target standard deviation of normalized values.
| stdDev | the target standard deviation |
|
virtual |
Returns the time window (expressed in seconds).
Implements pq::MovingFilter.
|
virtual |
Changes the time window (expressed in seconds).
Implements pq::MovingFilter.
|
virtual |
Returns true if time window is infinite.
Implements pq::MovingFilter.
|
protectedvirtual |
Adds a value to the statistics (returns the mean).
Reimplemented from pq::MovingStats.