Thursday, July 11, 2013

Compute Trimean from Quantile in Matlab

Since, Trimean is robust to outliers, it is recommended as summary statistics instead of simple mean. Let us give an example.

 x = [2 5 6 10 11 13 200];

In this example, taking a mean is heavily influenced by outlier value 200

mean(x)

ans =

    35.2857

But is there any better summary statistics than taking just direct mean?

Q = quantile(x,[0.25, 0.5, 0.75])

Q =

    5.2500   10.0000   12.5000

Note that here Q(2) is the median. And, Q(1) and Q(3) are first and third quantile respectively.

Now, we can compute the trimean by the weighted sum of quantiles. Median gets the higher weight since its the most robust quantile among three.

 0.25*Q(1)+0.5*Q(2)+0.25*Q(3)

ans =

    9.4375

This trimean represent x which is a better summary statistics than simple mean. 

No comments:

Post a Comment

Please ask if anything is not clear enough..........