How Do You Calculate Percentile? Formula and Example

By Dr. Zubair Khalid, DVM, MS, PhD ·

How Do You Calculate Percentile? Formula and Example

If you want to know how do you calculate percentile, the short version is this: sort the data, convert the percentile into a rank position, then read or interpolate the value at that position. The rank formula is $r = \frac{p}{100}(n-1)$, where $p$ is the percentile you want and $n$ is the number of values. The value sitting at that rank is your percentile.

Quick Answer

  • A percentile is a value in an ordered data set below which a given percentage of the data falls [1].
  • The 50th percentile is the median, and the 25th, 50th and 75th percentiles are the quartiles [2].
  • To find a percentile, sort the data, compute the rank $r = \frac{p}{100}(n-1)$, then interpolate between the two values that bracket that rank.
  • If the rank lands exactly on a whole number $r$, the percentile is simply the value at position $r+1$ in the sorted list.
  • Software like Excel, R and Python use slightly different interpolation rules, so the same data can give slightly different answers depending on the tool [1][2].

The Formula

There are two directions you can go, and people often mix them up. One finds the value at a given percentile. The other finds the percentile of a given value.

Finding the value at a percentile (the one most searchers want):

$$r = \frac{p}{100}(n-1)$$

  • $p$ is the percentile you want, expressed as a number from 0 to 100.
  • $n$ is the number of observations in the data set.
  • $r$ is the rank position, which is usually not a whole number.
  • If $r$ is a whole number, the percentile is the value at position $r+1$ in the sorted list (counting from 1).
  • If $r$ is not a whole number, let $k$ be the integer part and $d$ the decimal part. The percentile is $X_{k+1} + d \cdot (X_{k+2} - X_{k+1})$, where $X$ is the sorted data [1].

Finding the percentile of a value (the reverse direction):

$$p = \frac{x}{n} \cdot 100$$

Here $x$ is the number of data values below the value you are ranking, and $n$ is the total number of values [3]. This gives you a percentile rank, which answers "where does this score sit?"

The two formulas are not exact inverses of each other because of ties and rounding, which is one reason different tools disagree at the edges.

How to Calculate It Step by Step

  1. Sort the data from smallest to largest. Percentiles only make sense on ordered data [4].
  2. Count the observations to get $n$.
  3. Choose your percentile $p$, for example 25 for the 25th percentile.
  4. Compute the rank with $r = \frac{p}{100}(n-1)$.
  5. Read the value at that rank. If the rank $r$ is a whole number, take the value at position $r+1$. If it is not, interpolate between the values at positions $k+1$ and $k+2$, where $k$ is the integer part of $r$.
  6. Check your answer against a spreadsheet or a statistics function, since interpolation conventions vary [1][2].

Worked Example

Take the exam scores of 10 students. The data are already sorted here, but you should always sort first.

student_idscore
155
262
368
472
575
680
784
888
991
1095

Sorted data with $n = 10$: 55, 62, 68, 72, 75, 80, 84, 88, 91, 95.

25th percentile. The rank is $r = \frac{25}{100}(10-1) = 2.25$. The integer part is 2 and the decimal part is 0.25, so you interpolate between the 3rd and 4th values, which are 68 and 72:

$$68 + (72 - 68)(2.25 - 2) = 69.00$$

50th percentile. The rank is $r = \frac{50}{100}(10-1) = 4.50$. Interpolate between the 5th and 6th values, 75 and 80:

$$75 + (80 - 75)(4.50 - 4) = 77.50$$

75th percentile. The rank is $r = \frac{75}{100}(10-1) = 6.75$. Interpolate between the 7th and 8th values, 84 and 88:

$$84 + (88 - 84)(6.75 - 6) = 87.00$$

So P25 = 69.00, P50 = 77.50 and P75 = 87.00. A quick check in Python confirms it:

import numpy as np
scores = [55, 62, 68, 72, 75, 80, 84, 88, 91, 95]
print(np.percentile(scores, [25, 50, 75]))

Output:

[69.  77.5 87. ]

The dot plot of these 10 scores, with dashed vertical lines at 69.00, 77.50 and 87.00, shows how the quartiles cut the distribution into four roughly equal groups.

How to Interpret the Result

A percentile is a position, not a score out of 100. If a student scores at the 87th percentile, that does not mean they got 87%. It means about 87% of the group scored at or below that value, and about 13% scored above it [4].

The 50th percentile of 77.50 tells you half the class scored below 77.50 and half scored above. The gap between P25 (69.00) and P75 (87.00) is 18 points, which describes how spread out the middle half of the class is. That gap is the interquartile range, and it is a common way to describe spread without being thrown off by extreme values [5].

Percentiles are most useful for comparison. A raw score of 80 means little on its own, but knowing it sits at the 60th percentile tells you exactly where it stands relative to everyone else [3].

Doing It in Software

