Quantiles and the ECDF
Read any percentile from an ECDF, compare groups with it, and watch for quantile definitions that differ between tools.
What runs in CodeSplash
- Descriptive statistics Verified in Python and R
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
Quantiles
ReadA 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?"
The ECDF
ExploreThe 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.
View data
| minutes | device |
|---|---|
| 19.190 | Desktop |
| 4.460 | Desktop |
| 13.850 | Desktop |
| 24.570 | Desktop |
| 7.270 | Desktop |
| 24.810 | Desktop |
| 20.940 | Desktop |
| 5.360 | Desktop |
| 4.020 | Desktop |
| 11.450 | Desktop |
| 23.480 | Desktop |
| 29.930 | Desktop |
| 5.490 | Desktop |
| 7.540 | Desktop |
| 29.260 | Desktop |
| 12.350 | Desktop |
| 10.810 | Desktop |
| 12.440 | Desktop |
| 15.270 | Desktop |
| 19.130 | Desktop |
| 23.300 | Desktop |
| 11.280 | Desktop |
| 19.390 | Desktop |
| 6.850 | Desktop |
| 10.160 | Desktop |
| 8.450 | Desktop |
| 6.150 | Desktop |
| 10.110 | Desktop |
| 8.240 | Desktop |
| 8.220 | Desktop |
| 6.910 | Desktop |
| 5.940 | Desktop |
| 24.710 | Desktop |
| 14.720 | Desktop |
| 7.710 | Desktop |
| 10.540 | Desktop |
| 7.580 | Desktop |
| 4.190 | Desktop |
| 43.890 | Desktop |
| 4.870 | Desktop |
| 2.800 | Desktop |
| 10.790 | Desktop |
| 10.040 | Desktop |
| 11.800 | Desktop |
| 11.330 | Desktop |
| 6.920 | Desktop |
| 17.200 | Desktop |
| 7.880 | Desktop |
| 9.670 | Desktop |
| 13.760 | Desktop |
| 27.550 | Desktop |
| 13.530 | Desktop |
| 2.590 | Desktop |
| 9.040 | Desktop |
| 19.980 | Desktop |
| 8.660 | Desktop |
| 11.670 | Desktop |
| 44.110 | Desktop |
| 16.120 | Desktop |
| 19.040 | Desktop |
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.
Reading two curves
PredictPredict 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?
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.
View data
| minutes | courier |
|---|---|
| 24.800 | Northside |
| 14.100 | Northside |
| 22.400 | Northside |
| 26.600 | Northside |
| 17.700 | Northside |
| 26.600 | Northside |
| 25.400 | Northside |
| 15.500 | Northside |
| 13.400 | Northside |
| 21 | Northside |
| 26.200 | Northside |
| 28 | Northside |
| 15.700 | Northside |
| 18 | Northside |
| 27.800 | Northside |
| 21.600 | Northside |
| 20.600 | Northside |
| 21.600 | Northside |
| 23.100 | Northside |
| 24.700 | Northside |
| 26.200 | Northside |
| 20.900 | Northside |
| 24.800 | Northside |
| 17.300 | Northside |
| 20.100 | Northside |
| 18.800 | Northside |
| 16.500 | Northside |
| 20.100 | Northside |
| 18.600 | Northside |
| 18.600 | Northside |
| 17.300 | Northside |
| 16.200 | Northside |
| 26.600 | Northside |
| 22.800 | Northside |
| 18.100 | Northside |
| 20.400 | Northside |
| 18 | Northside |
| 13.700 | Northside |
| 30.800 | Northside |
| 14.800 | Northside |
| 10.600 | Express |
| 22 | Express |
| 21.200 | Express |
| 23.100 | Express |
| 22.600 | Express |
| 17.300 | Express |
| 28.400 | Express |
| 18.600 | Express |
| 20.800 | Express |
| 25.200 | Express |
| 36.700 | Express |
| 24.900 | Express |
| 10.100 | Express |
| 20 | Express |
| 30.800 | Express |
| 19.500 | Express |
| 23 | Express |
| 47.500 | Express |
| 27.400 | Express |
| 30 | Express |
First 60 of 80 rows.
Quantile definitions differ
ReadWith 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.
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 7x <- c(1, 2, 3, 4, 10)
quantile(x, c(0.25, 0.5, 0.75), type = 7)In the app
In the appDescriptive 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, 1973Check your understanding
CheckpointCheck 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.
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