Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Last week you built your first probability distribution table and used it to find a game’s expected winnings — the long-run average payout if you played over and over. That average is only half the story. Two games can share the exact same average payout and still feel completely different to play: one might pay out close to that average almost every time, while the other swings wildly between a big loss and a rare big win. This week you’ll learn to measure that swing with the standard deviation of a random variable. Then you’ll take the first step past distributions built from a short list of outcomes — discrete random variables — into the kind where the outcome could be any number in a range at all, like a person’s height or how long a coffee order takes. That’s a continuous random variable, and it’s the introduction to the bell-shaped Normal curve you’ll spend the next several weeks with.

1The mean of a random variable, one more time

A random variable XX assigns a number to every outcome of a random process. Its probability distribution lists each possible value xx next to P(x)P(x), the chance that value occurs — every P(x)P(x) is between 0 and 1, and they all add up to 1. You already met the mean, or expected value, of XX:

μ=E(X)=xP(x)\mu = E(X) = \sum x \cdot P(x)

Read this as a weighted average: instead of averaging every value equally, multiply each value by how likely it is, then add the products. μ\mu isn’t necessarily a value XX can even take on — it’s the distribution’s balancing point, and its most useful meaning is a long-run average: if the random process repeated itself thousands of times, the average of all those outcomes would settle in near μ\mu.

2How far from the mean? The standard deviation of a random variable

The standard deviation of a random variable, written σ\sigma or SD(X)SD(X), measures the typical distance an outcome lands from μ\mu:

σ=SD(X)=(xμ)2P(x)\sigma = SD(X) = \sqrt{\sum (x - \mu)^2\, P(x)}

Read it left to right: find each outcome’s deviation from the mean, xμx-\mu (this can be negative); square every deviation so negatives don’t cancel positives; weight each squared deviation by its probability P(x)P(x) and add them up (this sum is the variance, σ2\sigma^2); then undo the squaring with a square root so σ\sigma comes back in the same units as XX.

Worked Example 1 — a warm-up with round numbers. Before the richer example below, try the formula on the simplest possible game: flip one fair coin. Heads (probability 0.5) pays $4; tails (probability 0.5) pays $0. Let XX be the payout.

OutcomexxP(x)P(x)xP(x)x\cdot P(x)xμx-\mu(xμ)2(x-\mu)^2(xμ)2P(x)(x-\mu)^2 P(x)
Heads$40.52242
Tails$00.50−242
Total1.024

μ=E(X)=2+0=$2\mu = E(X) = 2 + 0 = \$2: the long-run average payout is $2. Summing the last column gives the variance, σ2=2+2=4\sigma^2 = 2 + 2 = 4, so σ=4=$2\sigma = \sqrt{4} = \$2. Every step is a round number here on purpose, so you can check each one in your head before the next example makes the numbers messier.

Worked Example 2 — expected winnings on a raffle ticket. A campus club sells 200 tickets at $5 each for a fundraiser. One ticket wins a $300 grand prize, four tickets win a $25 gift card, and the remaining 195 tickets win nothing. Let XX be a ticket buyer’s net winnings — the prize won minus the $5 cost — for a single ticket.

OutcomexxP(x)P(x)xP(x)x\cdot P(x)xμx-\mu(xμ)2(x-\mu)^2(xμ)2P(x)(x-\mu)^2 P(x)
Grand prize$2950.0051.47529888,804444.02
Gift card$200.0200.4002352910.58
No prize−$50.975−4.875−243.90
Total1.000−3.00458.50

Summing the xP(x)x\cdot P(x) column gives μ=E(X)=$3.00\mu = E(X) = -\$3.00. On average, a ticket buyer loses $3 per ticket in the long run. That is exactly why the fundraiser works: multiply that average loss by all 200 tickets sold, and 200×($3)=$600200 \times (-\$3) = -\$600 for players collectively — which means $600 raised for the club. You can check that number directly, ticket by ticket, instead of through the probability table:

Amount
Ticket sales (200 tickets × $5)$1,000
Prizes paid out ($300 + 4 × $25)$400
Net raised for the club$600

Both routes agree: $600. Summing the last column of the first table and taking the square root gives

σ=458.50$21.41.\sigma = \sqrt{458.50} \approx \$21.41.

A single ticket’s outcome typically lands about $21.41 away from that $3-\$3 average — a large spread relative to the mean. Almost every ticket loses exactly $5 (close to average), but the rare $295 win sits far out and pulls the typical distance from the mean way up. A hypothetical raffle with the same $3-\$3 mean where every ticket simply lost $3 for certain would have σ=0\sigma = 0 — no spread, because there’d be nothing uncertain about the outcome. Here σ$21.41\sigma \approx \$21.41 signals real risk: most players lose a little, a few win a lot.

3From discrete to continuous: density curves

Every random variable so far — carnival-game payouts, raffle winnings — has been discrete: a short list of possible values you can put in a table and add up. Many real quantities aren’t like that. A person’s height, an espresso machine’s steaming time, or a commute can fall anywhere along a continuum, with no useful way to list “every possible value” one at a time. These are continuous random variables, and they need a different tool than a probability table: a density curve.

