movmad
Moving median absolute deviation over a sliding window.
Category: Data Import and Analysis > Preprocessing Data
Syntax
M = movmad(A, wlen)
Median absolute deviation over a window of wlen elements centered on each element.
M = movmad(A, [nb na])
Window of nb elements before and na after the current one, plus the element itself.
Description
Inside each window the function computes median(abs(x - median(x))). This is a robust measure of spread: a single wild value in the window hardly changes it, which makes movmad better than movstd for noisy data with spikes.
Windows shrink at the ends of the data.
Input arguments
A- Vector or matrix; operates along the first non-singleton dimension.
wlen- Window length. For an even length the window is centered between elements, with one more element before than after.
Output arguments
M- Array of the same size as
A.
Example
Robust rolling spread
x = [1 2 3 10 5];
movmad(x, 3)
Output
ans = 1×5
0.5000 1.0000 1.0000 2.0000 2.5000