Data Smoothing Commands - Maple Help

Home : Support : Online Help : Statistics and Data Analysis : Statistics Package : Data Smoothing : Statistics/DataSmoothing

Data Smoothing Commands

 The Statistics package provides various data smoothing functions. The following is a list of available commands.

 apply exponential smoothing to a data set apply linear filter to a data set compute moving averages for a data set compute moving medians for a data set compute moving statistics for a data set compute weighted moving averages for a data set

 The TimeSeriesAnalysis[ExponentialSmoothingModel] command also provides a form of smoothing.

Examples

Create 100 points on the curve $y=\mathrm{sin}\left(\frac{\mathrm{\pi }x}{10}\right)$ and add some random noise.

 > $\mathrm{with}\left(\mathrm{Statistics}\right):$
 > $U≔\mathrm{Sample}\left(\mathrm{Normal}\left(0,0.3\right),100\right)$
 ${U}{:=}\left[\begin{array}{c}{\mathrm{1 .. 100}}{{\mathrm{Vector}}}_{{\mathrm{row}}}\\ {\mathrm{Data Type:}}{{\mathrm{float}}}_{{8}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{Fortran_order}}\end{array}\right]$ (1)
 > $V≔⟨\mathrm{seq}\left(\mathrm{sin}\left(\frac{\mathrm{π}i}{10}\right)+{U}_{i},i=1..100\right)⟩:$
 > $P≔\mathrm{PointPlot}\left(V\right):$
 > $Q≔\mathrm{plot}\left(\mathrm{sin}\left(\frac{\mathrm{π}x}{10}\right),x=0..100,\mathrm{thickness}=3\right):$
 > $\mathrm{plots}[\mathrm{display}]\left(P,Q\right)$

Compute 5-element moving averages.

 > $W≔\mathrm{MovingAverage}\left(V,5\right)$
 ${W}{:=}\left[\begin{array}{c}{\mathrm{1 .. 96}}{{\mathrm{Vector}}}_{{\mathrm{column}}}\\ {\mathrm{Data Type:}}{{\mathrm{float}}}_{{8}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{Fortran_order}}\end{array}\right]$ (2)
 > $R≔\mathrm{LineChart}\left(W,\mathrm{xcoords}=\left[\mathrm{seq}\left(i,i=2..98\right)\right],\mathrm{thickness}=3\right):$
 > $\mathrm{plots}[\mathrm{display}]\left(P,Q,R\right)$

Apply exponential smoothing.

 > $\mathrm{U1}≔\mathrm{ExponentialSmoothing}\left(V,0.2\right)$
 ${\mathrm{U1}}{:=}\left[\begin{array}{c}{\mathrm{1 .. 100}}{{\mathrm{Vector}}}_{{\mathrm{column}}}\\ {\mathrm{Data Type:}}{{\mathrm{float}}}_{{8}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{Fortran_order}}\end{array}\right]$ (3)
 > $\mathrm{U2}≔\mathrm{ExponentialSmoothing}\left(V,0.8\right)$
 ${\mathrm{U2}}{:=}\left[\begin{array}{c}{\mathrm{1 .. 100}}{{\mathrm{Vector}}}_{{\mathrm{column}}}\\ {\mathrm{Data Type:}}{{\mathrm{float}}}_{{8}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{Fortran_order}}\end{array}\right]$ (4)
 > $R≔\mathrm{LineChart}\left(\left[\mathrm{U1},\mathrm{U2}\right],\mathrm{color}=\left[\mathrm{red},\mathrm{blue}\right],\mathrm{thickness}=3\right):$
 > $\mathrm{plots}[\mathrm{display}]\left(P,R\right)$

Use lowess smoothing.

 > $X≔⟨\mathrm{seq}\left(i,i=1..100\right)⟩:$
 > $R≔\mathrm{ScatterPlot}\left(X,V,\mathrm{lowess},\mathrm{degree}=3,\mathrm{color}=\mathrm{blue},\mathrm{thickness}=3\right):$
 > $\mathrm{plots}[\mathrm{display}]\left(P,Q,R\right)$