Skip to content

Quantiles and the ECDF

Read any percentile from an ECDF, compare groups with it, and watch for quantile definitions that differ between tools.

Applied ~9 min7 steps

What runs in CodeSplash

You will be able to

  • Read a percentile and a share from an ECDF
  • Explain why ECDFs need no bins
  • Name the quantile definition CodeSplash uses

Read first

01

Quantiles

Read

A quantileQuantileThe value below which a given share of the data falls; the median is the 0.5 quantile. cuts sorted data at a share. The 90th percentile is the value that 90% of observations fall at or below. The median is the 50th percentile, and the quartiles are the 25th and 75th.

Percentiles answer questions that means can't: "how slow are our slowest 5% of requests?"

02

The ECDF

Explore

The ECDFEmpirical CDFFor each value, the share of observations at or below it; a step plot with no bins to choose. plots, for each value, the share of observations at or below it. It rises in a step at each data point and needs no bins.

ECDFWhat share of values falls below any threshold, and how do groups differ across the whole range?
View data
minutesdevice
19.190Desktop
4.460Desktop
13.850Desktop
24.570Desktop
7.270Desktop
24.810Desktop
20.940Desktop
5.360Desktop
4.020Desktop
11.450Desktop
23.480Desktop
29.930Desktop
5.490Desktop
7.540Desktop
29.260Desktop
12.350Desktop
10.810Desktop
12.440Desktop
15.270Desktop
19.130Desktop
23.300Desktop
11.280Desktop
19.390Desktop
6.850Desktop
10.160Desktop
8.450Desktop
6.150Desktop
10.110Desktop
8.240Desktop
8.220Desktop
6.910Desktop
5.940Desktop
24.710Desktop
14.720Desktop
7.710Desktop
10.540Desktop
7.580Desktop
4.190Desktop
43.890Desktop
4.870Desktop
2.800Desktop
10.790Desktop
10.040Desktop
11.800Desktop
11.330Desktop
6.920Desktop
17.200Desktop
7.880Desktop
9.670Desktop
13.760Desktop
27.550Desktop
13.530Desktop
2.590Desktop
9.040Desktop
19.980Desktop
8.660Desktop
11.670Desktop
44.110Desktop
16.120Desktop
19.040Desktop

First 60 of 570 rows.

Read across from 0.5 to the curve, then down: that's the median. Read up from a value to the curve, then across: that's the share at or below it. Try both on this chart.

03

Reading two curves

Predict

Predict first

Two ECDFs are drawn on one chart. Group B's curve sits to the right of group A's everywhere. Which group tends to have larger values?

Group AGroup BCan't tell
Reveal

The answer: Group B

Group B. To the right means that at any given share, its value is larger. A vertical gap between the curves is what the Kolmogorov–Smirnov test measures.

Two-sample ECDF with KS gapWhere do two distributions differ most?
View data
minutescourier
24.800Northside
14.100Northside
22.400Northside
26.600Northside
17.700Northside
26.600Northside
25.400Northside
15.500Northside
13.400Northside
21Northside
26.200Northside
28Northside
15.700Northside
18Northside
27.800Northside
21.600Northside
20.600Northside
21.600Northside
23.100Northside
24.700Northside
26.200Northside
20.900Northside
24.800Northside
17.300Northside
20.100Northside
18.800Northside
16.500Northside
20.100Northside
18.600Northside
18.600Northside
17.300Northside
16.200Northside
26.600Northside
22.800Northside
18.100Northside
20.400Northside
18Northside
13.700Northside
30.800Northside
14.800Northside
10.600Express
22Express
21.200Express
23.100Express
22.600Express
17.300Express
28.400Express
18.600Express
20.800Express
25.200Express
36.700Express
24.900Express
10.100Express
20Express
30.800Express
19.500Express
23Express
47.500Express
27.400Express
30Express

First 60 of 80 rows.

04

Quantile definitions differ

Read

With few points, a percentile may fall between two values, and tools interpolate differently. R offers nine definitions.

CodeSplash uses type 7, the default in both R and NumPy, so Python and R agree. If another tool gives a slightly different quartile, this is usually why.

Python
import numpy as np

x = [1, 2, 3, 4, 10]
print(np.quantile(x, [0.25, 0.5, 0.75]))  # linear interpolation: R's type 7
R
x <- c(1, 2, 3, 4, 10)
quantile(x, c(0.25, 0.5, 0.75), type = 7)
05

In the app

In the app

Descriptive statistics reports quartiles and percentiles. In Charts, open ECDF and use Use my data to draw it on your own column.

New York air quality, 1973
06

Check your understanding

Checkpoint

Check yourself

On an ECDF, the curve reaches 0.8 at the value 120 ms. What percentage of requests took longer than 120 ms?

Show the answer

Answer: 20

80% took 120 ms or less, so 100 − 80 took longer.

Check yourself

What does an ECDF have that a histogram doesn't?

Show the answer

Answer: a

Bin choices can change a histogram's story. An ECDF has none, though peaks are easier to see on a histogram.

07

Recap

Recap
  • Quantiles answer questions about tails that means can't.
  • The ECDF shows every percentile at once, with no bins.
  • CodeSplash uses type 7 quantiles in both engines.

Concepts in this lesson