Monday, June 15, 2009

Calculating Percentile

Procedure of calculating (k%) percentile:

Assume that we have an array M of n numbers
(1) Sort in increasing order, calculate (n-1)*k%, the integer part is i, and decimal part is j.
(2) Result=(1-j)*M_(i+1) + j*M_(i+2).
Special cases:
if j=0, the results is M_(i+1); if M_(i+1)=M_(i+2) either of them is the result.

Quartile can be calculated this way,
1st Quartile k%=25%
2nd Quartile k%=50%
3rd Quartile k%=75%

No comments:

Post a Comment