The median absolute deviation (MAD) is defined as
MAD = median(abs(A − median(A)))
for a rolling window of length n. For example:
move_mad(1:10, 5)
returns [1 1 1 1 1 1];
move_mad(logspace(0, 1, 10), 3)
returns [0.292 0.377 0.486 0.628 0.811 1.048 1.353 1.748]
Round the result to 3 digits.
Solution Stats
Problem Comments
5 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers15
Suggested Problems
-
7876 Solvers
-
263 Solvers
-
Matrix indexing with two vectors of indices
781 Solvers
-
Determine if input is a Narcissistic number
219 Solvers
-
Who has power to do everything in this world?
488 Solvers
More from this Author4
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
The description was improved and the test suite fixed.
The test suite needs to be fixed so it can admit a tolerance in the solution since it is using floats. Currently MATLAB has the function movmad, but even with it, and using round the last case of the test suite fails.
The test suite has had a tolerance applied.
The tolerance isn't defined in the test suite.
@ChrisR: the tolerance is hard-coded into the assert lines (1e-3).