Database Reference
In-Depth Information
forecasts,wherethexvalueisconsideredtobethenumberoftimestepsinto
the future, the level takes on the role of an intercept parameter, and the
trend takes the role of a slope parameter in the simple linear regression.
The basic forecast is then fairly simple:
public class HoltForecast {
double level = 0;
double trend = 0;
public HoltForecast( double level, double trend) {
this .level = level;
this .trend = trend;
}
public double forecast( double x) {
return level + trend*x;
}
}
To update the forecast when new data arrives, the level and trend are
maintained as separate exponentially smoothed variables. The smoothing
parameter a is used for both the trend and the level component, and the
smoothing parameter b is used only for the trend component. Each
component is adjusted by the error in the forecast and the observed value,
much like the gradient descent algorithms used by neural networks. This is
equivalent to exponential smoothing and is known as the error correcting
form; it's shown here:
double a = 0.0;
double b = 0.0;
public HoltForecast( double level, double trend, double
a, double b) {
this .level = level;
this .trend = trend;
this .a = a;
this .b = b;
}
public HoltForecast( double level, double trend) {
this (level,trend,0.2,0.8);
}
public double error( double y) { return y -
Search WWH ::




Custom Search