Random variables and distribution functions
A random variable puts a number on each outcome of an uncertain event. A discrete one has a probability mass function (PMF); a continuous one has a probability density function (PDF), where probability is area. The cumulative distribution function (CDF) gives P(X ≤ x) for both.
Watch the lesson 14 min
This lesson's video is for Plus members. The written lesson below is free, as always.
Before this: Statistical Characteristics of Asset Returns
On the exam
- Calculate, interpret, and evaluate unconditional expected values for mean, variance, and covariance
Interpret the three distribution functions and calculate a probability from them. Expect a range probability read off a mass function or cumulative table (watch whether the end points count), the meaning of a cumulative value, discrete against continuous variables, and the law of large numbers against the central limit theorem.
How deeply to learn each part
- Know the idea
- Understand it in general. It frames other topics, but you will not calculate with it.
- Use it
- Understand it well enough to solve a question with it. Recognize when it applies.
- Memorize
- Learn it by heart. The exam will not give it to you.
You know this one. The full lesson is folded away. The takeaways, formulas and checkpoint below are your quick refresher, and the checkpoint is a fair test of whether you still do.
You tested strong here. The full lesson is folded away. The takeaways, formulas and checkpoint below are your quick refresher, and the checkpoint is a fair test of whether you still know it.
What is a random variable?
A random variable is a rule that gives every outcome of an uncertain event a number. In finance it is often called a stochastic variable . The number lets you do arithmetic on an uncertain future: add it up, average it, ask how likely a range of values is.
There are two kinds, and the kind decides which tool describes the probabilities.
- A discrete random variable has a countable set of distinct outcomes: the number of defaults in a loan book, or the number of quarters in which a fund beats its benchmark.
- A continuous random variable can take any value in a range: tomorrow’s index return, or the share of a loan recovered after a default.
Real data blur the line. A daily return rounded to a basis point can only take certain values, yet with many observations it is modeled as continuous. Continuous models are easier to work with, fit data well and give clean formulas.
- Discrete Memorize countable outcomes, such as a count of defaults
- Probability mass function (PMF) P(X = x) for each outcome
- Cumulative distribution function (CDF) a staircase that jumps at each outcome
-
- Continuous Memorize any value in a range, such as a return
- Probability density function (PDF) probability is the area under it
- Cumulative distribution function (CDF) a smooth curve
-
How does the probability mass function work?
For a discrete variable, the probability mass function (PMF) lists P(X = x) for every outcome. The probabilities add to 1, and the probability of a range is the sum over the outcomes in it.
Take X to be the number of the next four quarters in which a fund beats its benchmark. The second row below is the PMF. The third row is a running total, which the next section explains.
| x | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| P(X = x) | 0.09 | 0.16 | 0.44 | 0.24 | 0.07 |
| F(x) = P(X ≤ x) | 0.09 | 0.25 | 0.69 | 0.93 | 1.00 |
How does the cumulative distribution function work?
The cumulative distribution function (CDF) gives F(x) = P(X ≤ x). It never falls, starts at 0 far to the left and reaches 1 far to the right. It works for discrete and continuous variables alike.
In words, F(2) = 0.69 in the fund table means a 69% chance that the fund beats its benchmark in two quarters or fewer.
For a discrete variable the CDF is a staircase: it jumps at each outcome by that outcome’s probability and is flat in between. That has a consequence for ranges. When both end points count, subtract F(a − 1), the step just below a, and not F(a).
Exam tip With a discrete table, say the range in words first: “from one up to and including three”. If the lower end is included, go one step below it.
How does the probability density function work?
For a continuous variable, probability is the area under the probability density function (PDF) between two points. That area equals F(b) − F(a). The PDF is the slope of the CDF, and its height is a density, not a probability.
Here is a toy model of a recovery rate X between 0 and 1. Its CDF is F(x) = x², so its density is f(x) = 2x. You never need to do the calculus: you subtract two CDF values.
Try this 1 of 3
- On the Discrete tab, find a range with probability exactly 0.84Both end points count for a discrete variable, so subtract F(a − 1), not F(a): F(3) − F(0) = 0.84, while F(3) − F(1) = 0.68 is the trap.
- On the Continuous tab, set a equal to b
- On the Law of large numbers tab, draw at least 100 times until the running mean is within 0.05 of the true mean
P(1 ≤ X ≤ 3) = 0.84: add the bars from 1 to 3, or F(3) − F(0).
PMF: P(X = x)
Drag the a marker, tap the chart, or focus the handle and use the arrow keys.
- Bars 1 to 3: 0.84
CDF: F(x) = P(X ≤ x)
Drag the b marker, tap the chart, or focus the handle and use the arrow keys.
- F(3) − F(0)
Show working
Add the bars: P(1 ≤ X ≤ 3) = 0.16 + 0.44 + 0.24 = 0.84.
Or use the CDF: F(3) − F(0) = 0.93 − 0.09 = 0.84. Both end points count, so subtract the CDF just below a.
The probabilities add to 1: 0.09 + 0.16 + 0.44 + 0.24 + 0.07 = 1.00. E[X] = 2.04 quarters.
- 0.93−0.09=0.84
- 0.93ENTER0.09−0.84
ENTER enter (on the HP, puts the number on the stack)
Display: 0.84
Start on the Discrete tab and drag the two range handles to see the bars that count and the jump they make in the cumulative staircase. Switch on the trap to see the wrong figure beside the right one. The Continuous tab shades the area, and the third tab shows the law of large numbers, which comes next.
Go deeper Why a density can be above 1
The total area under a PDF is 1, but the height can be larger than 1 where the variable is bunched up. In the recovery-rate model the density is f(0.9) = 1.8, yet no probability is above 1: probabilities are areas, and a narrow strip at height 1.8 has a small area. Never read a density height as “the chance of that value”.
Go deeper Why finance leans on continuous models
Prices move in ticks, so every price is technically discrete. Analysts still model returns as continuous because the formulas are cleaner, a smooth curve fits many observations well, and tools such as the normal distribution come with ready-made results. The next lessons use both kinds: counts (defaults, up moves) are discrete, returns and rates are continuous.
What does the law of large numbers say?
The law of large numbers says that as the number of independent trials grows, the sample mean gets closer and closer to the true (unconditional) mean, provided the sample is random and representative. It is why a long history or a long simulation estimates an expected value well.
Do not confuse it with the central limit theorem. The law of large numbers says where the sample mean ends up: at the true mean. The central limit theorem, covered in Learning Module 7, says what shape the sample mean has: approximately normal. Exam options often pair them as distractors.
Memorize this
MemorizeWhich function, which variable
| Function | Gives | Discrete | Continuous |
|---|---|---|---|
| Mass (PMF) | yes | no (every point has 0) | |
| Density (PDF) | density: area = probability | no | yes |
| Cumulative (CDF) | staircase | smooth curve |
Memory hook Mass sits on points, density spreads over a range, cumulative keeps a running total.
Know it cold Continuous: . Discrete with both ends included: .
MemorizeLaw of large numbers against the central limit theorem
Know it cold More trials: the sample mean converges to the true mean (law of large numbers). The shape of the sample mean: approximately normal (central limit theorem).
- Discrete Memorize countable outcomes, such as a count of defaults
- Probability mass function (PMF) P(X = x) for each outcome
- Cumulative distribution function (CDF) a staircase that jumps at each outcome
-
- Continuous Memorize any value in a range, such as a return
- Probability density function (PDF) probability is the area under it
- Cumulative distribution function (CDF) a smooth curve
-
Quick example
A cumulative table reads 0.09, 0.25 and 0.69 at x = 0, 1 and 2. P(X ≤ 1) = F(1) = 0.25.
Quick example
F(x) = x² on the range 0 to 1. P(0.2 ≤ X ≤ 0.5) = 0.25 − 0.04 = 0.21.
- 0.5x²−0.2x²= 0.21
x² square
- 0.5ENTER×0.2ENTER×− 0.21
ENTER enter (on the HP, puts the number on the stack)
Quick example
Mass of 0.12, 0.38 and 0.28 at x = 1, 2 and 3. P(1 ≤ X ≤ 3) = 0.78.
- 0.12+0.38+0.28= 0.78
- 0.12ENTER0.38+0.28+ 0.78
ENTER enter (on the HP, puts the number on the stack)
Quick example
Four outcomes have probabilities 0.22, 0.41, 0.19 and p. p = 1 − 0.82 = 0.18.
- 1−0.22−0.41−0.19= 0.18
- 1ENTER0.22−0.41−0.19− 0.18
ENTER enter (on the HP, puts the number on the stack)
Quick example
F(x) = x² gives f(x) = 2x, so the density at x = 0.5 is 1.0.
How it is asked
-
Range from a discrete cumulative table
F(0) = 0.25, F(1) = 0.55, F(2) = 0.80, F(3) = 1.00. P(1 ≤ X ≤ 2)?
F(2) − F(0) = 0.55. Trap: F(2) − F(1) = 0.25.
-
Meaning of a cumulative value
F(4%) = 0.70 for a monthly return. Meaning?
A 70% chance the return is 4% or less. Not "equal to 4%".
-
Single value of a continuous variable
P(return = exactly 1.00%)?
0. Only ranges have probability.
-
Law of large numbers against the central limit theorem
More trials make the sample mean...?
Converge to the true mean. "Become normally distributed" is the central limit theorem (trap).
Exam traps
- Subtracting F(a) instead of F(a − 1) for a discrete range that includes a.
- Reading the height of a density as a probability.
- Treating P(X = x) as positive for a continuous variable.
- Describing the central limit theorem when asked for the law of large numbers.
Checkpoint
3 exam-style questions. About 90 seconds each.
1The number of rating downgrades in a bond portfolio next year has this cumulative distribution: F(0) = 0.35, F(1) = 0.65, F(2) = 0.85, F(3) = 0.95, F(4) = 1.00. The probability of between one and three downgrades, inclusive, is closest to:
2For a continuous random variable, the probability that it takes one exact value is:
3A model's expected annual fund return is 6.0%. Fifty simulated years average 7.9%. Running 50,000 simulated years instead will most likely:
Key takeaways
- A random variable puts a number on each outcome; discrete ones have a mass function, continuous ones a density.
- The cumulative distribution function (CDF), F(x) = P(X ≤ x), works for both and climbs from 0 to 1.
- Continuous: probability = area = F(b) − F(a), and any single point has probability 0.
- Law of large numbers: more trials bring the sample mean closer to the true mean.
Quick example
A cumulative table reads 0.09, 0.25 and 0.69 at x = 0, 1 and 2. P(X ≤ 1) = F(1) = 0.25.
Quick example
F(x) = x² on the range 0 to 1. P(0.2 ≤ X ≤ 0.5) = 0.25 − 0.04 = 0.21.
- 0.5x²−0.2x²= 0.21
x² square
- 0.5ENTER×0.2ENTER×− 0.21
ENTER enter (on the HP, puts the number on the stack)
Quick example
Mass of 0.12, 0.38 and 0.28 at x = 1, 2 and 3. P(1 ≤ X ≤ 3) = 0.78.
- 0.12+0.38+0.28= 0.78
- 0.12ENTER0.38+0.28+ 0.78
ENTER enter (on the HP, puts the number on the stack)
Quick example
Four outcomes have probabilities 0.22, 0.41, 0.19 and p. p = 1 − 0.82 = 0.18.
- 1−0.22−0.41−0.19= 0.18
- 1ENTER0.22−0.41−0.19− 0.18
ENTER enter (on the HP, puts the number on the stack)
Quick example
F(x) = x² gives f(x) = 2x, so the density at x = 0.5 is 1.0.
Questions about this lesson?
Where this comes back
- Unconditional expected value, variance and standard deviation Statistical Distributions
- Monte Carlo simulation Simulating Prices and Returns
Questions candidates ask
What is the difference between a PMF and a PDF?
A probability mass function gives the probability of each exact outcome of a discrete variable. A probability density function describes a continuous variable: its height is a density, and probability is the area under it between two points.
How do you get a probability from a CDF?
For a continuous variable, P(a ≤ X ≤ b) = F(b) − F(a). For a discrete variable that includes a, subtract F(a − 1) instead, or add the mass values from a to b.
What does the law of large numbers say?
As the number of independent trials grows, the sample mean converges to the true mean. It does not say the data become normal; that is the central limit theorem, which describes the distribution of the sample mean.
Spotted an error? Tell us and we will fix it.