Overview - Maple Help

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}{cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc}{-0.321727238399481}& {-0.0987233611641195}& {-0.185127581072937}& {0.0643400235735872}& {-0.00762843841271539}& {0.518646385253350}& {-0.490457026303171}& {0.471351651526290}& {0.0511075264231225}& {0.301943522625543}& {0.0806138037474931}& {-0.439794134087633}& {-0.0107273561518490}& {-0.00195100903879099}& {-0.0171549006699714}& {-0.0553800283874787}& {0.0611566207113337}& {-0.0296615472081370}& {-0.0248094291125946}& {-0.0504357384364224}& {0.0486063899603798}& {-0.202775612901785}& {-0.132239293214560}& {0.268805995577865}& {0.138306886014007}& {0.383393115682154}& {0.0703697885383742}& {-0.0108823473881049}& {-0.134654437053644}& {-0.350211925597414}& {-0.365382865182373}& {-0.346407588277875}& {0.0328977969850794}& {-0.185942814192385}& {0.192645301393477}& {-0.0512312754294732}& {-0.246015672308395}& {0.403900558989702}& {-0.295811568047437}& {-0.289751638049954}& {-0.409387715941723}& {0.495023615869223}& {0.404412454056052}& {-0.307612177855977}& {0.0689364182591729}& {0.445480373904158}& {-0.390092716234762}& {-0.112839334870862}& {0.0185352590001619}& {0.240572348742312}& {-0.0389926411652577}& {0.0337453591812398}& {0.189108177538398}& {-0.00626878190525176}& {-0.249132846899220}& {-0.0787957530423553}& {-0.210090078590402}& {0.586670717583819}& {-0.0778422496867822}& {-0.0246255187687290}& {0.364673835787499}& {-0.294939544127897}& {0.579207194666806}& {0.0368205325760259}& {0.129883626345462}& {-0.157333145358841}& {0.0672646655783495}& {-0.124267670429512}& {0.0106578408688916}& {0.595113629303997}& {0.664013876817107}& {0.264368966588063}& {0.266056935168126}& {-0.258499784192641}& {-0.271983391002268}& {-0.263019295304916}& {-0.0652471378859968}& {-0.100846552286741}& {0.164812972805739}& {-0.359264530214500}& {-0.278253101861857}& {-0.398985181626683}& {-0.339130809440933}& {0.381561075201006}& {-0.442954639034717}& {0.484014747280828}& {-0.205602620810246}& {0.324723870276193}& {-0.233020470143960}& {-0.166644431428393}& {0.321717554330475}& {0.0214058932888665}& {-0.0546368773468666}& {0.188564863085573}& {-0.217755193503086}& {-0.124014101580007}& {0.462724590346982}& {-0.0660928282271428}& {-0.252244807425815}& {0.115519803619994}\end{array}\right]$ (1)
 > $V≔⟨\mathrm{seq}\left(\mathrm{sin}\left(\frac{\mathrm{\pi }i}{10}\right)+U\left[i\right],i=1..100\right)⟩:$
 > $P≔\mathrm{PointPlot}\left(V\right):$
 > $Q≔\mathrm{plot}\left(\mathrm{sin}\left(\frac{\mathrm{\pi }x}{10}\right),x=0..100,\mathrm{thickness}=3\right):$
 > $\mathrm{plots}\left[\mathrm{display}\right]\left(P,Q\right)$

Compute 5-element moving averages.

 > $W≔\mathrm{MovingAverage}\left(V,5\right)$
 ${W}{≔}\begin{array}{c}\left[\begin{array}{c}{0.621601832372371}\\ {0.918084461486979}\\ {0.883984076875663}\\ {0.971033574979014}\\ {0.839979171164879}\\ {0.701893563372531}\\ {0.362272344937339}\\ {0.0930444740469630}\\ {-0.282731776822149}\\ {-0.545358186048552}\\ {⋮}\end{array}\right]\\ \hfill {\text{96 element Vector[column]}}\end{array}$ (2)
 > $R≔\mathrm{LineChart}\left(W,\mathrm{xcoords}=\left[\mathrm{seq}\left(i,i=2..98\right)\right],\mathrm{thickness}=3\right):$
 > $\mathrm{plots}\left[\mathrm{display}\right]\left(P,Q,R\right)$

Apply exponential smoothing.

 > $\mathrm{U1}≔\mathrm{ExponentialSmoothing}\left(V,0.2\right)$
 ${\mathrm{U1}}{≔}\begin{array}{c}\left[\begin{array}{c}{-0.0127102440044911}\\ {0.0876441830220778}\\ {0.194893229078064}\\ {0.358993891236200}\\ {0.485669425306417}\\ {0.682476120554834}\\ {0.609692890058222}\\ {0.699581692810331}\\ {0.631690258407878}\\ {0.565740911251411}\\ {⋮}\end{array}\right]\\ \hfill {\text{100 element Vector[column]}}\end{array}$ (3)
 > $\mathrm{U2}≔\mathrm{ExponentialSmoothing}\left(V,0.8\right)$
 ${\mathrm{U2}}{≔}\begin{array}{c}\left[\begin{array}{c}{-0.0127102440195227}\\ {0.388707464098778}\\ {0.576853023461364}\\ {0.927687836587266}\\ {0.979434816587281}\\ {1.37164928455626}\\ {0.529177831368673}\\ {0.953145089328745}\\ {0.478728634504205}\\ {0.337300545001275}\\ {⋮}\end{array}\right]\\ \hfill {\text{100 element Vector[column]}}\end{array}$ (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}\left[\mathrm{display}\right]\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}\left[\mathrm{display}\right]\left(P,Q,R\right)$