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
26  return s_;
27 }
28 
29 void HoltWintersSmoothFilter::reset(double initialB) {
30  gotFirst_ = false;
31  b_ = initialB;
32 }
33 
36 }
37 
40 }
void insert(const double &v)
Definition: HoltWinters.cpp:9
HoltWintersSmoothFilter(double initialB=defaultInitialB_, double alfa=defaultAlfa_, double beta=defaultBeta_)
Definition: HoltWinters.cpp:3
void reset(double initialB=defaultInitialB_)
Definition: HoltWinters.cpp:29
void setBeta(double beta)
Definition: HoltWinters.cpp:38
void setAlfa(double alfa)
Definition: HoltWinters.cpp:34


timesync_ros
Author(s): Juraj Oršulić
autogenerated on Mon Jun 10 2019 15:28:33