When I try to calculate the 75th percentile in MATLAB, I get a different value than in NumPy.
MATLAB:
>> x = [ 11.308 ; 7.2896; 7.548 ; 11.325 ; 5.7822; 9.6343; 7.7117; 7.3341; 10.398 ; 6.9675; 10.607 ; 13.125 ; 7.819 ; 8.649 ; 8.3106; 12.129 ; 12.406 ; 10.935 ; 12.544 ; 8.177 ] >> prctile(x, 75) ans = 11.3165
Python + NumPy:
>>> import numpy as np >>> x = np.array([ 11.308 , 7.2896, 7.548 , 11.325 , 5.7822, 9.6343, 7.7117, 7.3341, 10.398 , 6.9675, 10.607 , 13.125 , 7.819 , 8.649 , 8.3106, 12.129 , 12.406 , 10.935 , 12.544 , 8.177 ]) >>> np.percentile(x, 75) 11.312249999999999
I also checked the answer with R, and I get a NumPy response.
R:
> x <- c(11.308 , 7.2896, 7.548 , 11.325 , 5.7822, 9.6343, + 7.7117, 7.3341, 10.398 , 6.9675, 10.607 , 13.125 , + 7.819 , 8.649 , 8.3106, 12.129 , 12.406 , 10.935 , + 12.544 , 8.177) > quantile(x, 0.75) 75% 11.31225
What's going on here? And is there a way to make Python and R behavior mirror MATLAB?