Matlab Percentile function VS excel percentile function

조회 수: 10 (최근 30일)
vijay sabawat
vijay sabawat 2011년 5월 28일
Is the matlab percentile function is equal to excel percentile function. I'm getting two different answers for the same data set.

답변 (2개)

Matt Fig
Matt Fig 2011년 5월 29일
I don't see a PERCENTILE function in MATLAB. Is it a custom function you wrote?
  댓글 수: 4
vijay sabawat
vijay sabawat 2011년 5월 29일
It depends on the sample size.. for a size of 10 the difference is about 1.5 and so. But if the sample size is large then results pretty close..
vijay sabawat
vijay sabawat 2011년 5월 29일
A = [11 15 74 42 63 21]';
B = prctile(A,30:20:70)
xlswrite('H:\test.xlsx',A)
B =
16.8000 31.5000 56.7000
using excel
=PERCENTILE($A$1:$A$6,0.3) = 18
=PERCENTILE($A$1:$A$6,0.7) = 52.5

댓글을 달려면 로그인하십시오.


Oleg Komarov
Oleg Komarov 2011년 5월 29일
I get the same results:
A = rand(1000,1);
B = prctile(A,30:20:70)
xlswrite('C:\Users\Oleg\Desktop\test.xlsx',A)
and then using PERCENTILE($A$1:$A$1000,0.3)
EDIT
Excel interpolates for values of the percentile that are not multiples of 1/(n-1). So the 25th percentile on 1:5 = 2! (online reference: percentile)
=PERCENTILE(A1:A5,0.25) where A1:A5 = 1:5 --> 2
Matlab interpolates for percentile values that are not (i -.5)/n, for i = 2, 1.5/5 = .3 which is not the 25th percentile.
prctile(1:5, .25) --> 1.7500 % Which makes more sense IMO
Hope this clarifies.
  댓글 수: 3
vijay sabawat
vijay sabawat 2011년 5월 29일
A = [11 15 74 42 63 21]';
B = prctile(A,30:20:70)
xlswrite('H:\test.xlsx',A)
B =
16.8000 31.5000 56.7000
using excel
=PERCENTILE($A$1:$A$6,0.3) = 18
=PERCENTILE($A$1:$A$6,0.7) = 52.5
Oleg Komarov
Oleg Komarov 2011년 5월 29일
See my edit.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by