Median absolute deviation(MAD)

 

MAD=median(|Xi−median(X)|)

For example, use the MAD method to detect outliers of “Fare”. Threshold=3.5


A

1

=file("D://titanic.csv").import@qtc()

2

=A1.(Fare)

3

=A2.median()

4

=A2.(abs(~-A3))

5

=A4.median()*1.4826

6

=A4.(~/A5)

7

=A6.pselect@a(~>3.5)

8

=A1(A7)

A3 Calculate the median of “Fare”

A4 Calculate the absolute value of the deviation of each Fare value from the median

A5 Calculate the median of the deviation, then multiply by 1.4826 to get the MAD value

A6 Calculate the ratio of each deviation to MAD

A7 Select the sequence number of samples with ratio greater than 3.5

A8 Select the outlier samples