When you turn 25, your car insurance premiums drop. This isn’t the insurance company being generous — it’s mathematics. The company has records on millions of drivers. They know the probability distribution of accidents by age, and they price each policy to make a profit across thousands of customers, even if any individual policy might lose money.
The concept at work is expected value — the long-run average outcome of a random process, weighted by how likely each outcome is. Insurance companies, casinos, investment funds, and pharmaceutical companies all make decisions by computing expected values. When a drug company decides whether to run a clinical trial, they are computing expected value. When a casino sets the payout on a slot machine, they are setting expected value below 1.
After this lesson, you will be able to:
By the end of this lesson, you will be able to:
Distinguish between discrete and continuous random variables and interpret the notation , .
Construct a probability mass function (PMF) and verify its validity.
Compute the expected value and interpret it as a long-run average.
Compute the variance and standard deviation using the shortcut formula.
This lesson introduces random variables — functions that attach numbers to random outcomes — and the mathematical tools for describing their behaviour: expected value and variance. These concepts are the bridge between probability and statistics.
Section 2: Prerequisites
▾
Sample space (from PR-1): The set of all possible outcomes of a random experiment. You need this to list every value a random variable can take.
Classical probability (from PR-1): for equally likely outcomes. Today we generalize: outcomes can have unequal probabilities, so we use a table instead of counting.
Probability axioms (from PR-1): for any event , and for the full sample space. The same axioms apply to every row and to the column total in a PMF table.
Complement rule (from PR-1):. You will use the equivalent idea that the sum of all PMF probabilities must equal 1 to find a missing value.
Weighted average (arithmetic): Multiplying each value by its “weight” and summing. Expected value is exactly a weighted average — weights are probabilities.
Checkpoint: If , what is ?
Success Factor:
Bridging old and new: In PR-1, you computed probabilities for individual events. Today, you will organize all outcomes into a table (the PMF) and compute a single number — — that summarizes the entire distribution. A key shift: probabilities in a PMF need not be equal, and need not equal any specific outcome in the table.
Retrieval Warm-up — from PR-1
A bag contains 3 red balls and 5 blue balls. You draw one ball, note its colour, put it back, and draw again. What is the probability the first ball is red and the second is blue?
Retrieval Warm-up — from PR-2
How many ways can you choose 3 students from a group of 10 to form a committee (no assigned roles)?
Section 3: Core Concepts
▾
Six concepts — here is how they build on each other:
C1 — Random Variables: What kind of quantity are we studying?
C2 — PMF: How do we record all the probabilities in one place?
C3 — Expected Value: What is the long-run average outcome?
C4 — E(X²): An intermediate quantity needed for variance.
C5 — Variance and SD: How spread out are the outcomes?
C6 — CDF: How do we answer “at most” and “at least” questions?
C1 — Random Variables
When you roll a die, you don’t know in advance which face will appear. But the outcome is always a number — 1, 2, 3, 4, 5, or 6. A random variable is a rule that assigns a number to each outcome of a random experiment.
We write to mean a random variable, and (lowercase) to mean one specific value it can take.
Random Variable
A random variable is a function that assigns a real number to each outcome in the sample space of a random experiment.
A discrete random variable takes a countable set of values (e.g., 0, 1, 2, 3, …).
A continuous random variable takes any value in an interval (e.g., any height between 150 cm and 200 cm).
Examples:
Number of customers who enter a store in one hour → discrete (0, 1, 2, 3, …)
Height of a randomly chosen student → continuous (any value in an interval)
Number of defective items in a batch of 20 → discrete (0, 1, 2, …, 20)
Time until the next earthquake → continuous (any non-negative real number)
Dots can be counted and listed; the band cannot — every point inside it is a valid value. That is the defining distinction.
“Discrete” does not mean “small.” The number of grains of sand on a beach is countable (even if enormous) — in principle it is discrete. The distinction is whether the variable can take any value in an interval (continuous) or only isolated, countable values (discrete).
C2 — Probability Mass Function (PMF)
A PMF is simply a table (or formula) that lists every value that can take, along with the probability of each. Think of it as the complete “probability recipe” for your random variable.
Probability Mass Function (PMF)
The probability mass function of a discrete random variable assigns a probability to each possible value:
A function is a valid PMF if and only if both conditions hold.
The PMF collapses the sample space: TH and HT both give X = 1, so their probabilities add to 0.50.
Example: = number of heads in two fair coin flips.
0
1
2
0.25
0.50
0.25
Check: ✓. All probabilities ✓.
A PMF does not require each probability to equal . Outcomes can have unequal probabilities — that is the whole point of building a PMF rather than just counting.
x
1
2
3
4
P(X = x)
0.10
0.40
0.30
0.05
0.05
Total = 0.85 — not a valid PMF: missing 0.15.
Three probabilities are fixed. Adjust until the total bar fills to exactly 1.00 — there is only one value that makes this a valid PMF.
Notice: E(X) = 2.60 falls between x = 2 and x = 3. It is not the tallest bar (x = 2 is the mode). E(X) is the balance point — where the distribution would balance if the bars had physical weight.
C3 — Expected Value
The expected value answers: “If this random experiment were repeated an enormous number of times, what would the average outcome be?” It is a weighted mean where each outcome is weighted by its probability .
We write to emphasize that the expected value plays the same role as the population mean in descriptive statistics.
Expected Value
The expected value (mean) of a discrete random variable is:
This is the long-run average outcome across infinitely many repetitions of the experiment.
Mini-example: For the PMF in the chart above ( = 1, 2, 3, 4 with = 0.10, 0.40, 0.30, 0.20):
If you repeated this experiment millions of times and averaged all results, the average would approach 2.60.
E(X) = —Mode = —
10/100 → 0.10
40/100 → 0.40
30/100 → 0.30
20/100 → 0.20
Try the three preset buttons. In the right-skewed preset, the mode is x = 4, but E(X) is pulled leftward by the lower-probability outcomes — the balance point is not the tallest bar.
E(X) is not the mode. The most likely outcome (mode) is in the example above (probability 0.40). But . The expected value is the balance point of the distribution — it accounts for how far each outcome is from the center, not just which has the highest probability. In fact, E(X) = 3.5 for a fair die, even though no face shows 3.5.
n = 0x̄ = —last outcome: —
Run trials to watch the running average build up.
“Expected value” means the long-run average. Run one trial: the average is that single whole-number outcome — nowhere near 2.60. Keep running trials and watch the running average wander, then settle onto the dashed E(X) line.
C4 — Computing
To compute variance, you first need a related quantity: . This is also a weighted average, but you square each outcome before weighting it.
We write to mean “the expected value of the squared random variable.”
Expected Value of X²
This is computed from the same PMF: square each value, multiply by its probability, and sum.
Continuing the example above:
. In the example, , but . These are equal only when is a constant (no randomness at all). Confusing these two quantities is one of the most common errors when computing variance — it would give , which is wrong.
C5 — Variance and Standard Deviation
Variance measures how spread out the distribution is — how far a typical outcome is from the expected value. A small variance means most outcomes cluster near ; a large variance means outcomes are spread widely.
We write and .
Variance and Standard Deviation
The variance of a discrete random variable is computed with the shortcut formula:
The standard deviation is:
Both measure spread in the same units as (standard deviation) or squared units (variance). Variance is always .
Completing the example:
Interpretation: outcomes of typically deviate from the expected value of 2.60 by about 0.92 units.
Each square's side is the distance from μ, so its area is the squared deviation
(x − μ)². Darker squares carry more probability weight. Variance averages the areas using those
weights — outcomes far from μ contribute disproportionately because the distance is squared.
What the formula measures: each outcome’s distance to is squared (the green squares — area = ) and weighted by its probability. Far outcomes contribute disproportionately because the distance is squared.
The ±σ brackets have the same center (E(X) = 3) but very different widths. A large variance does not change where the distribution is centered — only how much outcomes scatter around that center.
Variance is always . If you compute a negative variance, you made an arithmetic error. Since , it is an average of non-negative numbers and cannot be negative. A negative answer is a signal to recheck your arithmetic, not a valid result.
C6 — Cumulative Distribution Function (CDF)
The PMF answers “exactly equal to.” The CDF answers “less than or equal to” — it accumulates the probabilities as increases.
We write to denote the CDF evaluated at .
Cumulative Distribution Function (CDF)
The cumulative distribution function of a discrete random variable is:
The CDF gives the probability that takes a value at most.
To answer “at least ”: .
To answer “between and ”: .
CDF for our running example ( = 1, 2, 3, 4):
1
0.10
0.10
2
0.40
0.50
3
0.30
0.80
4
0.20
1.00
. .
Accumulate to:x < 1
x < 1x = 1x = 2x = 3x = 4
F(—) = 0.00P(X > —) = 1.00
Slide from x = 1 to x = 4 one step at a time. Each step highlights one new bar in the PMF and adds one jump to the staircase. is the height difference between two staircase levels.
Section 4: Worked Examples
▾
Example 1 — Verify a PMF
A game assigns payouts according to the table below. Verify that this is a valid PMF.
(payout $)
−2
0
3
5
0.20
0.50
0.20
0.10
Solution (fully narrated):
I notice this problem asks me to verify the PMF — that means checking the two conditions, not computing anything else yet.
Condition 1: All probabilities non-negative.
I scan the row: 0.20, 0.50, 0.20, 0.10. All are . ✓
Condition 2: Probabilities sum to 1.
Both conditions hold, so this is a valid PMF. I could stop here — the question only asks to verify, not to compute E(X). Resisting the urge to keep calculating is part of reading the question carefully.
Example 2 — Compute E(X) for a Payout Scenario
Using the same PMF from Example 1 (payouts −2, 0, 3, 5 with probabilities 0.20, 0.50, 0.20, 0.10), compute .
Prediction checkpoint: Before you see the full solution, predict: will be negative, zero, or positive? The largest probability (0.50) sits at , but there is also some probability on the positive values. Make a prediction, then read on.
Show Solution
The expected payout is $0.70 per play. Even though you have a 50% chance of winning nothing and a 20% chance of losing $2, the possibility of winning $3 or $5 tips the average to $0.70 in your favor.
Interpretation: If you played this game 1000 times, you would expect to come out ahead by about 700$ in total.
Example 3 — Compute Var(X) Step by Step
Using the same PMF (payouts −2, 0, 3, 5 with probabilities 0.20, 0.50, 0.20, 0.10), compute and .
Show Solution
Step 1: We already know from Example 2.
Step 2: Compute .
Step 3: Apply the shortcut formula.
Step 4: Compute the standard deviation.
Interpretation: Payouts in this game deviate from the expected $0.70 by about $2.15 on average. The game is favorable on average but quite volatile.
Example 4 — Use the CDF (Find the Error)
A student is using the PMF from Examples 1–3. They want to find and write:
Student’s work:
CDF values: , .
But wait — the student then says “so the answer is ,” and concludes that .
What error did the student make?
Show Solution
The CDF calculation is correct — is right. But the student’s conclusion is wrong.
includes all outcomes strictly greater than 0 and at most 3. In this distribution, the only value in that range is (since is excluded by the strict inequality). So in this particular case, happens to be numerically correct.
The error is conceptual: the student stated it as a general fact that , which is false in general. For example, , which includes both (probability 0.50) and (probability 0.20) — it is not equal to .
The CDF formula accumulates all outcomes in the interval, not just the endpoint.
Section 5: Guided Practice
▾
GP1 — Discrete or Continuous?
The number of phone calls a help-desk agent receives in a one-hour shift.
Is this random variable discrete or continuous? Explain your reasoning.
Choose the correct classification:
The height (in centimetres) of a randomly chosen student at your school.
Is this random variable discrete or continuous? Explain your reasoning.
Choose the correct classification:
The number of defective items in a quality-control sample of 50 products.
Is this random variable discrete or continuous? Explain your reasoning.
Choose the correct classification:
The time (in minutes) a customer waits in line at a coffee shop.
Is this random variable discrete or continuous? Explain your reasoning.
Choose the correct classification:
The number of siblings a randomly chosen person has.
Is this random variable discrete or continuous? Explain your reasoning.
Choose the correct classification:
GP2 — Is This PMF Valid?
GP3 — Compute E(X)
GP4 — Compute Var(X) and σ_X
Section 6: Independent Practice
▾
IP1 — Full E(X) + Var(X) Workflow
IP2 — CDF Practice
IP3 — Is the Game Fair?
IP4 — Find the Missing Probability, Then Compute E(X)
IP5 — Compute E(X) and σ_X, Then Interpret
IP6 — Multi-Step Synthesis
Mixed Review — Retrieval from Earlier Lessons
These problems draw on concepts from earlier in the course. Attempting them without re-reading prior lessons is the point — retrieval practice strengthens long-term memory more than re-reading.
Review Problem 1 — Conditional probability from a table
Review Problem 2 — Combinations in a probability calculation
Section 7: Mastery Check
▾
Question 1 — Feynman Test
Explain, in your own words and without formulas, why the expected value is not necessarily the most likely value (mode) of a random variable. Use a concrete example to support your explanation.
0 / 500
Model Answer
The expected value is a weighted average — it accounts for both the probability and the size of each outcome. The mode is simply the outcome with the highest probability, regardless of how large or small that outcome is.
Example: Imagine a lottery where you pay $1 and win $1,000 with probability 0.001 or $0 (lose your $1) with probability 0.999. The mode is −$1 because it happens 99.9% of the time. But .
The expected value is pulled up by the large prize even though you almost always lose. It is the balance point of the distribution — the location where it would balance if each outcome had weight equal to its probability. The mode ignores the magnitude of outcomes entirely.
Classic example from class: A fair die has (not an outcome at all), while the mode is undefined (all faces equally likely). The expected value summarizes the distribution’s center of gravity, not its peak.
Question 2 — Apply: Medical Testing Revenue
A hospital laboratory charges fees for diagnostic tests. For a randomly chosen test order, the number of individual tests performed, , has the following distribution:
1
2
3
4
0.40
0.30
0.20
0.10
Each test costs the patient $80. Let be the revenue per test order.
What is the most efficient approach to finding the expected revenue per test order?
Question 3 — Error Analysis
PMF Validity — Retrieval
CDF Probability — Retrieval
Self-Assessment
How confident do you feel about expected value and variance?
Still confusedReady for the Boss Fight
Section 8: Boss Fight
▾
Choose your challenge path. Both paths require the full toolkit from this lesson — PMF, , , and interpretation.
🎡 Path A — The Analyst
Evaluate a carnival game bet. Is it profitable for the player in the long run? Use E(X) and σ_X to give a complete recommendation.
🏗️ Path B — The Architect
Design a four-outcome PMF for a payout scheme that satisfies strict mathematical constraints. Build and verify your own distribution.
🎡 Path A — The Analyst
A carnival game costs $5 to play. You throw a ring onto a set of bottles. The outcomes and probabilities are:
Outcome
Prize
Probability
Ring on a red bottle
$20
0.05
Ring on a blue bottle
$10
0.15
Ring on a yellow bottle
$3
0.30
Miss entirely
$0
0.50
Let = net winnings per play (prize minus $5 entry fee).
Task 1. Construct the PMF for (net winnings). Write out the full table including all four outcomes with their net values and probabilities. Verify the PMF is valid.
Task 2. Compute . Show every step of the weighted sum. Then answer: Is this game favorable, unfavorable, or fair for a player? How much does the player expect to win or lose per play?
Task 3. Compute using the shortcut formula, then compute . Round to 2 decimal places.
Task 4. A friend says, “The most common outcome is missing (50% chance), so this game is obviously a bad deal.” Write a 2–3 sentence response that uses both and to give a more complete analysis. Does the variance change your recommendation?
0 / 500
🏗️ Path B — The Architect
Design a PMF for a payout scheme (e.g., a custom lottery or insurance product) with exactly 4 outcomes satisfying these constraints:
All probabilities are non-negative and sum to 1.
(the expected payout is $2 per play).
(the distribution is not too spread out).
Outcomes are positive integers (payouts in dollars).
Task 1. Choose your four outcome values (positive integers). Write down the equations you need your probabilities to satisfy: the PMF validity equation and the constraint. Explain your strategy for choosing outcomes and probabilities.
Task 2. Assign probabilities and verify: (a) all non-negative, (b) sum to 1, (c) . Show your arithmetic.
Task 3. Compute , then compute and verify . If your first attempt violates the variance constraint, adjust your design and re-verify.
Task 4. Suppose this PMF represents the daily payout (in $) of a new financial product. Write 2–3 sentences explaining what and your value mean to a potential investor who does not know probability theory.
0 / 500
Section 9: Challenge Problems
▾
Ready for more? These go beyond the lesson objectives.
Challenge 1 — Derive the Shortcut Formula
The definition of variance is:
where . Starting from this definition, derive the shortcut formula by algebraic expansion.
Hint: Expand as a polynomial, then apply linearity of expectation ( for constants , ).
Show Derivation
Expand the square:
Apply linearity of expectation (, and for constant ):
Substitute :
Since :
This derivation also explains why always: since variance is defined as an expected value of a squared quantity , it can never be negative, which forces .
Bonus: What does mean? By definition, . Since always, this expectation equals zero only if with probability 1, meaning with probability 1. A random variable with is a constant — it always takes the same value.
Challenge 2 — Regenerable Stretch Problem
This is the same generator as IP1 but used here as a stretch problem. Try to complete it with no scaffolding and verify your answer using the shortcut and definition formulas.