Important: The stats package has been deprecated. Use the superseding package Statistics instead.
>

$\mathrm{with}\left(\mathrm{stats}\right)\:$

>

$\mathrm{data}\u2254\left[2\,6\,1\,5\,3\,7\,2\,1\,2\,2\,4\right]$

${\mathrm{data}}{:=}\left[{2}{\,}{6}{\,}{1}{\,}{5}{\,}{3}{\,}{7}{\,}{2}{\,}{1}{\,}{2}{\,}{2}{\,}{4}\right]$
 (1) 
Replace each data point by the mean of itself and its two neighbors (so the size of the neighborhood is three).
>

$\mathrm{transform}\[\mathrm{moving}\[3\]\]\left(\mathrm{data}\right)$

$\left[{3}{\,}{4}{\,}{3}{\,}{5}{\,}{4}{\,}\frac{{10}}{{3}}{\,}\frac{{5}}{{3}}{\,}\frac{{5}}{{3}}{\,}\frac{{8}}{{3}}\right]$
 (2) 
Give more weight to the central item.
>

$\mathrm{transform}\[\mathrm{moving}\[3\,\mathrm{mean}\,\left[1\,4\,1\right]\]\]\left(\mathrm{data}\right)$

$\left[\frac{{9}}{{2}}{\,}\frac{{5}}{{2}}{\,}{4}{\,}{4}{\,}\frac{{11}}{{2}}{\,}\frac{{8}}{{3}}{\,}\frac{{4}}{{3}}{\,}\frac{{11}}{{6}}{\,}\frac{{7}}{{3}}\right]$
 (3) 
The first point is calculated by
>

$\mathrm{describe}\[\mathrm{mean}\]\left(\left[\mathrm{Weight}\left(2\,1\right)\,\mathrm{Weight}\left(6\,4\right)\,\mathrm{Weight}\left(1\,1\right)\right]\right)$

if you replace by the median instead of the mean, you have:
>

$\mathrm{transform}\[\mathrm{moving}\[3\,\mathrm{median}\]\]\left(\mathrm{data}\right)$

$\left[{2}{\,}{5}{\,}{3}{\,}{5}{\,}{3}{\,}{2}{\,}{2}{\,}{2}{\,}{2}\right]$
 (5) 
Using 4moving average results in
>

$\mathrm{Four\_m}\u2254\mathrm{transform}\[\mathrm{moving}\[4\]\]\left(\mathrm{data}\right)$

${\mathrm{Four\_m}}{:=}\left[\frac{{7}}{{2}}{\,}\frac{{15}}{{4}}{\,}{4}{\,}\frac{{17}}{{4}}{\,}\frac{{13}}{{4}}{\,}{3}{\,}\frac{{7}}{{4}}{\,}\frac{{9}}{{4}}\right]$
 (6) 
and the 4centered average is given by
>

$\mathrm{Four\_c}\u2254\mathrm{transform}\[\mathrm{moving}\[2\]\]\left(\mathrm{Four\_m}\right)$

${\mathrm{Four\_c}}{:=}\left[\frac{{29}}{{8}}{\,}\frac{{31}}{{8}}{\,}\frac{{33}}{{8}}{\,}\frac{{15}}{{4}}{\,}\frac{{25}}{{8}}{\,}\frac{{19}}{{8}}{\,}{2}\right]$
 (7) 