TL;DR
The cumulative distribution function, or CDF, answers one question for a random variable : how likely is it that is at most some value ? You write it . It starts at 0 on the far left, rises as moves right, and ends at 1 on the far right.
Unlike a density, the CDF exists for every random variable, whether its values are discrete, continuous, or a mix of both.
Where you'll see it: in computing percentiles and p-values, in sampling a random value by inverting a uniform draw, and in checking whether data matches a model with the Kolmogorov–Smirnov test.
Intuition
Running total of probability
Picture a pile of sand that represents all the probability of , spread along the number line. The CDF at is how much sand lies to the left of , including whatever sits exactly at . Moving to the right can only add sand, so the CDF never goes down. Once all the sand is counted, it stays at 1.
This is why the CDF is the natural object to study. A density can be awkward: a coin flip has no density at all, because all its probability sits on two points. But "how much sand is to the left of " always makes sense.
- rate 1
- rate 0.5
The math
Definition
For a random variable , the cumulative distribution function is
Here is any real number, and is the probability that takes a value no bigger than . The CDF is defined the same way for every random variable, so it is the one description that does not depend on whether is discrete or continuous.
Properties
Every CDF has these properties:
- Non-decreasing: if then , because the event is contained in .
- Limits: as , and as .
- Right-continuous: at a jump, takes the value after the jump. For example, includes all the probability sitting at 3.
Any function with these three properties is the CDF of some random variable.
Probabilities from the CDF
Almost every question about reduces to :
The last line is the size of a jump at . For a continuous variable has no jumps, so for every single value. Probability lives in intervals.
Discrete and continuous cases
For a discrete variable, is a staircase: flat between the possible values, and jumping by at each one. For a continuous variable with density , is the running integral of that density:
Where is continuous, the derivative by the fundamental theorem of calculus. So the CDF and the density carry the same information, and you can move between them with an integral or a derivative.
For the standard Gaussian, the CDF has no elementary closed form, but it can be written with the error function:
- Φ(x), standard Gaussian
Worked examples
Let be the result of one roll of a fair six-sided die. The values are 1 to 6, each with probability .
- Count the mass at or below . For it is ; for it is ; and so on.
- So for , for , and for .
- . Note that includes the mass at 3 itself, so but .
- .
- . The event "strictly above 4" leaves only the outcomes 5 and 6, which is two sixths.
A bulb's lifetime , in hours, has CDF for .
- The chance it fails by 100 hours is .
- The chance it survives past 200 hours is .
- The chance it fails between 50 and 150 hours is .
- The median is the value where : , so hours. Half the bulbs fail before about 69 hours.
Adult heights are roughly cm. What fraction are at most 190 cm?
- Standardise: .
- .
- About 97.7% of adults are 190 cm or shorter, so about 2.3% are taller.
Tradeoffs and failure modes
The CDF is the most general description of a distribution, so it is the right tool when you do not know or do not want to assume a density. It also turns percentiles into a direct read-off, and it stays meaningful for data that has ties or point masses.
Its drawbacks show up in practice:
| Situation | Problem | Better choice |
|---|---|---|
| You need a probability for one exact value of a continuous variable | is here, which is useless | Use the density and talk about small intervals |
| You want to see how a shape looks by eye | An S-curve hides detail in the tails | Plot the density, or a quantile-quantile plot |
| You have a sample, not a model | You do not know | Use the empirical CDF, which is the fraction of samples at or below |
| You need the value for a given probability | Inverting by hand is hard for most distributions | Use the quantile function , computed by a library |
A common mistake is to confuse with . For continuous variables they are equal. For discrete ones, they differ by the mass at . Forgetting this gives off-by-one errors with dice, counts, and integer scores.
History
Accumulating probability is an old idea: early work on errors of measurement already asked how likely a value was to fall below a threshold. The modern, general definition came with Andrey Kolmogorov's measure-theoretic foundation of probability in 1933, which gave the distribution function a precise role for every random variable. It caught on because it removed the need to treat discrete and continuous cases separately.
Later work made the CDF central to statistics. The empirical CDF, built from a sample, is the basis of the Kolmogorov–Smirnov test, which measures the largest gap between a sample's CDF and a model's CDF. Inverting the CDF gives a way to turn uniform random numbers into samples from any distribution, which is why it appears throughout simulation.
Check yourself
QuestionWhat are the limits of as goes to and to , and why?Show answer
The limits are 0 and 1. As goes to , the event shrinks to nothing, so its probability goes to 0. As goes to , the event grows to cover every outcome, so its probability goes to 1.
QuestionA fair die has CDF on . What is ?Show answer
. The subtle step is writing as , which is valid because takes only whole-number values. Counting the outcomes 4, 5, 6 gives , the same answer.
QuestionWhy does the CDF work for every random variable when the density does not?Show answer
A density only exists when probability is spread smoothly over values. A discrete variable puts its probability on separate points, so its density would have to be a point mass, which is not an ordinary function. The CDF counts probability to the left of , and that quantity is always defined, even when has jumps.
QuestionA web service's response time (in milliseconds) has . What does this say about the 95th percentile, and what fraction of requests take longer than 200 ms?Show answer
The 95th percentile is 200 ms, because 95% of responses take at most 200 ms. The fraction taking longer is , or 5%. This is the kind of statement a latency target is written as.