Data AnalyticsStatisticsbeginner
Updated:

Percentiles and Quartiles Made Clear

5 min read

Percentiles and quartiles describe position in sorted data. Learn to compute them, find the interquartile range, and use the 1.5 IQR rule to detect outliers.

TL;DR – Quick Answer

A percentile is the value below which a given percentage of the data falls; the 90th percentile is the value that 90% of the data sits below. Quartiles are the 25th, 50th and 75th percentiles, which split sorted data into four equal parts. The interquartile range (Q3 minus Q1) measures the spread of the middle half and is the basis of the standard outlier rule.

On This Page

When someone says a response time is "in the 95th percentile" or a salary is "top quartile," they are describing position in sorted data rather than a raw average. Percentiles and quartiles answer questions the mean cannot: where does this value rank, how wide is the middle of the data, and which points are unusually far out? They are the everyday tools behind box plots, SLA reports and outlier detection.

Unlike the mean, percentiles are barely affected by extreme values, which makes them the go-to summary for skewed data. This page shows exactly how they are computed, verifies the numbers by hand, and walks through the outlier rule that every analyst should know.

What percentiles and quartiles are

A percentile is a cut point: the k-th percentile is the value below which roughly k% of the data falls. The 25th percentile is the value that a quarter of the data sits below.

Quartiles are just three specific percentiles that divide sorted data into four equal quarters:

  • Q1 (first quartile) = 25th percentile — 25% of data is below it.
  • Q2 (second quartile) = 50th percentile = the median — 50% is below it.
  • Q3 (third quartile) = 75th percentile — 75% is below it.

The gap between Q1 and Q3 is the interquartile range (IQR), the span of the middle half of the data. Because it throws away the top and bottom quarters, the IQR is a robust measure of spread that shrugs off outliers, unlike the standard deviation.

A worked example, checked by hand

Take a small, illustrative sorted dataset: 10, 20, 30, 40, 50.

import numpy as np

data = np.array([10, 20, 30, 40, 50])

q1 = np.percentile(data, 25)
q2 = np.percentile(data, 50)
q3 = np.percentile(data, 75)
p90 = np.percentile(data, 90)

print("Q1:", q1)      # 20.0
print("Q2:", q2)      # 30.0
print("Q3:", q3)      # 40.0
print("IQR:", q3 - q1)  # 20.0
print("P90:", p90)    # 46.0

Expected output:

Q1: 20.0
Q2: 30.0
Q3: 40.0
IQR: 20.0
P90: 46.0

Let us verify with NumPy's linear-interpolation method. For n values, the position of the p-th percentile is (n - 1) * p. Here n = 5, so positions run from 0 to 4.

  • Q1: position = 4 × 0.25 = 1.0, which lands exactly on index 1 → the value 20.
  • Q2: position = 4 × 0.50 = 2.0, index 2 → the value 30 (the median, as expected).
  • Q3: position = 4 × 0.75 = 3.0, index 3 → the value 40.
  • P90: position = 4 × 0.90 = 3.6, which sits 60% of the way from index 3 (value 40) to index 4 (value 50). Interpolating: 40 + 0.6 × (50 − 40) = 40 + 6 = 46.

The IQR is Q3 − Q1 = 40 − 20 = 20, describing the span of the middle two values.

The outlier rule analysts rely on

The IQR powers the standard outlier test, the same one that draws box-plot whiskers. Define two fences:

lower fence = Q1 - 1.5 * IQR
upper fence = Q3 + 1.5 * IQR

Any point beyond a fence is flagged as a potential outlier. Using our example, IQR = 20, so:

lower fence = 20 - 1.5 * 20 = 20 - 30 = -10
upper fence = 40 + 1.5 * 20 = 40 + 30 =  70

Every value (10 through 50) sits inside [−10, 70], so this clean dataset has no outliers. Add a value of 200 and it would sail past the upper fence of 70 and be flagged immediately. Here is the check in code:

import numpy as np

