What Is a Cumulative Distribution Function?

A cumulative distribution function (CDF) describes the probability that a random variable takes a value less than or equal to a specific point. It provides a complete representation of the probability distribution of a random variable, whether that variable is discrete or continuous. In data analysis, the CDF is a fundamental tool for understanding the underlying distribution of data, identifying patterns, and making probabilistic statements.

The CDF is commonly denoted as F(x) and is defined mathematically as:

F(x) = P(Xx)

This function maps every real number x to a probability value between 0 and 1. For very small x (approaching negative infinity), the CDF tends to 0 because there is no probability below that value. As x increases toward positive infinity, the CDF approaches 1, capturing the full range of possible outcomes.

Properties of Cumulative Distribution Functions

Every valid CDF exhibits several key properties that make it useful for analysis:

  • Monotonicity: The CDF is non-decreasing; if x1 < x2, then F(x1) ≤ F(x2). This reflects the fact that adding more possible outcomes cannot decrease the cumulative probability.
  • Limit behavior: limx→-∞ F(x) = 0 and limx→+∞ F(x) = 1.
  • Right-continuity: For continuous random variables, the CDF is continuous everywhere. For discrete random variables, the CDF is a step function that jumps at each possible value, and it is continuous from the right at those jumps.

These properties ensure that the CDF uniquely characterizes the probability distribution of the random variable.

Continuous vs Discrete CDFs

For a continuous random variable, the CDF is a smooth curve, and the probability density function (PDF) is the derivative of the CDF: f(x) = dF(x)/dx. For a discrete random variable, the CDF is a step function, and the probability mass function (PMF) gives the height of each step. Understanding the distinction is important when working with real datasets, which are often discrete in nature (e.g., counts, ratings) but may be approximated by continuous distributions.

Relationship Between CDF and PDF/PMF

The CDF and the probability density (or mass) function are closely linked. While the PDF/PMF shows the probability of specific values or small intervals, the CDF accumulates those probabilities up to a given point. This dual perspective offers different insights into the same distribution.

  • From PDF to CDF: For a continuous random variable, F(x) = ∫-∞x f(t) dt. The CDF is the area under the PDF curve to the left of x.
  • From CDF to PDF: The derivative of the CDF recovers the PDF (if it exists). In practice, you can estimate the PDF from the slope of the empirical CDF using kernel density estimation or histograms.
  • For discrete distributions: The CDF at a point is the sum of the PMF values for all outcomes ≤ x. The PMF can be recovered by taking differences of the CDF at adjacent points.

Using both the CDF and PDF together gives a complete picture. For instance, the CDF provides direct quantile information, while the PDF highlights modes and spread.

How to Compute a Cumulative Distribution Function from Data

In data analysis, you rarely know the true underlying distribution, so you work with the empirical CDF (ECDF). The ECDF is constructed directly from observed data points and converges to the true CDF as sample size increases (by the Glivenko-Cantelli theorem).

Constructing an Empirical CDF

Given a dataset of n observations x1, x2, …, xn, the ECDF at a value t is defined as:

n(t) = (1/n) × (number of observations ≤ t)

Steps to compute:

  1. Sort the data values in ascending order.
  2. For each sorted value, assign a cumulative proportion: i/n for the i-th smallest value (or use adjustments like (i-0.5)/n for better quantile estimation).
  3. Plot the points (x(i), i/n) and connect them with a step function (the ECDF is right-continuous).

Most programming packages, such as Python’s Matplotlib and NumPy, provide built-in functions for ECDF computation and plotting. Software like R, Excel, and many statistical tools also support ECDF functions. The ECDF is non-parametric; it makes no assumptions about the data distribution, making it a robust exploratory tool.

Interpreting CDF Plots

A well-drawn CDF plot reveals several aspects of the data distribution at a glance:

  • Central tendency: The median is the value where the CDF equals 0.5. The interquartile range (IQR) is the span between the 25th and 75th percentiles (CDF = 0.25 and 0.75).
  • Spread and shape: A steep segment in the CDF indicates that many data points are concentrated in that region (high density). A gentle slope means data are spread out. Asymmetry appears as a longer flatter region on one side, indicating skewness.
  • Outliers: Values far from the main body of data cause the CDF to approach 0 or 1 very slowly. A sudden jump at the extreme ends may point to outliers.
  • Comparison with theoretical distributions: By overlaying the empirical CDF with a theoretical CDF (e.g., normal, exponential), you can visually assess goodness-of-fit.

