Stats Master VCL
|
Single moving average.
Parameters |
Description |
Y |
Sample data. |
N |
Number of elements in period. |
M |
Smoothed data. |
Index |
Index of first value in smoothed data. |
Centered |
If true, a centered moving average is perfomed. |
MSE.
Performs single moving average smoothing on data Y. General equation for moving average smoothing is:
where N indicates number of points in period and X.Length data sample size. When using single moving average smoothing, bear in mind that when used as forecasts for the next period, single moving average is not able to cope with a significant trend.
Load sample time series, perform centered moving average smoothing with period 12 (yearly average) and finally plot the results using TChart.
Uses MtxExpr, StatTimeSerAnalysis, Series, TeEngine; procedure Example(Series1,Series2: TLineSeries); var ts,Mv: Vector; FirstIndex: Integer; begin ts.LoadFromFile('testdata.vec'); DrawValues(ts,Series1); // draw original time series MovingAverage(ts,12,Mv,FirstIndex,True); DrawValues(Mv,Series2,FirstIndex); // draw MA over original time series end;
#include "MtxExpr.hpp" #include "Math387.hpp" #include "StatTimeSerAnalysis.hpp" void __fastcall Example(TLineSeries* Series1, TLineSeries* Series2); { sVector ts,Mv; int FirstIndex; ts.LoadFromFile("aerosol_particles.vec"); DrawValues(ts,Series1,0.0,1.0); // draw original time series MovingAverage(ts,12,Mv,FirstIndex,true); DrawValues(Mv,Series2,FirstIndex,1.0); // draw MA over original time series }
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
|
What do you think about this topic? Send feedback!
|