data = np.array([10, 20, 30, 40, 50, 200])
q1, q3 = np.percentile(data, [25, 75])
iqr = q3 - q1
lower, upper = q1 - 1.5 * iqr, q3 + 1.5 * iqr
outliers = data[(data < lower) | (data > upper)]
print("outliers:", outliers)   # [200]

How analysts use them

Percentiles are the language of service-level reporting. Engineering teams track the "p95 latency" — the response time that 95% of requests beat — because the average hides the slow tail that actually annoys users. In business analytics, you segment customers into quartiles by spend to find your top 25%. In HR reporting, you place a salary within its market percentile band. In every case the appeal is the same: percentiles describe rank and are immune to a few wild values.

Common mistakes

Assuming one universal percentile formula. Different tools interpolate differently between data points, so a small sample can give slightly different Q1 values across Excel, NumPy and SQL. State your method for reproducibility; the differences vanish on large datasets.

Confusing percentile the score with percentile the rank. "Scored 90" and "in the 90th percentile" are different claims. The first is a raw value; the second is a position relative to everyone else.

Using the mean to find outliers on skewed data. A "more than 3 standard deviations" rule assumes symmetry and is itself distorted by the outliers you are hunting. The 1.5 IQR rule is more robust because the quartiles resist extreme values.

Reporting quartiles without the count. Quartiles of five values are noisy; quartiles of five thousand are stable. Always show sample size alongside percentile summaries.

In interviews

Percentiles appear in both statistics and SQL rounds. Expect "What is the IQR and how do you use it to find outliers?" — name the 1.5 IQR fences. You may be asked "Why report p95 latency instead of the average?" (the average hides the slow tail that hurts real users). SQL interviews often want PERCENTILE_CONT or NTILE to bucket rows into quartiles. A common trap question: "Is the median a percentile?" — yes, the 50th. Being fluent in the vocabulary and the outlier rule signals you can handle messy real data.

Where this fits in your learning path

Percentiles and quartiles round out the spread toolkit alongside variance and standard deviation, and they extend the median idea from mean, median and mode to any position in the data. They belong to the descriptive statistics foundation of the data analytics learning path. Master them before moving to distributions, and use the data analyst roadmap to see where box plots and outlier handling appear in real projects.

Frequently Asked Questions

What is the interquartile range?
The interquartile range, or IQR, is the third quartile minus the first quartile (Q3 minus Q1). It measures the spread of the middle 50% of the data and ignores the extreme tails. Because it discards outliers by design, it is a robust measure of spread for skewed data.
How does the 1.5 IQR rule detect outliers?
Compute the IQR, then flag any value below Q1 minus 1.5 times IQR or above Q3 plus 1.5 times IQR as a potential outlier. These boundaries are called the lower and upper fences. It is the rule that draws the whiskers on a box plot.
Is the median the same as the 50th percentile?
Yes. The median is exactly the 50th percentile and the second quartile (Q2). Half the data falls below it and half above. The three names refer to the same value.
Why do different tools give slightly different percentiles?
There are several accepted methods for interpolating a percentile when it falls between two data points. NumPy defaults to linear interpolation, but other methods like nearest-rank exist. For large datasets the differences are negligible, but for small samples they can vary.
What does being in the 90th percentile mean?
It means the value is greater than or equal to about 90% of the other values in the dataset. A student in the 90th percentile on a test scored higher than roughly 90% of test-takers. It describes rank position, not the raw score itself.

Want to Build Your Career in Data Analytics with AI?

Join CodeBegun and train with working industry engineers — View the Data Analytics curriculum

Apply for Demo Class →
Siva Prasad Galaba
Founder, CodeBegun · Staff Engineer

Founder of CodeBegun. 15+ years building Java systems at companies like Crunchyroll. Teaches Java, Spring Boot and system design the way the industry actually works, and mentors students through projects, mock interviews and placement preparation.

Technically reviewed by CodeBegun Technical TeamLast reviewed 16 July 2026 LinkedIn
Chat with us