Dew Stats Master .NET
SingleExpSmooth Routines
Summary
Single exponential smoothing.

Unit
StatTimeSerAnalysis

Declaration
Function SingleExpSmooth(Y: TVec; S: TVec; var Alpha: TSample; InitMethod: Integer = 0): TSample;
 Parameter  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. 
Result
MSE, evaluated at minimum.
Description
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.

Categories
Time series analysis routines
 See Also 
SingleExpForecast 

Example 1

Load data, perform smoothing and read Alpha + MSE.
Uses MtxExpr, StatTimeSerAnalysis, Math387; procedure Example; var Data,S: Vector; Alpha,MSE: TSample; 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 "MtxVecCpp.h" #include "Math387.hpp" #include "StatTimeSerAnalysis.hpp" void __fastcall Example(); { Vector 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 }
using Dew.Math; using Dew.Stats; using Dew.Stats.Units; namespace Dew.Examples { private void Example() { Vector Data = new Vector(0); Vector S = new Vector(0); Data.LoadFromFile("aerosol_particles.vec"); // smooth data, initial alpha = 0.1 double alpha = 0.1; double MSE = SingleExpSmooth(Data,S,ref alpha,0); // results: MSE and MLE estimate for Alpha } }


Declaration
Procedure SingleExpSmooth(Y: TVec; S: TVec; const Alpha: TSample; out MSE: TSample; InitMethod: Integer = 0);
 Parameter  Description 
MSE Returns MSE, evaluated for constant Alpha. 

Description
In this case a fixed smoothing constant Alpha is used in smoothing equations (no minimization is performed).
Categories
Time series analysis routines
 See Also 
SingleExpForecast 

Example 1

Load data, perform smoothing with Alpha = 0.33.
Uses MtxExpr, StatTimeSerAnalysis, Math387; procedure Example; var Data,S: Vector; MSE: TSample; begin Data.LoadFromFile('aerosol_particles.vec'); // smooth data with Alpha=0.33 SingleExpSmooth(Data,S,0.33,MSE,0); // results: MSE end;
#include "MtxVecCpp.h" #include "Math387.hpp" #include "StatTimeSerAnalysis.hpp" void __fastcall Example(); { Vector Data,S; Data->LoadFromFile("aerosol_particles.vec"); // smooth data with Alpha=0.33 double MSE; SingleExpSmooth(Data,S,0.33,MSE,0); // results: MSE }
using Dew.Math; using Dew.Stats; using Dew.Stats.Units; namespace Dew.Examples { private void Example() { Vector Data = new Vector(0); Vector S = new Vector(0); Data.LoadFromFile("aerosol_particles.vec"); // smooth data with Alpha=0.33 double MSE; SingleExpSmooth(Data,S,0.33,out MSE,0); // results: MSE } }

Copyright 2008 Dew Research
http://www.dewresearch.com