Examples - pi.science.smoothing.PIDoubleExponentialSmoothing
1. How to perform double exponential smoothing ?
/* - prepare variable for source data */
PIVariable var = new PIVariable();
var.AddValues( new int[] { 199, 205, 217, 197, 223 } );
var.AddValues( new int[] { 217, 236, 243, 248, 253 } );
var.AddValues( new int[] { 250, 246, 268, 273, 281 } );
var.AddValues( new int[] { 281, 278, 284, 270, 301 } );
var.AddValues( new int[] { 297, 308, 328, 315 } );
/* - calc Double exponential smoothing, alpha=0.84 */
PIDoubleExponentialSmoothing smoothing = new PIDoubleExponentialSmoothing( var );
/* use first 12 values for mean...and use it as the first value */
smoothing.SetFirstValueCalcType( FirstValueCalcType.MEAN_WINDOWLENGTH );
smoothing.SetWindowLength( 12 );
smoothing.SetAlpha( 0.84 );
Console.WriteLine( "New ALPHA = " + smoothing.GetAlpha() );
smoothing.Calc();
/* - show results */
PIDebug.Blank();
Console.WriteLine( "After smoothing = " + smoothing.GetOutputVariable().AsString( 2 ) );
Console.WriteLine( "Errors = " + smoothing.GetErrors().AsString( 2 ) );
PIDebug.Blank();
Console.WriteLine( "SSE = " + smoothing.GetSSE() );
Console.WriteLine( "MSE = " + smoothing.GetMSE() );
Console.WriteLine( "MSE-1 = " + smoothing.GetErrors().GetSum2() / ( smoothing.GetSourceVariable().Count() - 1 ) );
Output:
New ALPHA = 0,84
After smoothing = 199.86;204.74;209.95;217.34;216.15;223.13;226.14;234.11;242.02;249.22;255.88;259.54;
260.60;268.01;274.84;282.18;287.32;289.83;293.21;290.89;298.63;302.88;309.24;320.10
Errors = -0.86;5.14;12.26;-12.95;5.66;0.85;12.87;16.86;13.89;10.98;0.78;-9.88;8.46;12.40;12.99;
6.16;-4.18;-3.32;-19.83;7.79;6.11;9.37;25.12;5.76
SSE = 2943,22118776501
MSE = 122,634216156875
MSE-1 = 127,966138598479