Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-016

Median Absolute Deviation

Problem

Return the median absolute deviation: the median of |x - median(data)|, unscaled. Return 0.0 for empty input.

Hint

Compute the median first, then take the median of the absolute deviations.

Test cases

case 1
in: [[1,2,3,4,5]]
expected: 1
case 2
in: [[1,1,2,2,4,6,9]]
expected: 1
case 3
in: [[1,2,3,4]]
expected: 1
case 4
in: [[5]]
expected: 0
case 5
in: [[]]
expected: 0
Starter codePython
def median_absolute_deviation(data):
    # Your code here
    pass

5 test cases · run your code against them in the editor