Analyst Dojo
Lesson 1 of 8 11–14% of the exam

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.

6 min cram, 26 min full read. Based on the 2027 CFA® Program Level I curriculum, Quantitative Methods, Learning Module 6.

Tailor this to you: take the self-assessment

Watch the lesson 14 min

This lesson's video is for Plus members. The written lesson below is free, as always.

See Plus

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.

Cram mode: the one-screen version of this lesson. Switch to Full for the explanations, worked examples and interactives.

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.

Two kinds of random variable and their functions
Random variablea number for each outcome of an uncertain event
  • 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.

Probabilities add to 1 Memorize
∑xP(X=x)=1,∫−∞∞f(x) dx=1\sum_x P(X = x) = 1, \qquad \int_{-\infty}^{\infty} f(x)\,dx = 1
Probability of a range, discrete variable Use it
P(a≤X≤b)=∑x=abP(X=x)P(a \le X \le b) = \sum_{x=a}^{b} P(X = x)

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.

x01234
P(X = x)0.090.160.440.240.07
F(x) = P(X ≤ x)0.090.250.690.931.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.

Cumulative distribution function Memorize
F(x)=P(X≤x)F(x) = P(X \le x)

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.

Probability of a range, continuous variable Memorize
P(a≤X≤b)=∫abf(x) dx=F(b)−F(a)P(a \le X \le b) = \int_a^b f(x)\,dx = F(b) - F(a)
Density as the slope of the CDF Know the idea
f(x)=dF(x)dxf(x) = \dfrac{dF(x)}{dx}

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.

InteractiveDiscrete: add the bars, or 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)

00.10.20.30.401234Quarters beating the benchmark, x0.090.160.440.240.07a = 1

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)

00.250.50.75101234x0.84b = 3

Drag the b marker, tap the chart, or focus the handle and use the arrow keys.

  • F(3) − F(0)
P(1 ≤ X ≤ 3)0.84
F(3)0.93
F(0)0.09
Distribution
PMF
Range, both ends included
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.

Probability from the CDF on your calculator
  1. 0.93−0.09=0.84
  1. 0.93ENTER0.09−0.84

ENTER enter (on the HP, puts the number on the stack)

Display: 0.84

Discrete: add the bars. Continuous: measure the area. Either way, the CDF does the adding for you.

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

FunctionGivesDiscreteContinuous
Mass (PMF)P(X=x)P(X = x)yesno (every point has 0)
Density (PDF)density: area = probabilitynoyes
Cumulative (CDF)P(X≤x)P(X \le x)staircasesmooth curve

Memory hook Mass sits on points, density spreads over a range, cumulative keeps a running total.

Know it cold Continuous: P(a≤X≤b)=F(b)−F(a)P(a \le X \le b) = F(b) - F(a). Discrete with both ends included: F(b)−F(a−1)F(b) - F(a - 1).

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).

Two kinds of random variable and their functions
Random variablea number for each outcome of an uncertain event
  • 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
Cumulative distribution function Memorize
F(x)=P(X≤x)F(x) = P(X \le x)
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.

Probability of a range, continuous variable Memorize
P(a≤X≤b)=∫abf(x) dx=F(b)−F(a)P(a \le X \le b) = \int_a^b f(x)\,dx = F(b) - F(a)
Quick example

F(x) = x² on the range 0 to 1. P(0.2 ≤ X ≤ 0.5) = 0.25 − 0.04 = 0.21.

On your calculator
  1. 0.5x²−0.2x²= 0.21

x² square

  1. 0.5ENTER×0.2ENTER×− 0.21

ENTER enter (on the HP, puts the number on the stack)

Probability of a range, discrete variable Use it
P(a≤X≤b)=∑x=abP(X=x)P(a \le X \le b) = \sum_{x=a}^{b} P(X = x)
Quick example

Mass of 0.12, 0.38 and 0.28 at x = 1, 2 and 3. P(1 ≤ X ≤ 3) = 0.78.

On your calculator
  1. 0.12+0.38+0.28= 0.78
  1. 0.12ENTER0.38+0.28+ 0.78

ENTER enter (on the HP, puts the number on the stack)

