naginterfaces.library.smooth.data_runningmedian(itype, y)[source]

data_runningmedian computes a smoothed data sequence using running median smoothers.

For full information please refer to the NAG Library document for g10ca


Specifies the method to be used.

If , 4253H,twice is used.

If , 3RSSH,twice is used.

yfloat, array-like, shape

The sample observations.

smoothfloat, ndarray, shape

Contains the smooth.

roughfloat, ndarray, shape

Contains the rough.

(errno )

On entry, .

Constraint: or .

(errno )

On entry, .

Constraint: .


In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.

Given a sequence of observations recorded at equally spaced intervals, data_runningmedian fits a smooth curve through the data using one of two smoothers. The two smoothers are based on the use of running medians and averages to summarise overlapping segments. The fit and the residuals are called the smooth and the rough respectively. They obey the following:

The two smoothers are:

  1. 4253H,twice consisting of a running median of , then , then , then followed by hanning. Hanning is a running weighted average, the weights being , and . The result of this smoothing is then reroughed by computing residuals, applying the same smoother to them and adding the result to the smooth of the first pass.

  2. 3RSSH,twice consisting of a running median of , two splitting operations named S to improve the smooth sequence, each of which is followed by a running median of , and finally hanning. The end points are dealt with using the method described by Velleman and Hoaglin (1981). The full smoother 3RSSH,twice is produced by reroughing as described above.

The compound smoother 4253H,twice is recommended. The smoother 3RSSH,twice is popular when calculating by hand as it requires simpler computations and is included for comparison purposes.


Tukey, J W, 1977, Exploratory Data Analysis, Addison–Wesley

Velleman, P F and Hoaglin, D C, 1981, Applications, Basics, and Computing of Exploratory Data Analysis, Duxbury Press, Boston, MA