Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2016-12-03 01:28:29

Mathilie
Member
Registered: 2016-12-03
Posts: 3

Comparing percentile by python or numpy with the definition

What do we mean by when we say percentile: percentile_of_score or score_at_percentile?
For [1, 3, 3, 4, 5, 6, 6, 7, 8, 8] written at https://www.mathsisfun.com/data/percentiles.html under "Quartiles" subtopic, the 25th, 50th, 75th percentile is written as 3, 5.5, 7, respectively.

But calculating it with python (numpy.percentile, i get the following output):
>>> from numpy import percentile
>>> data1 = [1, 3, 3, 4, 5, 6, 6, 7, 8, 8]
>>> for p in [25, 50, 75]: print(percentile(data1, p))
...
3.25
5.5
6.75

Why is there a difference? Which one is correct?
What is 25th percentile: 3 or 3.25?
What is 75th percentile: 7 or 6.75?

From mathisfun page, can I conclude the below information?
1 is the  0th percentile
3 is the 20th percentile
4 is the 30th percentile
5 is the 40th percentile
6 is the 60th percentile
7 is the 70th percentile
8 is the 90th percentile

Thanks
PS: the numpy link: https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.percentile.html & I don't know about the internal working of how it is calculated.

Offline

#2 2016-12-03 03:07:50

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Comparing percentile by python or numpy with the definition

Hi;

Mathematica says {3, 5.5, 7} and so does wolfram alpha. So I would say that MathsisFun is correct but there may be other ways to compute quartiles!


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#3 2016-12-03 06:48:58

Mathilie
Member
Registered: 2016-12-03
Posts: 3

Re: Comparing percentile by python or numpy with the definition

bobbym wrote:

Mathematica says {3, 5.5, 7} and so does wolfram alpha. So I would say that MathsisFun is correct but there may be other ways to compute quartiles!

Thanks for the reply.
I'm asking a definition type question: Is 100 percentile possible? I think theoretically no, but numpy.percentile for 100%ile doesn't give an error and gives the highest entry. Satirical: it solves the purpose what user may be seeking but is theoretically incorrect.

With your answer, my clouds of confusion over percentiles are reduced, & I wrote an answer here: http://www.mathisfunforum.com/viewtopic.php?pid=391172

Offline

#4 2016-12-03 07:00:20

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Comparing percentile by python or numpy with the definition

In regards to your previous question.

There are at least 9 different definitions of empirical quantiles.

So both numpy and Mathematica etc are correct, depending on what definition the textbook is using.

Is 100 percentile possible? I think theoretically no

I would think that 100 percentile would mean the value that 100 percent of the data would be less than. But some definitions obviously include equal to also. I have seen many cases of 100 percentile computed and urge you to look at this answer:

http://math.stackexchange.com/questions … tile#33502

whuber, is an expert on statistics and he seems to indicate 100 percentile is allowed.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

Board footer

Powered by FluxBB