For example, if you are analyzing customer wait times, the CDF can show the proportion of customers served within a given time, such as the percentage served within 10 minutes.

Practical Applications in Data Analysis

Cumulative distribution functions are versatile and used across many data analysis tasks. Below are some common applications with concrete examples.

Percentiles and Quantiles

The inverse of the CDF, known as the quantile function (also called the percent-point function), maps probability values back to data values. This allows you to compute any desired percentile. For instance, the 90th percentile is the value below which 90% of the data fall. In practice, you use the ECDF or its inverse to find percentiles. This is essential for setting thresholds, such as determining the minimum score needed to be in the top 10% of applicants.

Comparing Two Datasets

Two empirical CDFs can be plotted on the same axes to compare distributions. If one CDF lies consistently to the right of another, that dataset tends to have larger values. The Kolmogorov-Smirnov (K-S) test uses the maximum vertical distance between two ECDFs to test whether they come from the same distribution. This non-parametric test is widely used in quality control, A/B testing, and anomaly detection. For example, you can compare the distribution of click-through rates between two web page designs to see if they differ significantly.

Survival Analysis and the Complementary CDF

In fields like reliability engineering and biostatistics, the complementary CDF (CCDF), also called the survival function, is used. The CCDF is defined as S(x) = 1 – F(x) = P(X > x). It gives the probability that a system or individual survives beyond a given time. The CCDF is often plotted on a logarithmic scale to examine tail behavior, such as heavy-tailed distributions in network traffic or financial losses.

Probability Integral Transform (PIT)

The PIT states that if X has a continuous CDF F, then the transformed variable U = F(X) is uniformly distributed on (0,1). This property is used in model diagnostics: if you apply the predicted CDF to your data, the resulting uniform distribution suggests a good model fit. PIT also underpins many resampling and simulation techniques, such as inverse transform sampling, where you generate uniform random numbers and then apply the inverse CDF to produce samples from any desired distribution.

Example: Analyzing Test Scores with CDFs

Consider a dataset of final exam scores for a class of 200 students. You want to understand the distribution, identify the median, and determine what score a student needs to be in the top 5%.

  1. Sort the scores: Order all 200 scores from lowest to highest.
  2. Compute the ECDF: Assign each sorted score a cumulative probability. For example, the 50th lowest score (the median) has cumulative probability 50/200 = 0.25? Wait – careful: the median corresponds to cumulative probability 0.5, so find the score where the ECDF reaches 0.5. That might be around the 100th sorted score. Correction: Use i/n; for i=100, i/n=0.5, so the 100th sorted value is the median.
  3. Find percentiles: To get the 95th percentile (top 5%), locate the score where the ECDF reaches 0.95. That corresponds to the sorted position 0.95 × 200 = 190. The 190th sorted score is the cutoff.
  4. Plot the CDF: Graph the ECDF to see the shape. A steep region in the middle indicates most students scored in a narrow range. If the curve rises rapidly near the top, it suggests that the top scores are tightly clustered.

Using the CDF, you can also answer questions like: “What percentage of students scored below 70?” by reading the ECDF value at score 70. This direct interpretability makes CDFs a powerful communication tool in reports and presentations.

Using CDFs in Your Workflow

Incorporating cumulative distribution functions into your data analysis routine adds a layer of probabilistic reasoning that goes beyond simple summary statistics. Start by plotting the ECDF for any new dataset before modeling. It reveals distribution shape, outliers, and potential data issues that histograms might obscure (such as gaps or multiple modes). When building machine learning models, CDFs can help calibrate predicted probabilities: plot the CDF of predicted probabilities against the empirical distribution of actual outcomes to check alignment.

For advanced applications, CDFs are central to methods like quantile regression, which models conditional quantiles instead of means, and to non-parametric hypothesis tests like the K-S test and the Anderson-Darling test. Understanding CDFs also opens the door to copula models, which use CDFs to describe dependence structures between multiple variables.

To deepen your knowledge, explore resources such as Wikipedia’s entry on CDFs, the NIST Engineering Statistics Handbook, or introductory texts like Statistical Inference by Casella and Berger. Many statistical computing libraries also include detailed tutorials on ECDFs; for Python users, the SciPy documentation for ECDF is a practical starting point.

By mastering CDFs, you gain a flexible tool that supports both exploratory analysis and rigorous inference, helping you turn raw data into actionable insights.