Statistics

Random Variables and Expected Value

Last updated: March 2026 · Intermediate
Before you start

You should be comfortable with:

Real-world applications
πŸ’°
Retail & Finance

Discounts, tax, tips, profit margins

A random variable assigns a numerical value to each outcome of a random process. It is the bridge between probability (which deals with events) and statistics (which deals with numbers). Instead of saying β€œthe event is heads,” a random variable lets you say β€œthe value is 1.” This shift from events to numbers opens the door to averages, spread, and all the quantitative tools of statistics.

What Is a Random Variable?

A random variable is a variable whose value is determined by the outcome of a random process. Random variables are typically denoted by capital letters such as XX, YY, or ZZ.

Example: Flip a fair coin 3 times and let XX = the number of heads. The possible values of XX are 0, 1, 2, and 3. Before you flip, you do not know what XX will be β€” but you can describe the probability of each possible value.

There are two types of random variables:

  • Discrete random variables take on a countable number of values (0, 1, 2, 3, …). Examples include the number of heads in 3 flips, the number of defective items in a batch, or the number of customers per hour.
  • Continuous random variables can take any value within a range (like height, temperature, or time). These require different tools (probability density functions) and are covered in a later topic.

This page focuses entirely on discrete random variables.

Probability Distribution Tables

A probability distribution lists every possible value of a random variable alongside its probability. It provides a complete picture of the random variable’s behavior.

Every valid probability distribution must satisfy two rules:

  1. Every probability is non-negative: P(X=x)β‰₯0P(X = x) \geq 0 for all values xx
  2. All probabilities sum to exactly 1: βˆ‘P(X=x)=1\sum P(X = x) = 1

Example 1: Number of Heads in 3 Coin Flips

When you flip a fair coin 3 times, the sample space has 23=82^3 = 8 equally likely outcomes: HHH, HHT, HTH, THH, HTT, THT, TTH, TTT. Counting the number of heads in each outcome gives us this distribution:

XX (heads)0123
P(X)P(X)18\frac{1}{8}38\frac{3}{8}38\frac{3}{8}18\frac{1}{8}

Verification: 18+38+38+18=88=1\frac{1}{8} + \frac{3}{8} + \frac{3}{8} + \frac{1}{8} = \frac{8}{8} = 1 βœ“\checkmark

The distribution tells us that getting exactly 1 or exactly 2 heads is much more likely (probability 38\frac{3}{8} each) than getting 0 or 3 heads (probability 18\frac{1}{8} each).

Probability Distribution β€” Number of Heads in 3 Coin Flips

1/82/83/801/83/83/81/80123X (number of heads)P(X)

Expected Value (Mean of a Random Variable)

The expected value (or mean) of a discrete random variable is the long-run average value you would observe if you repeated the random process many times. It is calculated by multiplying each value by its probability and summing:

E(X)=ΞΌ=βˆ‘xiβ‹…P(xi)E(X) = \mu = \sum x_i \cdot P(x_i)

The expected value does not have to be a value the random variable can actually take. It represents the theoretical average.

Example 2: Expected Number of Heads

Using the distribution from Example 1:

E(X)=0β‹…18+1β‹…38+2β‹…38+3β‹…18E(X) = 0 \cdot \frac{1}{8} + 1 \cdot \frac{3}{8} + 2 \cdot \frac{3}{8} + 3 \cdot \frac{1}{8}

=0+38+68+38=128=1.5= 0 + \frac{3}{8} + \frac{6}{8} + \frac{3}{8} = \frac{12}{8} = 1.5

Interpretation: On average, you would expect 1.5 heads per 3 flips. Of course you cannot flip exactly 1.5 heads in a single trial, but over 1,000 sets of 3 flips, the average number of heads would be very close to 1.5.

Example 3: Insurance Payout

An insurance policy pays out as follows:

OutcomePayoutProbability
No claim$00.90
Minor claim$2,0000.08
Major claim$10,0000.02

What is the expected payout per policy?

E(payout)=0(0.90)+2000(0.08)+10000(0.02)E(\text{payout}) = 0(0.90) + 2000(0.08) + 10000(0.02)

=0+160+200=360= 0 + 160 + 200 = 360

The expected payout is $360 per policy. If the insurance company charges a premium of $500, it expects to profit $140 per policy on average. This is exactly how insurance companies set their prices β€” by calculating expected value and adding a margin.

Verification: 2000Γ—0.08=1602000 \times 0.08 = 160. 10000Γ—0.02=20010000 \times 0.02 = 200. 0+160+200=3600 + 160 + 200 = 360 βœ“\checkmark

Variance and Standard Deviation of a Random Variable

Expected value tells you the center of a distribution, but it says nothing about how spread out the values are. Variance measures the average squared distance from the mean:

Var(X)=Οƒ2=βˆ‘(xiβˆ’ΞΌ)2β‹…P(xi)\text{Var}(X) = \sigma^2 = \sum (x_i - \mu)^2 \cdot P(x_i)

There is an equivalent shortcut formula that is often easier to compute:

Var(X)=E(X2)βˆ’[E(X)]2\text{Var}(X) = E(X^2) - [E(X)]^2

The standard deviation is the square root of the variance, bringing the measure of spread back to the original units:

SD(X)=Οƒ=Var(X)\text{SD}(X) = \sigma = \sqrt{\text{Var}(X)}

Example 4: Variance of Coin Flips

Using the distribution from Example 1 with ΞΌ=1.5\mu = 1.5:

Var(X)=(0βˆ’1.5)2β‹…18+(1βˆ’1.5)2β‹…38+(2βˆ’1.5)2β‹…38+(3βˆ’1.5)2β‹…18\text{Var}(X) = (0 - 1.5)^2 \cdot \frac{1}{8} + (1 - 1.5)^2 \cdot \frac{3}{8} + (2 - 1.5)^2 \cdot \frac{3}{8} + (3 - 1.5)^2 \cdot \frac{1}{8}

=2.25β‹…18+0.25β‹…38+0.25β‹…38+2.25β‹…18= 2.25 \cdot \frac{1}{8} + 0.25 \cdot \frac{3}{8} + 0.25 \cdot \frac{3}{8} + 2.25 \cdot \frac{1}{8}

=0.28125+0.09375+0.09375+0.28125=0.75= 0.28125 + 0.09375 + 0.09375 + 0.28125 = 0.75

SD(X)=0.75β‰ˆ0.866\text{SD}(X) = \sqrt{0.75} \approx 0.866

Verification: 2.258=0.28125\frac{2.25}{8} = 0.28125. 0.25Γ—38=0.09375\frac{0.25 \times 3}{8} = 0.09375. Sum: 0.28125+0.09375+0.09375+0.28125=0.750.28125 + 0.09375 + 0.09375 + 0.28125 = 0.75 βœ“\checkmark

Interpretation: The number of heads in 3 coin flips has a mean of 1.5 and a standard deviation of about 0.87. Most outcomes will fall within one standard deviation of the mean (roughly between 0.63 and 2.37), which aligns with what we see β€” 1 and 2 heads are the most common results.

Linear Transformations

If you transform a random variable using a linear function Y=aX+bY = aX + b, the expected value and variance follow predictable rules:

E(Y)=E(aX+b)=aβ‹…E(X)+bE(Y) = E(aX + b) = a \cdot E(X) + b

Var(Y)=Var(aX+b)=a2β‹…Var(X)\text{Var}(Y) = \text{Var}(aX + b) = a^2 \cdot \text{Var}(X)

Adding a constant (bb) shifts the mean but does not change the spread. Multiplying by a constant (aa) scales both the mean and the standard deviation, and scales the variance by a2a^2.

Example: A store marks up each item by doubling the wholesale price and adding $5. If the wholesale price XX has E(X)=20E(X) = 20 and Var(X)=9\text{Var}(X) = 9, then the retail price Y=2X+5Y = 2X + 5 has:

E(Y)=2(20)+5=45E(Y) = 2(20) + 5 = 45

Var(Y)=22(9)=36β‡’SD(Y)=6\text{Var}(Y) = 2^2(9) = 36 \quad \Rightarrow \quad \text{SD}(Y) = 6

Real-World Application: Retail β€” Expected Daily Revenue

A small bookstore tracks the number of books sold per day and finds the following distribution:

Books sold (XX)012345
Probability0.050.150.300.250.150.10

Each book sells for $25. What is the expected daily revenue?

Step 1: Find E(X)E(X), the expected number of books sold.

E(X)=0(0.05)+1(0.15)+2(0.30)+3(0.25)+4(0.15)+5(0.10)E(X) = 0(0.05) + 1(0.15) + 2(0.30) + 3(0.25) + 4(0.15) + 5(0.10)

=0+0.15+0.60+0.75+0.60+0.50=2.60= 0 + 0.15 + 0.60 + 0.75 + 0.60 + 0.50 = 2.60

Verification: 0.05+0.15+0.30+0.25+0.15+0.10=1.000.05 + 0.15 + 0.30 + 0.25 + 0.15 + 0.10 = 1.00 βœ“\checkmark

Step 2: Since revenue R=25XR = 25X, use the linear transformation rule:

E(R)=25β‹…E(X)=25Γ—2.60=65E(R) = 25 \cdot E(X) = 25 \times 2.60 = 65

Answer: The bookstore expects to earn $65 in daily book revenue on average.

Step 3 (bonus): Find the standard deviation of daily revenue.

E(X2)=02(0.05)+12(0.15)+4(0.30)+9(0.25)+16(0.15)+25(0.10)E(X^2) = 0^2(0.05) + 1^2(0.15) + 4(0.30) + 9(0.25) + 16(0.15) + 25(0.10)

=0+0.15+1.20+2.25+2.40+2.50=8.50= 0 + 0.15 + 1.20 + 2.25 + 2.40 + 2.50 = 8.50

Var(X)=8.50βˆ’(2.60)2=8.50βˆ’6.76=1.74\text{Var}(X) = 8.50 - (2.60)^2 = 8.50 - 6.76 = 1.74