Probabilities add to 1 Memorize
∑xP(X=x)=1,∫−∞∞f(x) dx=1\sum_x P(X = x) = 1, \qquad \int_{-\infty}^{\infty} f(x)\,dx = 1
Quick example

Four outcomes have probabilities 0.22, 0.41, 0.19 and p. p = 1 − 0.82 = 0.18.

On your calculator
  1. 1−0.22−0.41−0.19= 0.18
  1. 1ENTER0.22−0.41−0.19− 0.18

ENTER enter (on the HP, puts the number on the stack)

Density as the slope of the CDF Know the idea
f(x)=dF(x)dxf(x) = \dfrac{dF(x)}{dx}
Quick example

F(x) = x² gives f(x) = 2x, so the density at x = 0.5 is 1.0.

How it is asked

  1. 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.

  2. 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%".

  3. Single value of a continuous variable

    P(return = exactly 1.00%)?

    0. Only ranges have probability.

  4. 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.

  1. 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:

  2. 2For a continuous random variable, the probability that it takes one exact value is:

  3. 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.
Cumulative distribution function Memorize
F(x)=P(X≤x)F(x) = P(X \le x)
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.

Probability of a range, continuous variable Memorize
P(a≤X≤b)=∫abf(x) dx=F(b)−F(a)P(a \le X \le b) = \int_a^b f(x)\,dx = F(b) - F(a)
Quick example

F(x) = x² on the range 0 to 1. P(0.2 ≤ X ≤ 0.5) = 0.25 − 0.04 = 0.21.

On your calculator
  1. 0.5x²−0.2x²= 0.21

x² square

  1. 0.5ENTER×0.2ENTER×− 0.21

ENTER enter (on the HP, puts the number on the stack)

Probability of a range, discrete variable Use it
P(a≤X≤b)=∑x=abP(X=x)P(a \le X \le b) = \sum_{x=a}^{b} P(X = x)
Quick example

Mass of 0.12, 0.38 and 0.28 at x = 1, 2 and 3. P(1 ≤ X ≤ 3) = 0.78.

On your calculator
  1. 0.12+0.38+0.28= 0.78
  1. 0.12ENTER0.38+0.28+ 0.78

ENTER enter (on the HP, puts the number on the stack)

Probabilities add to 1 Memorize
∑xP(X=x)=1,∫−∞∞f(x) dx=1\sum_x P(X = x) = 1, \qquad \int_{-\infty}^{\infty} f(x)\,dx = 1
Quick example

Four outcomes have probabilities 0.22, 0.41, 0.19 and p. p = 1 − 0.82 = 0.18.

On your calculator
  1. 1−0.22−0.41−0.19= 0.18
  1. 1ENTER0.22−0.41−0.19− 0.18

ENTER enter (on the HP, puts the number on the stack)

Density as the slope of the CDF Know the idea
f(x)=dF(x)dxf(x) = \dfrac{dF(x)}{dx}
Quick example

F(x) = x² gives f(x) = 2x, so the density at x = 0.5 is 1.0.

All Quantitative Methods formulas, every lesson

Practice exam-style questions on Statistical Distributions

Questions about this lesson?

Where this comes back

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.

  1. Random variables and distribution functions
  2. Unconditional expected value, variance and standard deviation
  3. Discrete distributions: uniform, binomial and Poisson
  4. Continuous distributions: uniform, normal and logistic
  5. Why asset prices are log-normal
  6. Probability trees, conditional expectations and conditional variance
  7. Covariance and correlation from a joint probability table
  8. Bayes' theorem: updating a probability with new information

Ask Sensei Listen instead

Questions on Random variables and distribution functions

Learn with Sensei, out loud The voice tutor, in early access

Sensei teaches the lesson aloud and stops when you interrupt: "wait, why is the geometric mean lower?" It answers with the lesson's own example, then quizzes you by voice. Every account can try Sensei on one module, with one voice question.

USD 149 a month founding price (regular USD 199), kept for as long as you stay subscribed. Everything in Plus included.

In active development and improving every day. Send feedback · Plans and pricing

Analyst Dojo Plus

Your free review list holds 10 items.

Plus keeps everything you save, for USD 19 a month. To make room on the free plan, remove something from your review list.

See Plus

Lessons, checkpoints and the lesson questions in practice stay free. Compare plans