Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Understanding the subtle difference in calculating percentile

When calculating the percentile using numpy, I see some authors use:

Q1, Q3 = np.percentile(X, [25, 75])

which is clear to me. However, I also see others use:

loss = np.percentile(X, 4)

I presume 4 implies dividing the 100 into 4 percentiles but how the loss is calculated here (i.e., in the second case)?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thank you

>Solution :

I don’t know where you found the second case but it’s incorrect (or misinterpreted).

np.percentile(X, 4) simply calculates the 4th percentile.

X = np.arange(0, 101)

np.percentile(X, [25, 75])
# array([25., 75.])

np.percentile(X, 4)
# 4.0
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading