You are here: Symbol Reference > StatTimeSerAnalysis Namespace > Functions > StatTimeSerAnalysis.SingleExpSmooth Function
Stats Master VCL
ContentsIndex
PreviousUpNext
StatTimeSerAnalysis.SingleExpSmooth Function

Single exponential smoothing.

Pascal
function SingleExpSmooth(const Y: TVec; const S: TVec; var Alpha: double; const InitMethod: Integer = 0): double; overload;
Parameters 
Description 
Time series data set. 
Smoothed values (see above equation). Size and complex properties of S are set automatically. 
Alpha 
Defines initial estimate for Alpha, returns Alpha which minimizes MSE. 
InitMethod 
Defines how the initial values for S[0] are calculated. 

MSE, evaluated at minimum.

Performs single exponential smoothing using the following equation: 

 

This is the basic equation of exponential smoothing and the variable Alpha is called the smoothing constant. This smoothing scheme begins by setting S[0] to Y[0], where S[i] stands for smoothed observation and Y stands for the original observation. The subscripts refer to the time periods, 0, 1, ..., n. Note that there is no S[0]; the smoothed series starts with the smoothed version of the second observation. Also note that the internal algorithm automatically accounts for this by resizing S vector to Y.Length-1. 

Setting S[0] to Y[0] is not mandatory. There are numerous ways to initialize S[0]. Some of the choices are: 

 

Different initialization methods are controlled by the InitMethod parameter. Default value (0) uses first equation, setting it to (1) means the second equation will be used to initialize S[0]. 

The smoothing constant alpha determines how fast the weights of the series decays. The value may be chosen either subjectively or objectively. Values near one put almost all weight on the most recent observations. Values of the smoothing constant near zero allow the distant past observations to have a large influence. When selecting the smoothing constant subjectively, you use your own experience with this, and similar, series. Also, specifying the smoothing constant yourself lets you tune the forecast to your own beliefs about the future of the series. If you believe that the mechanism generating the series has recently gone through some fundamental changes, use a smoothing constant value of 0.9 which will cause distant observations to be ignored. If, however, you think the series is fairly stable and only going through random fluctuations, use a value of 0.1.

To select the value of the smoothing constant objectively, internal algorithm searches for an Alpha that minimizes the mean squared error (MSE)of the combined forecast errors of the currently available series.

Load data, perform smoothing and read Alpha + MSE.

Uses MtxExpr, StatTimeSerAnalysis, Math387;
procedure Example;
var Data,S: Vector;
    Alpha,MSE: double;
begin
  Data.LoadFromFile('aerosol_particles.vec');
  // smooth data, initial alpha = 0.1
  Alpha := 0.1;
  MSE := SingleExpSmooth(Data,S,Alpha,0);
  // results: MSE and MLE estimate for Alpha
end;
#include "MtxExpr.hpp"
#include "Math387.hpp"
#include "StatTimeSerAnalysis.hpp"
void __fastcall Example();
{
  sVector Data,S;
  Data.LoadFromFile("aerosol_particles.vec");
  // smooth data, initial alpha = 0.1
  double alpha = 0.1;
  double MSE = SingleExpSmooth(Data,S,alpha,0);
  // results: MSE and MLE estimate for Alpha
}
Examples on GitHub
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!