Definition
The empirical cumulative distribution function (ECDF) of a sample of values is the function that gives, for every threshold , the fraction of the values that are at most . Its graph is a staircase: 0 left of the smallest value, a rise of at each value ( where values are equal), flat between values, and 1 from the largest value on. It is the sample’s version of a cumulative distribution function, which gives the probability that one value drawn from a process is at most .
The idea
Four requests took 2, 2, 4 and 10 milliseconds. A deadline of 3 milliseconds was met by two of the four, a fraction of ; a deadline of 5 milliseconds was met by three, . Asking that question for every possible deadline and plotting the answers gives the ECDF. Empirical means computed from observed data, and cumulative means counting everything at or below the threshold.
The ECDF shows the distribution of the sample values. A histogram, which counts values in bins, changes when the bins change; the ECDF needs no bins and keeps every value. Every nearest-rank percentile §11.16 can be read off it, and the ECDFs of two systems on one plot can be compared at every level at once. The key to its shape: each observation lifts the curve by at its own value, and nothing else moves it.
How it works
To draw the ECDF:
Sort the values.
To the left of the smallest value, the height is 0.
At each distinct value, the height jumps up by the number of observations equal to that value, divided by .
Between two neighboring distinct values, the height stays constant.
From the largest value on, the height is 1.
Because the definition counts values equal to the threshold, the height at a jump point is the upper level, after the jump. A function with this property is called right-continuous.
To read the plot:
Up from a value. At a value on the horizontal axis, the height is the fraction of observations at or below , for example the fraction of requests that met a deadline .
Across from a height. At a height , move right until the curve first reaches . The value found is the nearest-rank quantile at level , the smallest observation with at least a fraction of the sample at or below it; at height 0.95 it is the p95, the 95th percentile.
Steepness. A steep region means many observations packed into a narrow range of values; a gently rising region means values spread thinly.
Two curves. If the curve of system A lies on or above the curve of system B everywhere, then at every level the quantile of A is at most the quantile of B: A’s measured values are smaller across the whole distribution, not only on average.
Worked example
For the four durations 2, 2, 4 and 10 milliseconds, and each observation has weight .
Below 2 milliseconds the height is 0.
At 2 milliseconds two equal observations enter together: a vertical step of , from 0 to 0.5.
From 2 up to, but not including, 4 milliseconds: a plateau at 0.5.
At 4 milliseconds: a step of , up to 0.75.
From 4 up to, but not including, 10 milliseconds: a plateau at 0.75.
At 10 milliseconds: a step of 0.25, up to 1.
The value exactly at 2 milliseconds is 0.5, not 0, because the two observations equal to 2 are counted.
Reading it: the deadline 3 milliseconds lies on the first plateau, so half the requests met it. The lower median §11.13, where the height first reaches 0.5, is 2 milliseconds. Averaging the middle pair gives 3 milliseconds under the usual even-sample median convention. The height first reaches 0.95 only at the final step, so the nearest-rank p95 is 10 milliseconds. The plateau from 4 to 10 milliseconds says that this sample contains no duration strictly between 4 and 10 milliseconds. It does not say that such durations cannot occur; with only four observations, gaps are expected.
Stated precisely
Let be the observed values. Write for the indicator, which is 1 when the condition is true and 0 otherwise. The ECDF is where the hat marks a quantity computed from data and adds the indicators. At in the example the indicators are 1, 1, 0 and 0, so . The function never decreases and is right-continuous, with below the smallest value and from the largest value on. The vertical step at a value equals the fraction of observations equal to . A plateau between two neighboring distinct values means that no observation lies strictly between them.
As an estimate: suppose the observations are independent and identically distributed §11.5 (IID) draws of a random value whose cumulative distribution function is . Then for each fixed , the count has a binomial distribution with trials and success probability , so has expected value and variance §11.14 . The Dvoretzky–Kiefer–Wolfowitz inequality [470], with the constant 2 that Massart proved in 1990 [471], bounds the error at all thresholds at once: where is the largest difference over all thresholds . Setting the right side to 0.05 gives a 95% confidence band of half-width . For that is .
Limits and common mistakes
The horizontal axis is the measured value, not time. The ECDF discards the order in which the values were measured, so a slow drift or a burst of slow requests in the middle of a run is invisible in it. Plot the values against time to see those.
An ECDF is not a confidence band. Its steps are the sample’s own, and a small sample gives large steps. A statement about the population needs an assumption such as independent draws, and a band such as the Dvoretzky–Kiefer–Wolfowitz band under “Stated precisely”.
Every row has equal weight . If one device contributed 900 of 1000 rows, the curve mostly describes that device. Decide whether the question is about requests or about devices, and weight accordingly, for example by drawing one curve per device.
Only recorded values are counted. If timed-out or failed requests were dropped, the curve describes completed requests only, and reaching height 1 does not mean every request completed; judging from the completed requests alone is a form of survivorship bias §11.30. A timed-out request is an example of censoring §11.28: its true duration is known only to exceed the timeout §9.34. To show observed completions by deadline, divide the number completed by each deadline by all attempts. With a common observation limit this gives the exact sample fraction through that limit. With different limits, earlier censoring makes it only a lower bound on the fraction that actually finished by a later deadline. The curve then levels off at the completed fraction, for example 0.97, and does not present the failures as fast.
Connecting the steps with sloping lines, as some plotting tools do, draws observations that do not exist.
Questions answered
What do a vertical step and a horizontal plateau mean?
In an empirical cumulative distribution function (ECDF), the staircase graph that shows, for each value , the fraction of observations at or below , a vertical step at a value means that the sample contains observations exactly equal to . The height of the step is the fraction of the sample at : for one observation among , and for equal observations. A horizontal plateau between two values means that no observation lies strictly between them; its height is the fraction of observations at or below the left end of the plateau.
For the durations 2, 2, 4 and 10 milliseconds there is a step of at 2 milliseconds, from the two equal observations, and a plateau at height from 4 up to 10 milliseconds, because no duration fell between 4 and 10. Both shapes describe this sample only. A plateau does not show that values in the gap are impossible, and a step does not show that the population puts exactly that probability on .
Related entries: Population and sample (§11.1), Quantile and percentile (§11.16), Confidence interval (§11.18), Censoring (§11.28), Survivorship bias (§11.30). Further reading: [470, 471].