Data Smoothing Commands
The Statistics package provides various data smoothing functions. The following is a list of available commands.
ExponentialSmoothing
apply exponential smoothing to a data set
LinearFilter
apply linear filter to a data set
MovingAverage
compute moving averages for a data set
MovingMedian
compute moving medians for a data set
MovingStatistic
compute moving statistics for a data set
WeightedMovingAverage
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=sin⁡π⁢x10 and add some random noise.
with⁡Statistics:
U≔Sample⁡Normal⁡0,0.3,100
U≔−0.321727238399481−0.0987233611641195−0.1851275810729370.0643400235735872−0.007628438412715390.518646385253350−0.4904570263031710.4713516515262900.05110752642312250.3019435226255430.0806138037474931−0.439794134087633−0.0107273561518490−0.00195100903879099−0.0171549006699714−0.05538002838747870.0611566207113337−0.0296615472081370−0.0248094291125946−0.05043573843642240.0486063899603798−0.202775612901785−0.1322392932145600.2688059955778650.1383068860140070.3833931156821540.0703697885383742−0.0108823473881049−0.134654437053644−0.350211925597414−0.365382865182373−0.3464075882778750.0328977969850794−0.1859428141923850.192645301393477−0.0512312754294732−0.2460156723083950.403900558989702−0.295811568047437−0.289751638049954−0.4093877159417230.4950236158692230.404412454056052−0.3076121778559770.06893641825917290.445480373904158−0.390092716234762−0.1128393348708620.01853525900016190.240572348742312−0.03899264116525770.03374535918123980.189108177538398−0.00626878190525176−0.249132846899220−0.0787957530423553−0.2100900785904020.586670717583819−0.0778422496867822−0.02462551876872900.364673835787499−0.2949395441278970.5792071946668060.03682053257602590.129883626345462−0.1573331453588410.0672646655783495−0.1242676704295120.01065784086889160.5951136293039970.6640138768171070.2643689665880630.266056935168126−0.258499784192641−0.271983391002268−0.263019295304916−0.0652471378859968−0.1008465522867410.164812972805739−0.359264530214500−0.278253101861857−0.398985181626683−0.3391308094409330.381561075201006−0.4429546390347170.484014747280828−0.2056026208102460.324723870276193−0.233020470143960−0.1666444314283930.3217175543304750.0214058932888665−0.05463687734686660.188564863085573−0.217755193503086−0.1240141015800070.462724590346982−0.0660928282271428−0.2522448074258150.115519803619994
V≔seq⁡sin⁡π⁢i10+Ui,i=1..100:
P≔PointPlot⁡V:
Q≔plot⁡sin⁡π⁢x10,x=0..100,thickness=3:
plotsdisplay⁡P,Q
Compute 5-element moving averages.
W≔MovingAverage⁡V,5
R≔LineChart⁡W,xcoords=seq⁡i,i=2..98,thickness=3:
plotsdisplay⁡P,Q,R
Apply exponential smoothing.
U1≔ExponentialSmoothing⁡V,0.2
U2≔ExponentialSmoothing⁡V,0.8
R≔LineChart⁡U1,U2,color=red,blue,thickness=3:
plotsdisplay⁡P,R
Use lowess smoothing.
X≔seq⁡i,i=1..100:
R≔ScatterPlot⁡X,V,lowess,degree=3,color=blue,thickness=3:
See Also
Statistics
Statistics[Commands]
Statistics[DataManipulation]
TimeSeriesAnalysis
TimeSeriesAnalysis[ExponentialSmoothingModel]
Download Help Document