You rarely compute percentiles by hand once you have more than a few dozen values. The defaults of Excel's PERCENTILE.INC, R's quantile() and NumPy's percentile() all match the hand calculation above, but each tool also offers other methods that give slightly different numbers.

Excel. PERCENTILE.INC(array, k) returns the value at percentile $k$, where $k$ is between 0 and 1. PERCENTILE.EXC(array, k) uses a different interpolation rule and excludes the endpoints. For the data above, =PERCENTILE.INC(A1:A10, 0.25) returns 69.00. If you want the percentile rank of a value instead, use PERCENTRANK.INC or PERCENTRANK.EXC, or count values below it and divide by the total.

R. quantile(x, probs = 0.25) returns the 25th percentile. R offers nine different quantile types through the type argument, and the default is type 7. quantile(scores, probs = c(0.25, 0.5, 0.75)) gives you all three quartiles at once.

Python. numpy.percentile(scores, 25) returns the 25th percentile using linear interpolation by default. The scipy.stats.percentileofscore function goes the other way and returns the percentile rank of a score, with a kind argument that controls how ties are handled [6].

If you are working with percentages more broadly, the percentage calculator handles the arithmetic side quickly.

Common Mistakes

  • Forgetting to sort the data. Percentiles are defined on ordered data. Running the formula on unsorted values gives a meaningless number. Fix: sort ascending first, every time [4].
  • Confusing the percentile with the percentage score. Scoring 90% on a test and being in the 90th percentile are different things. Fix: check whether the question asks for a value or a position.
  • Using the wrong $n$. Some formulas use $n$, others use $n-1$ or $n+1$. The rank formula here uses $n-1$ [1]. Fix: write down which convention you are using before you start.
  • Assuming all methods agree. Excel's PERCENTILE.EXC, R's nine quantile types and NumPy's method argument give different interpolation rules, so P25 can differ by a fraction of a point depending on the method chosen [1][2]. Fix: state the method when the exact value matters.
  • Ignoring ties. When several values are identical, "below" and "at or below" give different percentile ranks [6]. Fix: decide whether ties count as below or at-or-below and apply it consistently.
  • Treating a percentile as a cutoff for a population. A percentile from a small sample is an estimate, not a fixed property of the population [2]. Fix: report the sample size alongside the percentile.

Limitations

A percentile tells you about position, not about the shape of the distribution or the size of the gaps. Two data sets can share the same 90th percentile while looking completely different in the middle. Percentiles also compress information: you lose the actual distances between values, so you cannot reconstruct the data from percentiles alone.

The method also depends on the interpolation convention you pick. With small samples, the choice between methods can shift the answer noticeably, and there is no single standard that all software follows [1][2]. For very small data sets, percentiles are unstable and can mislead. A 90th percentile from 10 observations is a rough estimate, not a precise boundary.

Frequently Asked Questions

What is the difference between a percentile and a percentage?

A percentage is a fraction out of 100, like 80%. A percentile is a position in a ranked data set, like the 80th percentile. A score can be 80% correct and still sit at the 60th percentile if most people did better. The two numbers measure different things.

How do you calculate percentile rank of a score?

Count how many values in the data set fall below the score, divide that count by the total number of values, then multiply by 100. The formula is $p = \frac{x}{n} \cdot 100$, where $x$ is the count below and $n$ is the total [3]. If ties matter, decide whether equal values count as below or at-or-below [6].

Why do Excel and Python give different percentiles for the same data?

With default settings they usually do not. Excel's PERCENTILE.INC, NumPy's default and R's default type 7 all interpolate at the same rank $\frac{p}{100}(n-1)$. Differences appear when you use PERCENTILE.EXC, another R type or a different NumPy method, and they matter most at the extremes or with small samples [1][2].

Can a percentile be a value that is not in the data set?

Yes. Interpolation often produces a value between two observations. In the example above, the 25th percentile is 69.00, which is not one of the 10 scores. That is expected and correct.

What percentile is the median?

The median is the 50th percentile [2]. It splits the ordered data in half, with 50% of values below it and 50% above. The 25th and 75th percentiles are the first and third quartiles, and together with the median they divide the data into four quarters [5].

For a broader treatment of how percentiles relate to other position measures, see Percentiles: What They Are and How to Calculate Them. If you are working with standardized scores, Z-Scores and Percentiles: How They Relate and How to Convert covers the conversion, and the Z-table guide shows how to read probabilities off the normal curve.

References

  1. Percentile
  2. 7.2.6.2. Percentiles
  3. 2.3: Location of the Data - Statistics LibreTexts/02%3A_Descriptive_Statistics/2.03%3A_Location_of_the_Data)
  4. 6.10: Percentiles - Mathematics LibreTexts
  5. The Sofia Open Content Initiative - Elementary Statistics
  6. percentileofscore, SciPy v1.18.0 Manual

Further Reading

Related Articles