A density curve is a smooth curve where area, not height, equals probability. The probability that XX falls between two values aa and bb is the area under the curve between aa and bb — never read a probability directly off the curve’s height. Two properties always hold: the curve never dips below 0, and the total area under the entire curve equals 1 (some outcome always happens). One especially important density-curve shape — the one you’ll use for the rest of the semester — is the Normal curve: bell-shaped, symmetric, single-peaked, centered exactly at the mean μ\mu, with its spread controlled by σ\sigma. A Normal curve with mean μ\mu and standard deviation σ\sigma is written N(μ,σ)N(\mu, \sigma).

Worked Example 3 — Reading area under a density curve. Suppose adult female height (inches) is modeled by a Normal density curve N(64.5,2.5)N(64.5, 2.5) — a common illustrative figure for this bell shape, not a claim about any specific real survey. What’s the probability a randomly selected woman is between 63 and 66 inches tall? Because XX is continuous, this probability is the area under the curve between 63 and 66, not a height read off the curve. R’s xpnorm() function computes that area (quietly converting each boundary to a standardized distance from the mean behind the scenes — a preview of the z-score tool coming in Week 6) and reports:

P(X<63)=0.2743,P(X<66)=0.7257,P(X<63)=0.2743, \qquad P(X<66)=0.7257,

so the strip between them has area P(63<X<66)=0.4515P(63<X<66)=0.4515 — about 45.1% of adult women, under this model, fall in that six-inch window. Two things this previews: first, P(X<66)P(X<66) already includes everything up through 63, so the middle strip’s area is the difference of two “less-than” areas — the same whole-minus-the-rest logic you’ll use constantly with density curves. Second, because a single exact height is a line with zero width, the area above any one exact value is 0, so P(X=64.5)=0P(X=64.5)=0 even though P(63<X<66)>0P(63<X<66)>0.

See it in R.

library(mosaic)

# Worked Example 2: raffle net winnings ($5 ticket, 200 sold)
x <- c(295, 20, -5)             # net winnings (prize won - $5 cost)
p <- c(0.005, 0.020, 0.975)     # 1 grand prize, 4 gift cards, 195 no-prize / 200
sum(p)                          # check: probabilities sum to 1

mu <- sum(x * p)                # E(X)
mu

sigma <- sqrt(sum((x - mu)^2 * p))   # SD(X)
sigma

# Worked Example 3 preview: area under a density curve
xpnorm(c(63, 66), mean = 64.5, sd = 2.5, plot = FALSE)
gf_dist("norm", mean = 64.5, sd = 2.5)   # draws the N(64.5, 2.5) density curve

Running this prints mu = -3 and sigma = 21.41261 — matching the by-hand table above — and xpnorm() prints P(X ≤ 63) = 0.2743 and P(X ≤ 66) = 0.7257, the same two areas used in Worked Example 2. gf_dist("norm", ...) draws the N(64.5,2.5)N(64.5, 2.5) density curve itself, a visual check that it’s bell-shaped and centered where you’d expect.

A probability histogram of the raffle's net winnings has three bars: a very tall bar at x = -5 reaching a height of 0.975, a short bar at x = 20 with height 0.02, and a barely visible bar at x = 295 with height 0.005. A vertical dashed line marks the mean, mu = -3, sitting just to the right of the tall -5 bar -- most tickets lose close to the average, while the rare 295 win sits far out in the right tail and pulls the standard deviation up to $21.41.

Figure 1. A probability histogram of the raffle’s net winnings has three bars: a very tall bar at x=$5x=-\$5 reaching a height of 0.975, a short bar at x=$20x=\$20 with height 0.02, and a barely visible bar at x=$295x=\$295 with height 0.005. A vertical dashed line marks the mean, μ=$3\mu=-\$3, sitting just to the right of the tall $5-\$5 bar — most tickets lose close to the average, while the rare $295 win sits far out in the right tail and pulls the standard deviation up to $21.41.

A bell-shaped Normal density curve N(64.5, 2.5) is shaded between x = 63 and x = 66. The shaded strip's area, 0.4515, is printed in the middle of the curve; the unshaded area in both tails together equals 1 minus 0.4515 = 0.5485, and the entire shaded-plus-unshaded region under the curve sums to exactly 1.

Figure 2. A bell-shaped Normal density curve N(64.5,2.5)N(64.5, 2.5) is shaded between x=63x=63 and x=66x=66. The shaded strip’s area, 0.4515, is printed in the middle of the curve; the unshaded area in both tails together equals 10.4515=0.54851-0.4515=0.5485, and the entire shaded-plus-unshaded region under the curve sums to exactly 1.

4Check your understanding

  1. A carnival ring-toss game costs $3 to play. You win a $10 prize with probability 0.10, a $5 prize with probability 0.20, and nothing the rest of the time. Let XX be your net winnings. Find μ=E(X)\mu = E(X).

  2. Using the same ring-toss game, find σ=SD(X)\sigma = SD(X). (Hint: build the same six-column table as Worked Example 2.)

  3. In Worked Example 2’s raffle, the club sells all 200 tickets. Using μ=E(X)=$3\mu = E(X) = -\$3, find the players’ total expected net winnings across all 200 tickets, and explain what that number means for the club’s fundraiser.

  4. In Worked Example 3, P(X<66)=0.7257P(X < 66) = 0.7257. Using the fact that the total area under any density curve equals 1, find P(X>66)P(X > 66) without computing a new area from scratch.

  5. Explain, in your own words, why height needs a density curve instead of a probability table like the ones you built for discrete random variables in Weeks 4–5.

  6. True or false, with a one-sentence reason: for the continuous XX in Worked Example 3, P(X=64.5)>0P(X = 64.5) > 0.

5Key terms