The cumulative distribution function (CDF), written F(x), gives the probability that a random variable X takes a value at or below x: F(x) = P(X ≤ x). It is one of the two standard ways of fully describing a probability distribution, the other being the probability density function (PDF) for continuous variables or the probability mass function (PMF) for discrete ones. Unlike a histogram, a CDF requires no binning choices, which makes it a useful, assumption-light way to summarize and compare distributions of research data.
Note on the acronym: CDF is also used for unrelated things — NASA’s Common Data Format for scientific datasets, the older XML-based Channel Definition Format, and the Collider Detector at Fermilab. This guide covers the statistical sense only: cumulative distribution function.
What the CDF Tells You
For any random variable X and any real number x, the CDF answers one question: “what fraction of the distribution lies at or below x?” Formally:
F(x) = P(X ≤ x)
This single function fully characterizes the distribution — every probability statement about X can be derived from it. For a discrete variable, F(x) is the running sum of probabilities up to x. For a continuous variable, F(x) is the running (integrated) area under the probability density curve up to x.
Properties of a CDF
Every valid CDF, regardless of the underlying distribution, has the same four properties:
- Non-decreasing. F(x) never goes down as x increases — adding more of the distribution to the “at or below” region can only add probability, never remove it.
- Right-continuous. Approaching any point x from the right, F is continuous at x (this matters for discrete variables, where F jumps upward exactly at each possible value of X and holds that new, higher value at x itself).
- Bounded between 0 and 1, with limiting values: F(x) → 0 as x → -∞, and F(x) → 1 as x → +∞. All the probability mass is accounted for somewhere on the real line.
- Defined for every real x, whether or not x is itself a value the variable can take.
Discrete vs. Continuous: Step Function vs. Smooth Curve
The CDF looks different depending on the type of variable, but the definition F(x) = P(X ≤ x) is identical in both cases:
- Discrete variables (e.g., number of grant applications submitted, count of adverse events) have a CDF that is a step function: flat between possible values, then jumping up by exactly P(X = that value) at each value the variable can actually take.
- Continuous variables (e.g., reaction time, a lab measurement) have a CDF that is a smooth, continuous curve, because the probability of landing on any single exact value is zero (see below) — probability only accumulates gradually as x increases.
CDF vs. PDF (or PMF): How They Relate
The CDF and the density/mass function are two views of the same distribution, connected by calculus (continuous case) or summation (discrete case):
- The PDF is the derivative of the CDF: f(x) = F′(x). The density at a point is the instantaneous rate at which cumulative probability is increasing there.
- The CDF is the integral of the PDF: F(x) = the area under f(t) for all t ≤ x. For a discrete variable, the CDF is the running sum of the PMF: F(x) = the sum of P(X = t) for all t ≤ x.
This is why, for a continuous variable, probability is fundamentally an area under a curve, not a height read off the curve. The PDF’s y-axis value at a single point is a density, not a probability, and densities can exceed 1 — only the area under a stretch of the curve is a probability. A direct consequence: for a continuous variable, P(X = x) = 0 for any single exact value x, because the area under a curve at a single point (zero width) is zero. This is also why, for continuous variables, P(X ≤ x) and P(X < x) are the same number — it only matters for discrete variables, where the CDF’s jump at x means the two differ by exactly P(X = x).
Reading Percentiles, Quantiles, and Interval Probabilities Off a CDF
Once you have a CDF, several practical quantities fall out directly:
- Percentiles and quantiles. The p-th quantile is the value x such that F(x) = p. This is the inverse CDF, sometimes called the quantile function, F&supminus;¹(p). The 90th percentile of a distribution is the x-value at which the CDF reaches 0.90.
- The median is simply the quantile where F(x) = 0.5 — the point at which half the distribution lies at or below and half lies above.
- Interval probabilities. The probability that X falls between two values a and b (with a < b) is F(b) − F(a) — read two points off the CDF and subtract.
The interquartile range and five-number summary are specific, well-known quantiles read this way — see CASRAI’s guide to the interquartile range and five-number summary for how the 25th, 50th, and 75th percentiles are calculated and used in practice.
Why Researchers Use the CDF: The Empirical CDF (ECDF)
Given a real dataset rather than a theoretical distribution, you can construct the empirical CDF (ECDF): for any x, the ECDF is simply the proportion of observed data points that are ≤ x. Plotted, it is a step function that rises by 1/n at each observed data point.
The ECDF’s real advantage over a histogram is that it requires no binning decisions. A histogram’s shape — how many modes it appears to show, how smooth or jagged it looks — depends on bin width and bin placement choices that are somewhat arbitrary and can visually mislead (see CASRAI’s histogram guide for how those choices are made). The ECDF uses every data point at its exact value, with no aggregation and no lost information, so two analysts building an ECDF from the same data always get the identical plot. This makes it a genuinely assumption-free way to display an entire distribution’s shape, spread, and any gaps or clusters in the data, and a useful complement to the descriptive statistics (mean, median, standard deviation, skewness) summarized in CASRAI’s descriptive statistics guide.
Where CDFs Show Up in Statistical Inference
- P-values as tail probabilities. A p-value is a tail-area probability computed from the CDF of a reference (null) distribution — the probability, under the null hypothesis, of observing a test statistic at least as extreme as the one calculated from the data. See CASRAI’s guide to what a p-value is for the full definition and common misinterpretations.
- The Kolmogorov-Smirnov (K-S) test directly compares an ECDF built from sample data against a theoretical CDF (the one-sample case) or two ECDFs against each other (the two-sample case), using the largest vertical distance between the two curves as its test statistic. It is a common way to formally check whether data plausibly came from a specified distribution, including checking the normality assumption discussed in CASRAI’s guide to normality of distribution.
- Q-Q (quantile-quantile) plots are a visual, quantile-by-quantile comparison built from the same inverse-CDF logic as percentiles: each point plots a sample quantile against the corresponding quantile of a reference distribution, and points falling along a straight diagonal line indicate the two distributions match.
A Brief Note on Survival Analysis
In survival analysis, the complement of the CDF is the survival function, S(x) = 1 − F(x): the probability that an event (death, failure, relapse, equipment breakdown) has not yet occurred by time x. The Kaplan-Meier estimator, the standard method for estimating survival from time-to-event data with censoring, is essentially an empirical estimate of this survival function — the complement of an ECDF built to handle observations where the event hasn’t yet been observed to occur. Researchers reporting time-to-event outcomes (time to relapse, time to grant renewal, equipment time-to-failure) are, in effect, working with a CDF-derived quantity even when the CDF itself is never plotted.
Computing a CDF in R and Python
Illustrative syntax only — consult each package’s documentation for full argument details:
- R: distribution-family functions prefixed
pgive the theoretical CDF, e.g.pnorm(x, mean, sd)for the normal distribution,pbinom()for binomial,ppois()for Poisson. The base functionecdf(data)returns the empirical CDF as a callable function, which can be plotted directly withplot(ecdf(data)). - Python:
scipy.statsdistribution objects expose a.cdf()method, e.g.scipy.stats.norm.cdf(x, loc, scale). For an empirical CDF from sample data,statsmodels.distributions.empirical_distribution.ECDFconstructs one directly, andscipy.stats.ecdf()(added in recent SciPy versions) does the same with confidence-band support.
Frequently Asked Questions
Is the CDF the same as a percentile?
Related but inverse of each other. The CDF takes a value x and returns a probability (proportion). A percentile does the reverse: it takes a probability (e.g., 0.90 for the 90th percentile) and returns the value x at which the CDF reaches that probability. The percentile function is the inverse CDF.
Why is P(X = x) always zero for a continuous variable?
Because probability for a continuous variable is the area under the density curve, and the area under any curve at a single exact point, with zero width, is zero. Probability only accumulates over an interval, however small.
What is the difference between a CDF and an ECDF?
A CDF describes a theoretical probability distribution (e.g., the normal distribution). An ECDF is built directly from observed sample data, with no distributional assumption — it is the proportion of the actual sample at or below each value, and it is the sample-based estimate that a K-S test or Q-Q plot uses to check whether the data resembles a given theoretical CDF.
Does a CDF replace a histogram?
Not exactly — they show different things. A histogram is often more visually intuitive for seeing where a distribution’s mass is concentrated (its modes), while a CDF is better for reading off exact percentiles, comparing two distributions precisely, and avoiding binning artifacts. Many analyses benefit from looking at both.