Var(R)=252Γ—1.74=625Γ—1.74=1087.50\text{Var}(R) = 25^2 \times 1.74 = 625 \times 1.74 = 1087.50

SD(R)=1087.50β‰ˆ32.98\text{SD}(R) = \sqrt{1087.50} \approx 32.98

The expected daily revenue is $65, with a standard deviation of about $33 β€” there is meaningful day-to-day variation.

Practice Problems

Test your understanding with these problems. Click to reveal each answer.

Problem 1: A discrete random variable X has the following distribution. Find the missing probability.
XX1234
P(X)P(X)0.100.25?0.30

Since all probabilities must sum to 1:

P(X=3)=1βˆ’0.10βˆ’0.25βˆ’0.30=0.35P(X = 3) = 1 - 0.10 - 0.25 - 0.30 = 0.35

Answer: P(X=3)=0.35P(X = 3) = 0.35

Problem 2: A random variable X has the distribution: P(X=1) = 0.2, P(X=2) = 0.5, P(X=3) = 0.3. Find E(X).

E(X)=1(0.2)+2(0.5)+3(0.3)E(X) = 1(0.2) + 2(0.5) + 3(0.3)

=0.2+1.0+0.9=2.1= 0.2 + 1.0 + 0.9 = 2.1

Answer: E(X)=2.1E(X) = 2.1

Problem 3: A game costs $5 to play. You roll a die: if you roll a 6 you win $20, otherwise you win nothing. What is the expected net gain per game?

Let XX = net gain. If you roll a 6, net gain = $20 - $5 = $15. Otherwise, net gain = $0 - $5 = -$5.

E(X)=15β‹…16+(βˆ’5)β‹…56E(X) = 15 \cdot \frac{1}{6} + (-5) \cdot \frac{5}{6}

=156+βˆ’256=βˆ’106β‰ˆβˆ’1.67= \frac{15}{6} + \frac{-25}{6} = \frac{-10}{6} \approx -1.67

Answer: The expected net gain is approximately -$1.67 per game. On average, you lose about $1.67 each time you play. The game favors the house.

Problem 4: Using the distribution from Problem 2, find Var(X) and SD(X).

We found E(X)=2.1E(X) = 2.1. Now compute variance:

Var(X)=(1βˆ’2.1)2(0.2)+(2βˆ’2.1)2(0.5)+(3βˆ’2.1)2(0.3)\text{Var}(X) = (1 - 2.1)^2(0.2) + (2 - 2.1)^2(0.5) + (3 - 2.1)^2(0.3)

=(βˆ’1.1)2(0.2)+(βˆ’0.1)2(0.5)+(0.9)2(0.3)= (-1.1)^2(0.2) + (-0.1)^2(0.5) + (0.9)^2(0.3)

=1.21(0.2)+0.01(0.5)+0.81(0.3)= 1.21(0.2) + 0.01(0.5) + 0.81(0.3)

=0.242+0.005+0.243=0.49= 0.242 + 0.005 + 0.243 = 0.49

SD(X)=0.49=0.7\text{SD}(X) = \sqrt{0.49} = 0.7

Answer: Var(X)=0.49\text{Var}(X) = 0.49 and SD(X)=0.7\text{SD}(X) = 0.7

Problem 5: If X has E(X) = 10 and Var(X) = 4, find E(Y) and SD(Y) where Y = 3X - 2.

Using the linear transformation rules:

E(Y)=3β‹…E(X)βˆ’2=3(10)βˆ’2=28E(Y) = 3 \cdot E(X) - 2 = 3(10) - 2 = 28

Var(Y)=32β‹…Var(X)=9Γ—4=36\text{Var}(Y) = 3^2 \cdot \text{Var}(X) = 9 \times 4 = 36

SD(Y)=36=6\text{SD}(Y) = \sqrt{36} = 6

Answer: E(Y)=28E(Y) = 28 and SD(Y)=6\text{SD}(Y) = 6

Key Takeaways

  • A random variable assigns a number to each outcome of a random process. Discrete random variables take countable values; continuous ones take any value in a range.
  • A probability distribution lists every value with its probability. All probabilities must be non-negative and sum to 1.
  • Expected value E(X)=βˆ‘xiβ‹…P(xi)E(X) = \sum x_i \cdot P(x_i) gives the long-run average β€” the theoretical center of the distribution.
  • Variance Var(X)=βˆ‘(xiβˆ’ΞΌ)2β‹…P(xi)\text{Var}(X) = \sum (x_i - \mu)^2 \cdot P(x_i) measures spread. Standard deviation is Οƒ=Var(X)\sigma = \sqrt{\text{Var}(X)}.
  • Linear transformations: if Y=aX+bY = aX + b, then E(Y)=aE(X)+bE(Y) = aE(X) + b and Var(Y)=a2Var(X)\text{Var}(Y) = a^2 \text{Var}(X).
  • Expected value is used everywhere β€” insurance pricing, inventory planning, game theory, and business revenue forecasting.

Return to Statistics for more topics in this section.

Last updated: March 29, 2026