Plaquette
 
Loading...
Searching...
No Matches
MinMaxScaler.h
1/*
2 * MinMaxScaler.h
3 *
4 * (c) 2015 Sofian Audry :: info(@)sofianaudry(.)com
5 * (c) 2015 Thomas O Fredericks :: tof(@)t-o-f(.)info
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef MIN_MAX_SCALER_H_
22#define MIN_MAX_SCALER_H_
23
24#include "PqCore.h"
25#include "MovingFilter.h"
26
27namespace pq {
28
30class MinMaxScaler : public MovingFilter {
31public:
37
44
45 virtual ~MinMaxScaler() {}
46
48 float minValue() const { return _minValue; }
49
51 float maxValue() const { return _maxValue; }
52
54 virtual void infiniteTimeWindow();
55
57 virtual void timeWindow(float seconds);
58
60 virtual float timeWindow() const;
61
63 virtual bool timeWindowIsInfinite() const;
64
66 virtual void reset();
67
74 virtual float put(float value);
75
76protected:
77 virtual void step();
78
79 // Time window (in seconds).
80 float _timeWindow;
81
82 // Minimum value ever put (decays over time if time window is finite).
83 float _minValue;
84
85 // Maximum value ever put (decays over time if time window is finite).
86 float _maxValue;
87
88 // Smoothed minimum value.
89 float _smoothedMinValue;
90
91 // Smoothed minimum value.
92 float _smoothedMaxValue;
93
94 // Number of samples that have been processed thus far.
95 unsigned int _nSamples;
96
97 // Variables used to compute current value average during a step (in case of multiple calls to put()).
98 float _currentValueStep;
99};
100
101}
102
103#endif
The main Plaquette static class containing all the units.
Definition PqCore.h:60
static Engine & primary()
Returns the main instance of Plaquette.
Definition PqCore.cpp:31
Regularizes signal into [0,1] by rescaling it using the min and max values.
Definition MinMaxScaler.h:30
virtual void infiniteTimeWindow()
Sets time window to infinite.
Definition MinMaxScaler.cpp:45
virtual bool timeWindowIsInfinite() const
Returns true if time window is infinite.
Definition MinMaxScaler.cpp:55
float maxValue() const
Returns the current max. value.
Definition MinMaxScaler.h:51
float minValue() const
Returns the current min. value.
Definition MinMaxScaler.h:48
virtual float put(float value)
Pushes value into the unit.
Definition MinMaxScaler.cpp:71
virtual float timeWindow() const
Returns the time window (expressed in seconds).
Definition MinMaxScaler.cpp:53
virtual void reset()
Resets the moving filter.
Definition MinMaxScaler.cpp:59
Definition MovingFilter.h:29
float seconds() const
Returns engine time in seconds.
Definition PqCore.h:348
Engine * engine() const
Returns the engine that owns this unit.
Definition PqCore.h:382