Quant Memo
Core

The Empirical Distribution Function

The step-function version of a cumulative distribution built directly from your data — at any point x it just reports the fraction of your sample at or below x, and it converges to the true CDF as your sample grows.

Prerequisites: Random Variables & Distributions, Confidence Intervals

You have 500 historical daily returns for a stock and want to know: what fraction of days had a return below -1%? You don't need to assume the returns are normally distributed, fit a model, or estimate any parameters — you can just count. The empirical distribution function does exactly this, systematically, for every possible threshold at once, and it turns out that this simple counting exercise is itself a legitimate estimator of the true, unknown distribution the data came from.

An analogy: ranking your class by test score

Imagine lining up every student in a class by their test score and, for any score xx you name, reading off what fraction of the class scored at or below xx. With no model of "how test scores are distributed" required, this ranking directly answers the question for any xx you could ask about. As you add more students to the class, this fraction-below-xx becomes a more and more reliable estimate of the fraction you'd see in the entire population of students who could have taken the test, even though you never assumed a bell curve or any other shape to begin with.

The idea, one symbol at a time

Given a sample X1,,XnX_1, \ldots, X_n, the empirical distribution function is

F^n(x)=1ni=1n1{Xix},\hat{F}_n(x) = \frac{1}{n} \sum_{i=1}^{n} \mathbb{1}\{X_i \leq x\},

where 1{Xix}\mathbb{1}\{X_i \leq x\} is 1 if observation ii is at or below xx and 0 otherwise. In plain English: F^n(x)\hat{F}_n(x) is simply the fraction of your nn data points that fall at or below the value xx, and as xx sweeps from -\infty to ++\infty, F^n\hat{F}_n traces out a staircase that jumps up by 1/n1/n at each observed data point and is flat everywhere else. The Glivenko-Cantelli theorem guarantees that F^n(x)\hat{F}_n(x) converges to the true, unknown CDF F(x)F(x) uniformly — meaning the worst-case gap between the staircase and the true curve, over all xx simultaneously, shrinks to zero as nn grows — not just at each individual point separately, but everywhere at once.

Worked example 1: five daily returns by hand

Suppose five sorted daily returns (in %): 2.1,0.5,0.3,0.8,1.5-2.1, -0.5, 0.3, 0.8, 1.5. The ECDF is a staircase: for x<2.1x < -2.1, F^5(x)=0\hat{F}_5(x) = 0; for 2.1x<0.5-2.1 \leq x < -0.5, F^5(x)=1/5=0.2\hat{F}_5(x) = 1/5 = 0.2; for 0.5x<0.3-0.5 \leq x < 0.3, F^5(x)=2/5=0.4\hat{F}_5(x) = 2/5 = 0.4; for 0.3x<0.80.3 \leq x < 0.8, F^5(x)=3/5=0.6\hat{F}_5(x) = 3/5 = 0.6; for 0.8x<1.50.8 \leq x < 1.5, F^5(x)=4/5=0.8\hat{F}_5(x) = 4/5 = 0.8; and for x1.5x \geq 1.5, F^5(x)=1\hat{F}_5(x) = 1. So the answer to "what fraction of days had a return below -1%?" is read directly off the step at x=1x=-1: F^5(1)=0.2\hat{F}_5(-1) = 0.2, since only the 2.1%-2.1\% observation is below 1%-1\%.

Worked example 2: watching convergence

Now suppose the true, unknown distribution is standard normal, and you draw increasingly large samples. With n=10n=10, the ECDF's staircase might deviate from the true normal CDF by as much as 0.15 at some point (a coarse, jumpy staircase from few observations). With n=1,000n=1{,}000, that maximum deviation typically shrinks to around 1/10000.031/\sqrt{1000} \approx 0.03 — a much finer staircase hugging the smooth curve closely. This shrinking maximum gap, on the order of 1/n1/\sqrt{n}, is exactly what the Kolmogorov-Smirnov test (see The Kolmogorov-Smirnov Test) later formalizes into a hypothesis test.

Convergence explorer
true meansamples →
after n = 200estimate -0.025error 0.025std error 0.071

Drag the sample size in the explorer above and watch the running estimate settle onto the truth — the same logic applies to the ECDF: watch how the staircase's largest deviation from the true CDF shrinks as more data accumulates, exactly the Glivenko-Cantelli guarantee in action.

x true CDF F(x) ECDF F̂ₙ(x)
The empirical distribution function (solid staircase) jumps by 1/n at each data point and tracks the smooth true CDF (dashed) more closely as the sample grows.

What this means in practice

The ECDF is the foundation underneath most of nonparametric statistics: it's what a QQ plot compares against a theoretical distribution, what the Kolmogorov-Smirnov test measures deviations from, and what the bootstrap implicitly resamples from when it treats your data as a stand-in for the whole population. Whenever you plot "percent of days with a drawdown worse than X" or build a historical value-at-risk estimate by reading a percentile off your data, you are using the ECDF, whether or not you name it.

The empirical distribution function estimates the whole cumulative distribution just by counting: at any point x, it's the fraction of your sample at or below x. It requires no distributional assumption, and by the Glivenko-Cantelli theorem it converges uniformly to the true CDF as the sample grows.

The ECDF is a step function with visible jumps at every observed data point, and it is easy to mistake those individual jump sizes (1/n1/n each) for meaningful signal — especially in the tails, where a single extreme observation can create a jump that looks dramatic but reflects one data point, not a robust feature of the underlying distribution. Tail behavior of the ECDF is the least reliable part of it precisely where you have the fewest observations to estimate from.

Related concepts

Practice in interviews

Further reading

  • van der Vaart, Asymptotic Statistics, ch. 19
  • Casella & Berger, Statistical Inference, ch. 10
ShareTwitterLinkedIn