Main Page
Namespaces
Classes
Files
File List
File Members
src
HoltWinters.cpp
Go to the documentation of this file.
1
#include "
HoltWinters.h
"
2
3
HoltWintersSmoothFilter::HoltWintersSmoothFilter
(
double
initialB,
double
alfa,
double
beta) {
4
alfa_
= alfa;
5
beta_
= beta;
6
reset
(initialB);
7
}
8
9
void
HoltWintersSmoothFilter::insert
(
const
double
& v )
10
{
11
double
s_prev =
s_
;
12
if
(!
gotFirst_
) {
13
s_
= v;
14
gotFirst_
=
true
;
15
}
16
else
{
17
// update the estimate
18
s_
=
alfa_
* v + (1 -
alfa_
) * (
s_
+
b_
);
19
// update the estimate of the derivative
20
b_
=
beta_
* (
s_
- s_prev) + (1 -
beta_
) *
b_
;
21
}
22
}
23
24
// Returns the current smoothed value
25
double
HoltWintersSmoothFilter::getFiltered
() {
26
return
s_
;
27
}
28
29
void
HoltWintersSmoothFilter::reset
(
double
initialB) {
30
gotFirst_
=
false
;
31
b_
= initialB;
32
}
33
34
void
HoltWintersSmoothFilter::setAlfa
(
double
alfa) {
35
HoltWintersSmoothFilter::alfa_
= alfa;
36
}
37
38
void
HoltWintersSmoothFilter::setBeta
(
double
beta) {
39
HoltWintersSmoothFilter::beta_
= beta;
40
}
HoltWintersSmoothFilter::insert
void insert(const double &v)
Definition:
HoltWinters.cpp:9
HoltWintersSmoothFilter::HoltWintersSmoothFilter
HoltWintersSmoothFilter(double initialB=defaultInitialB_, double alfa=defaultAlfa_, double beta=defaultBeta_)
Definition:
HoltWinters.cpp:3
HoltWintersSmoothFilter::b_
double b_
Definition:
HoltWinters.h:33
HoltWintersSmoothFilter::beta_
double beta_
Definition:
HoltWinters.h:34
HoltWintersSmoothFilter::alfa_
double alfa_
Definition:
HoltWinters.h:34
HoltWintersSmoothFilter::reset
void reset(double initialB=defaultInitialB_)
Definition:
HoltWinters.cpp:29
HoltWintersSmoothFilter::s_
double s_
Definition:
HoltWinters.h:33
HoltWintersSmoothFilter::getFiltered
double getFiltered()
Definition:
HoltWinters.cpp:25
HoltWinters.h
HoltWintersSmoothFilter::gotFirst_
bool gotFirst_
Definition:
HoltWinters.h:32
HoltWintersSmoothFilter::setBeta
void setBeta(double beta)
Definition:
HoltWinters.cpp:38
HoltWintersSmoothFilter::setAlfa
void setAlfa(double alfa)
Definition:
HoltWinters.cpp:34
timesync_ros
Author(s): Juraj Oršulić
autogenerated on Mon Jun 10 2019 15:28:33