Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Percentile
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Calculation methods== {{Synthesis|section|date=February 2023}} {{wide image|Frequency histogram and exclusive and inclusive percentiles 2.png|center|Interpolated and nearest-rank, exclusive and inclusive, percentiles for 10-score distribution}} There are many formulas or algorithms<ref>{{cite web |last1=Wessa |first1=P |title=Percentiles in Free Statistics Software |url=http://www.wessa.net/rwasp_percentiles.wasp/ |year=2021 |publisher=Office for Research Development and Education |access-date=13 November 2021}}</ref> for a percentile score. Hyndman and Fan <ref name="hyndman"/> identified nine and most statistical and spreadsheet software use one of the methods they describe.<ref name="nist"/> Algorithms either return the value of a score that exists in the set of scores (nearest-rank methods) or interpolate between existing scores and are either exclusive or inclusive. {| class="wikitable" |+ Nearest-rank methods (exclusive/inclusive) |- align="center" !PC: percentile specified !! 0.10 !! 0.25 !! 0.50 !! 0.75 !! 0.90 |- align="center" |N: Number of scores || 10 || 10 || 10 || 10 || 10 |- align="center" |OR: ordinal rank = PC Γ N || 1 || 2.5 || 5 || 7.5 || 9 |- align="center" |Rank: >OR / β₯OR || 2/1 || 3/3 || 6/5 || 8/8 || 10/9 |- align="center" |Score at rank (exc/inc) || 2/1 || 3/3 || 4/3 || 5/5 || 7/5 |} The figure shows a 10-score distribution, illustrates the percentile scores that result from these different algorithms, and serves as an introduction to the examples given subsequently. The simplest are nearest-rank methods that return a score from the distribution, although compared to interpolation methods, results can be a bit crude. The Nearest-Rank Methods table shows the computational steps for exclusive and inclusive methods. {| class="wikitable" |+ Interpolated methods (exclusive/inclusive) |- align="center" !PC: percentile specified !! 0.10 !! 0.25 !! 0.50 !! 0.75 !! 0.90 |- align="center" |N: number of scores || 10 || 10 || 10 || 10 || 10 |- align="center" |OR: PCΓ(N+1) / PCΓ(Nβ1)+1 || 1.1/1.9 || 2.75/3.25 || 5.5/5.5 || 8.25/7.75 || 9.9/9.1 |- align="center" |LoRank: OR truncated || 1/1 || 2/3 || 5/5 || 8/7 || 9/9 |- align="center" |HIRank: OR rounded up || 2/2 || 3/4 || 6/6 || 9/8 || 10/10 |- align="center"- |LoScore: score at LoRank || 1/1 || 2/3 || 3/3 || 5/4 || 5/5 |- align="center" |HiScore: score at HiRank || 2/2 || 3/3 || 4/4 || 5/5 || 7/7 |- align="center" |Difference: HiScore β LoScore || 1/1 || 1/0 || 1/1 || 0/1 || 2/2 |- align="center" |Mod: fractional part of OR || 0.1/0.9 || 0.75/0.25 || 0.5/0.5 || 0.25/0.75 || 0.9/0.1 |- align="center" |Interpolated score (exc/inc) <br/> = LoScore + Mod Γ Difference || 1.1/1.9 || 2.75/3 || 3.5/3.5 || 5/4.75 || 6.8/5.2 |} Interpolation methods, as the name implies, can return a score that is between scores in the distribution. Algorithms used by statistical programs typically use interpolation methods, for example, the percentile.exc and percentile.inc functions in Microsoft Excel. The Interpolated Methods table shows the computational steps. ===The nearest-rank method=== [[File:Percentile.png|thumb|450px|The percentile values for the ordered list {15, 20, 35, 40, 50}]] One definition of percentile, often given in texts, is that the ''P''-th percentile <math>(0 < P \le 100)</math> of a list of ''N'' ordered values (sorted from least to greatest) is the smallest value in the list such that no more than ''P'' percent of the data is strictly less than the value and at least ''P'' percent of the data is less than or equal to that value. This is obtained by first calculating the ordinal rank and then taking the value from the ordered list that corresponds to that rank. The [[Ordinal scale|ordinal]] [[Ranking|rank]] ''n'' is calculated using this formula : <math> n = \left \lceil \frac{P}{100} \times N \right \rceil. </math> * Using the nearest-rank method on lists with fewer than 100 distinct values can result in the same value being used for more than one percentile. * A percentile calculated using the nearest-rank method will always be a member of the original ordered list. * The 100th percentile is defined to be the largest value in the ordered list. ===The linear interpolation between closest ranks method=== An alternative to rounding used in many applications is to use [[linear interpolation]] between adjacent ranks. All of the following variants have the following in common. Given the [[order statistics]] : <math>\{v_i,i=1,2,\ldots,N : v_{i+1}\ge v_i,\forall i=1,2,\ldots,N-1\},</math> we seek a linear interpolation function that passes through the points <math>(v_i,i)</math>. This is simply accomplished by : <math>v(x) = v_{\lfloor x\rfloor} + (x \bmod 1)(v_{\lfloor x\rfloor+1}-v_{\lfloor x\rfloor}),\forall x\in[1,N] : v(i)=v_i \text{, for } i=1,2,\ldots,N,</math> where <math>\lfloor x\rfloor</math> uses the [[floor function]] to represent the integral part of positive {{mvar|x}}, whereas <math>x\bmod 1</math> uses the [[mod function]] to represent its fractional part (the remainder after division by 1). (Note that, though at the endpoint <math>x = N</math>, <math>v_{\lfloor x\rfloor+1}</math> is undefined, it does not need to be because it is multiplied by <math>x \bmod 1 = 0</math>.) As we can see, {{mvar|x}} is the continuous version of the subscript {{mvar|i}}, linearly interpolating {{mvar|v}} between adjacent nodes. There are two ways in which the variant approaches differ. The first is in the linear relationship between the ''rank'' {{mvar|x}}, the ''percent rank'' <math>P=100p</math>, and a constant that is a function of the sample size {{mvar|N}}: : <math>x=f(p,N)=(N+c_1)p+c_2.</math> There is the additional requirement that the midpoint of the range <math>(1,N)</math>, corresponding to the [[median]], occur at <math>p=0.5</math>: : <math>\begin{align} f(0.5,N)&=\frac{N+c_1}{2}+c_2=\frac{N+1}{2}\\ \therefore 2c_2+c_1&=1 \end{align},</math> and our revised function now has just one degree of freedom, looking like this: : <math>x=f(p,N)=(N+1-2C)p+C.</math> The second way in which the variants differ is in the definition of the function near the margins of the <math>[0,1]</math> range of {{mvar|p}}: <math>f(p,N)</math> should produce, or be forced to produce, a result in the range <math>[1,N]</math>, which may mean the absence of a one-to-one correspondence in the wider region. One author has suggested a choice of <math>C = \tfrac{1}{2} (1+\xi)</math> where {{mvar|ξ}} is the shape of the [[Generalized extreme value distribution]] which is the extreme value limit of the sampled distribution. ====First variant, ''C'' = 1/2==== [[File:Percentile interpolation.png|thumb|450px|The result of using each of the three variants on the ordered list {15, 20, 35, 40, 50}]] (Sources: Matlab "prctile" function,<ref>{{cite web |url=http://www.mathworks.com/access/helpdesk/help/toolbox/stats/prctile.html |title=Matlab Statistics Toolbox β Percentiles |access-date=2006-09-15}}, This is equivalent to Method 5 discussed [[Quantile#Estimating the quantiles of a population|here]]</ref><ref>{{cite journal|last1=Langford|first1=E.|title=Quartiles in Elementary Statistics|journal=Journal of Statistics Education|date=2006|volume=14|issue=3|doi=10.1080/10691898.2006.11910589|doi-access=free}}</ref>) : <math>x=f(p)=\begin{cases} Np+\frac{1}{2},\forall p\in\left [p_1,p_N\right ], \\ 1,\forall p\in\left [0,p_1\right ], \\ N,\forall p\in\left [p_N,1\right ]. \end{cases}</math> where : <math>p_i=\frac{1}{N}\left(i-\frac{1}{2}\right),i\in[1,N]\cap\mathbb{N}</math> : <math>\therefore p_1=\frac{1}{2N}, p_N=\frac{2N-1}{2N}.</math> Furthermore, let : <math>P_i=100p_i.</math> The inverse relationship is restricted to a narrower region: : <math>p=\frac{1}{N}\left(x-\frac{1}{2}\right),x\in(1,N)\cap\mathbb{R}.</math> ====Second variant, ''C'' = 1==== [Source: Some software packages, including [[NumPy]]<ref name="numpydocs">{{cite web | url = https://docs.scipy.org/doc/numpy/reference/generated/numpy.percentile.html | title = NumPy 1.12 documentation | access-date = 2017-03-19 | publisher = [[SciPy]] }}</ref> and [[Microsoft Excel]]<ref name="pottel" /> (up to and including version 2013 by means of the PERCENTILE.INC function). Noted as an alternative by [[National Institute of Standards and Technology|NIST]].<ref name="nist">{{cite web | url = http://www.itl.nist.gov/div898/handbook/prc/section2/prc262.htm | title = Engineering Statistics Handbook: Percentile | access-date = 2009-02-18 | publisher = [[NIST]] }}</ref>] : <math>x = f(p,N) = p(N-1)+1 \text{, } p\in[0,1]</math> : <math>\therefore p = \frac{x-1}{N-1} \text{, } x\in[1,N].</math> Note that the <math>x\leftrightarrow p</math> relationship is one-to-one for <math>p\in[0,1]</math>, the only one of the three variants with this property; hence the "INC" suffix, for ''inclusive'', on the Excel function. ====Third variant, ''C'' = 0==== (The primary variant recommended by [[National Institute of Standards and Technology|NIST]].<ref name="nist" /> Adopted by Microsoft Excel since 2010 by means of PERCENTIL.EXC function. However, as the "EXC" suffix indicates, the Excel version ''excludes'' both endpoints of the range of ''p'', i.e., <math>p\in(0,1)</math>, whereas the "INC" version, the second variant, does not; in fact, any number smaller than <math>\frac 1 {N+1}</math> is also excluded and would cause an error.) : <math>x = f(p,N) = \begin{cases} 1\text{, }p\in\left[0,\frac{1}{N+1}\right] \\ p(N+1)\text{, }p\in\left(\frac{1}{N+1},\frac{N}{N+1}\right) \\ N\text{, }p\in\left[\frac{N}{N+1},1\right] \end{cases}.</math> The inverse is restricted to a narrower region: : <math>p = \frac{x}{N+1}\text{, }x\in(0,N).</math> ==={{anchor|Weighted percentile}}The weighted percentile method=== {{see also|Weighted median}} In addition to the percentile function, there is also a ''weighted percentile'', where the percentage in the total weight is counted instead of the total number. There is no standard function for a weighted percentile. One method extends the above approach in a natural way. Suppose we have positive weights <math>w_1, w_2, w_3, \dots, w_N</math> associated, respectively, with our ''N'' sorted sample values. Let : <math>S_N = \sum_{k=1}^N w_k,</math> the sum of the weights. Then the formulas above are generalized by taking : <math>p_n = \frac{1}{S_N}\left(S_n - \frac{w_n}{2}\right)</math> when <math>C=1/2</math>, or : <math>p_n = \frac{S_n - Cw_n}{S_N +(1-2C)w_n}</math> for general <math>C</math>, and : <math>v = v_k + \frac{P - p_k}{p_{k + 1} - p_k}(v_{k + 1} - v_k).</math> The 50% weighted percentile is known as the [[weighted median]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)