StatTimeSerAnalysis::MovingAverage Function

double MovingAverage(TVec *Y, const int N, TVec *M, int &Index, const bool Centered = true);

Single moving average.

#NameTypeDescription
1YTVec *Sample data.
2Nconst intNumber of elements in period.
3MTVec *Smoothed data.
4Indexint &Index of first value in smoothed data.
5Centered = trueconst boolIf true, a centered moving average is perfomed.

Returns: MSE.

Remarks:

Performs single moving average smoothing on data Y. General equation for moving average smoothing is:

M[i]=1N(X[i]+X[i1]++X[iN+1]),N1iX.LengthM[i] =\cfrac{1}{N} \left(X[i]+X[i-1]+\cdots+X[i-N+1] \right) \quad , \quad N-1\leq i \leq X.Length

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.

Declared in Dew::Stats::Units::StatTimeSerAnalysis · Dew.Stats/Units.StatTimeSerAnalysis.h · Cross-compiler