Double MovingAverage(TVec Y, Int32 N, TVec M, ref Int32 Index, Boolean Centered)
Single moving average.
| # | Name | Description |
|---|---|---|
| 1 | Y | Sample data. |
| 2 | N | Number of elements in period. |
| 3 | M | Smoothed data. |
| 4 | Index | Index of first value in smoothed data. |
| 5 | Centered | If true, a centered moving average is perfomed. |
Returns: Double - MSE.
Remarks:
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.
Examples
using Dew.Math;
using Dew.Stats;
using Dew.Stats.Units;
using Steema.TeeChart;
namespace Dew.Examples
{
private void Example(Styles.Line line1, Styles.Line line2)
{
Vector ts = new Vector(0);
Vector Mv = new Vector(0);
int FirstIndex;
ts.LoadFromFile("testdata.vec");
MtxVecTee.DrawValues(ts,line1,0.0,1.0); // draw original time series
StatTimeSerAnalysis.MovingAverage(ts,12,Mv,out FirstIndex,true);
MtxVecTee.DrawValues(Mv,line2,FirstIndex,1.0); // draw MA over original time series
}
}