1 Definition and intuition
An empirical cumulative distribution function (ECDF) is a nonparametric estimator of a cumulative distribution function based on a finite sample. Instead of assuming a specific parametric form (such as normal or exponential), it constructs an estimate directly from the observed data by tracking how the sample accumulates as the threshold value increases.
1.1 What an ECDF measures
For any real number \(x\), the ECDF reports the proportion of observations in the dataset whose values are less than or equal to \(x\). Interpreted probabilistically, it approximates \[ F(x)=\Pr(X\le x) \] by replacing the unknown probability with the observed relative frequency.
1.2 Step-function construction
Because it is based on observed sample points, the ECDF increases only when the threshold \(x\) passes a data value. Between distinct observed values, the cumulative proportion stays constant, producing a characteristic step-like curve.
1.3 Relationship to the CDF
The theoretical cumulative distribution function (CDF) is a nondecreasing function that is typically smooth only when the underlying distribution has sufficient regularity. The ECDF is a sample-based analogue of the CDF: as the sample size grows, the ECDF approaches the true CDF at most points, but it remains a step function for any finite dataset.
2 Mathematical formulation
2.1 Formal ECDF definition
Given observations \(X_1, X_2, \dots, X_n\), the (unweighted) ECDF is defined as \[ \widehat{F}_n(x)=\frac{1}{n}\sum_{i=1}^n \mathbf{1}\{X_i\le x\}, \] where \(\mathbf{1}\{\cdot\}\) is an indicator that equals 1 if the condition holds and 0 otherwise.
2.2 Handling ties and repeated observations
If multiple observations take the same value, the ECDF makes a larger jump at that value. In the definition above, each tied observation contributes an additional unit to the sum, so repeated measurements increase the cumulative proportion by the appropriate multiple of \(1/n\).
2.3 Discrete vs continuous interpretation
Although the ECDF is often used for continuous data, its definition does not require continuity. It can be interpreted consistently for both discrete and continuous settings; the difference is how the function behaves relative to the data-generating mechanism.
2.3.1 Jump sizes at observed data points
At each distinct observed value \(x_{(k)}\), the ECDF increases by the fraction of observations equal to that value. If a value \(x_{(k)}\) appears \(m\) times among the \(n\) observations, then the ECDF has a jump of size \(m/n\) at \(x_{(k)}\).
2.3.2 Behavior in the tails
For \(x\) smaller than the minimum observation, \(\widehat{F}_n(x)=0\). For \(x\) greater than or equal to the maximum observation, \(\widehat{F}_n(x)=1\). In the tails, the ECDF is therefore constrained by the sample extremes, which can make it appear sensitive when few data points lie in those regions.
3 Computation and implementation
3.1 Sorting and cumulative counts
A common computation method is to sort the observations: \[ x_{(1)}\le x_{(2)}\le \cdots \le x_{(n)}. \] Then the ECDF evaluated at sorted values can be written as \[ \widehat{F}_n(x_{(k)})=\frac{k}{n}, \] with the curve remaining constant between successive sorted values.
3.2 Vectorized calculation approaches
In practice, implementations often compute the ECDF by using vector operations. Typical strategies include:
- sorting once and constructing cumulative ranks,
- using boolean comparisons \((X_i \le x)\) for a grid of \(x\)-values,
- or generating the step coordinates directly from the sorted sample and cumulative fractions.
Vectorization improves speed and reduces implementation errors, especially when generating many ECDF plots or performing repeated calculations.
3.3 Software and plotting conventions
Different libraries may represent the ECDF with slightly different plotting conventions, such as where the step changes are drawn relative to the data points. The underlying definition remains the same, but the visual details can vary.
3.3.1 Plotting ECDF with different axes/scales
ECDFs are frequently displayed with a linear \(x\)-axis, but the \(x\)-axis may also be transformed (e.g., logarithmic) depending on the data scale. When plotting on a log scale, care is required for nonpositive values. The \(y\)-axis is typically kept linear in probability or proportion because it directly represents cumulative probability.
4 Properties of ECDFs
4.1 Monotonicity and right-continuity
By construction, the ECDF is nondecreasing: increasing the threshold cannot decrease the proportion of observations below it. It is also naturally right-continuous when expressed in the standard step-function form, with the value at a data point reflecting inclusion of observations equal to that threshold.
4.2 Convergence behavior
ECDFs are consistent estimators of the true CDF. As \(n\) increases, the random step function produced from the sample stabilizes and approaches the deterministic target distribution function.
4.2.1 Glivenko–Cantelli theorem (overview)
A central result in empirical process theory states that the supremum distance between the ECDF and the true CDF converges to zero almost surely as \(n\to\infty\): \[
| \sup_x \left | \widehat{F}_n(x)-F(x)\right | \to 0. |
|---|
\] This provides theoretical justification for using ECDFs to approximate distributional behavior across the entire real line.
4.3 Bias and variance considerations
Because the ECDF is based on relative frequencies, it can be viewed as having sampling variability rather than systematic bias in the usual sense. However, the magnitude of variability depends on both \(x\) and the underlying \(F(x)\).
4.3.1 Sampling variability across x-values
The ECDF at a particular \(x\) behaves like a binomial proportion: the event \(\{X_i \le x\}\) has probability \(F(x)\). As a result, variability is smaller where \(F(x)\) is near 0 or 1, and largest around intermediate cumulative probabilities. This can make central parts of the ECDF more “wiggly” than the extreme tails for moderate sample sizes.
5 Comparing distributions with ECDFs
5.1 Two-sample ECDF comparison
When two samples are available, each yields its own ECDF. By overlaying the curves, one can visually assess differences in location (shifts), spread (steepness), and distributional shape (pattern of relative cumulative accumulation).
5.2 Visual comparison techniques
Common approaches include:
- plotting both ECDFs on the same axes to compare at each threshold \(x\),
- focusing on regions where one curve consistently lies above the other,
- using difference plots (e.g., ECDF\(_1\) minus ECDF\(_2\)) to highlight where discrepancies concentrate.
Such comparisons are descriptive and should be complemented with formal inference when decisions are needed.
5.3 Quantile comparison via ECDF
Because the ECDF provides cumulative probabilities, it also enables quantile estimation without parametric assumptions. Quantiles can be read off by finding the smallest \(x\) for which the ECDF reaches a target probability level.
5.3.1 Median and percentile extraction
For a desired percentile \(p\) (such as \(p=0.5\) for the median), a typical empirical quantile definition uses the sample order statistics: \[ \widehat{Q}(p)=\inf\{x:\widehat{F}_n(x)\ge p\}. \] This yields a data-driven estimate of central tendencies and dispersion-related percentiles.
6 Statistical inference and uncertainty
6.1 Confidence bands for ECDFs
Uncertainty quantification for an ECDF is often expressed through confidence bands: ranges around \(\widehat{F}_n(x)\) that, with a chosen confidence level, contain the true CDF \(F(x)\) for all \(x\) in a specified domain. These bands account for multiple comparisons across thresholds.
6.2 Nonparametric confidence regions (conceptual)
Beyond pointwise intervals (at a single \(x\)), nonparametric methods construct regions intended to control the overall deviation between the ECDF and the true CDF.
6.2.1 Bootstrap vs asymptotic methods
Two broad strategies are used:
- Bootstrap-based procedures resample the data and recompute ECDFs, using the resulting distribution of deviations to form bands.
- Asymptotic approaches rely on limiting theory for empirical processes, producing bands from approximations that become more accurate as \(n\) grows.
Choice between them can depend on sample size, distributional complexity, and computational budget.
6.3 Coverage interpretation
Coverage refers to the probability that the confidence band includes the true CDF. For simultaneous (uniform) bands, coverage is interpreted across a range of \(x\)-values, not merely at a single point. Proper interpretation requires attention to the confidence level, the method used, and the domain over which the band is claimed.
7 Goodness-of-fit applications
7.1 Using ECDF to assess model fit
An ECDF can be used to evaluate whether a proposed distribution reasonably matches observed data. A typical workflow compares the sample ECDF to the CDF implied by a fitted or hypothesized model, looking for systematic differences such as persistent over- or under-estimation of cumulative probabilities.
7.2 Kolmogorov–Smirnov connection (overview)
The Kolmogorov–Smirnov (K–S) framework provides formal test statistics that measure the maximum vertical gap between an ECDF and a target CDF. In essence, it converts the visual discrepancy into a numerical summary suitable for hypothesis testing.
7.3 Practical decision criteria and limitations
In applied settings, goodness-of-fit conclusions depend on the test statistic, choice of significance level, and sample size. ECDF-based comparisons can be sensitive to tail behavior or to deviations concentrated in a narrow region. Moreover, if parameters are estimated from the same data, some classical versions of tests may require adjustment for correct calibration.
8 Special cases and variants
8.1 Weighted ECDFs
In some contexts, observations contribute unequally, such as when data come from survey sampling or when observations represent aggregated quantities. A weighted ECDF replaces the equal \(1/n\) contribution with normalized weights.
8.1.1 Normalizing weights and effective sample size
With nonnegative weights \(w_i\), a common form is \[ \widehat{F}_w(x)=\frac{\sum_{i=1}^n w_i \mathbf{1}\{X_i\le x\}}{\sum_{i=1}^n w_i}. \] When weights vary substantially, the variability of the estimator behaves as if the sample were smaller; this motivates the idea of an “effective sample size,” which summarizes how weight dispersion affects uncertainty.
8.2 ECDF for grouped/aggregated data
If data are presented as counts within bins rather than individual observations, an ECDF-like curve can still be constructed by cumulatively summing bin frequencies. The result is an approximation whose resolution depends on the chosen binning scheme; finer bins generally preserve more detail.
8.3 ECDF with censored or truncated observations (high-level)
When some observations are censored (partially observed) or truncated (partly missing because values fall outside a range), the usual ECDF can be biased because it treats missingness as if it were absent. In such cases, methods based on specialized estimators are often used to adapt cumulative estimation to the observation mechanism; the ECDF can serve as a conceptual baseline for cumulative probability under complete observation.
9 Practical guidance
9.1 Choosing resolution for plotting
For plotting, ECDFs can be shown as steps at each observation, or evaluated on a grid for smoother visuals. Using the exact step points preserves the definition precisely, while grid-based evaluation can be useful for comparing curves when multiple datasets or transformations are involved.
9.2 Common pitfalls and misinterpretations
Potential issues include:
- interpreting small vertical differences as meaningful without considering sampling variability,
- assuming smoothness or continuity where the ECDF is inherently discrete,
- neglecting the effect of ties, which can create larger jumps,
- comparing ECDFs across different transformations without accounting for the transformation’s impact on the x-scale.
9.3 Recommendations for reporting ECDF results
Reports typically include:
- the sample size(s) and how the ECDF was computed (weighted or unweighted),
- the plotting scale (e.g., linear or logarithmic),
- any confidence bands or uncertainty statements, including the confidence level,
- and a clear description of the comparison goal (location shift, spread, quantiles, or goodness-of-fit).