MovingMedian - Maple Help

# Online Help

###### All Products    Maple    MapleSim

Statistics

 MovingMedian
 compute moving medians for a data set

 Calling Sequence MovingMedian(X, m, options)

Parameters

 X - m - posint; moving window size options - (optional) equation(s) of the form option=value where option is one of weights or ignore; specify options for the Statistics[MovingMedian] function

Description

 • The MovingMedian function computes moving medians for a set of observations. This is useful for smoothing the data, thus eliminating cyclic and irregular patterns and therefore enhancing the long term trends.
 • The first parameter X is a single data sample - given as e.g. a Vector. Each value represents an individual observation.
 • The second parameter m is the size of the moving window. The size of the moving window cannot exceed the number of elements in X (or the number of non-missing elements if ignore is set to true). The number of items in the answer is less than the number of items in data. Only complete neighborhoods are included, so the number of items is reduced by m-$1$.

Options

 The options argument can contain one or more of the options shown below. These options are described in more detail in the Statistics[Median] help page.
 • weights=rtable -- Vector of weights (one-dimensional rtable). The weights will be used to compute the local medians (see Statistics[Median]. The number of elements in the weights array should be equal to the size of the moving window.
 • ignore=truefalse -- This option is used to specify how to handle non-numeric data. If ignore is set to true all non-numeric items in X will be ignored.

Examples

 > $\mathrm{with}\left(\mathrm{Statistics}\right):$
 > $A≔\mathrm{Array}\left(\left[1,2,10,2,1,2,10,2,1\right]\right)$
 ${A}{≔}\left[\begin{array}{ccccccccc}{1}& {2}& {10}& {2}& {1}& {2}& {10}& {2}& {1}\end{array}\right]$ (1)
 > $\mathrm{MovingMedian}\left(A,2\right)$
 $\left[\begin{array}{cccccccc}{1.50000000000000}& {6.}& {6.}& {1.50000000000000}& {1.50000000000000}& {6.}& {6.}& {1.50000000000000}\end{array}\right]$ (2)
 > $\mathrm{MovingMedian}\left(A,3\right)$
 $\left[\begin{array}{ccccccc}{2.}& {2.}& {2.}& {2.}& {2.}& {2.}& {2.}\end{array}\right]$ (3)
 > $W≔\mathrm{Array}\left(\left[0,1,1\right]\right)$
 ${W}{≔}\left[\begin{array}{ccc}{0}& {1}& {1}\end{array}\right]$ (4)
 > $\mathrm{MovingMedian}\left(A,3,\mathrm{weights}=W\right)$
 $\left[\begin{array}{ccccccc}{6.}& {6.}& {1.50000000000000}& {1.50000000000000}& {6.}& {6.}& {1.50000000000000}\end{array}\right]$ (5)

 See Also