-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathewma.h
More file actions
37 lines (30 loc) · 708 Bytes
/
ewma.h
File metadata and controls
37 lines (30 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef _EWMA_H
#define _EWMA_H
class ewma {
public:
/*
* Current data output
*/
double output = 0;
/*
* Smoothing factor, in range [0,1]. Higher the value - less smoothing (higher the latest reading impact).
*/
double alpha = 0;
/*
* Creates a filter without a defined initial output. The first output will be equal to the first input.
*/
ewma(double alpha);
/*
* Creates a filter with a defined initial output.
*/
ewma(double alpha, double initialOutput);
void reset();
/*
* Specifies a reading value.
* @returns current output
*/
double filter(double input);
private:
bool hasInitial = false;
};
#endif