Skip to content

06-01: Exercises — Random Variables and Expected Value

Notes reference: 06-01: Random Variables and Expected Value


Q1: Is it a valid probability distribution?

Check each table.

(a)  x     0     1     2     3
     P(x)  0.15  0.35  0.30  0.20

(b)  x     1     2     3     4
     P(x)  0.20  0.30  0.35  0.20

(c)  x     0     1     2
     P(x)  0.50  0.70  −0.20

Solution

(a)  All P(x) in [0,1]  ✓        Σ = 0.15+0.35+0.30+0.20 = 1.00  ✓
     VALID

(b)  All P(x) in [0,1]  ✓        Σ = 0.20+0.30+0.35+0.20 = 1.05  ✗
     NOT VALID — probabilities sum to more than 1

(c)  P(2) = −0.20 < 0            ✗
     NOT VALID — a probability can never be negative
     (the sum happens to be 1.00, which is why you must check BOTH conditions)

Q2: Mean, variance, standard deviation

For distribution (a) in Q1, find μ, σ², and σ.

Solution

x P(x) x·P(x) x²·P(x)
0 0.15 0.00 0.00
1 0.35 0.35 0.35
2 0.30 0.60 1.20
3 0.20 0.60 1.80
Σ 1.00 1.55 3.35
μ  = Σ x·P(x) = 1.55

σ² = Σ x²·P(x) − μ²  =  3.35 − 1.55²  =  3.35 − 2.4025  =  0.9475

σ  = √0.9475 = 0.9734

Check with the definition form:

Σ (x−μ)²P(x) = (0−1.55)²(0.15) + (1−1.55)²(0.35) + (2−1.55)²(0.30) + (3−1.55)²(0.20)
             = 2.4025(0.15) + 0.3025(0.35) + 0.2025(0.30) + 2.1025(0.20)
             = 0.360375 + 0.105875 + 0.060750 + 0.420500
             = 0.9475     ✓  same
=SUMPRODUCT(A2:A5, B2:B5)                       ' μ  -> 1.55
=SUMPRODUCT(A2:A5^2, B2:B5)-D1^2                ' σ² -> 0.9475
=SQRT(D2)                                        ' σ  -> 0.9734
x <- 0:3; p <- c(.15,.35,.30,.20)
mu <- sum(x*p);                 mu       # 1.55
s2 <- sum(x^2*p) - mu^2;        s2       # 0.9475
sqrt(s2)                                 # 0.9734

Q3: Build a distribution from an experiment

Roll two dice and let X = the larger of the two values (or the common value on doubles).

Build the probability distribution and find E(X).

Solution

For X = k, the outcomes are those where both dice ≤ k, minus those where
both dice ≤ k−1:      count = k² − (k−1)² = 2k − 1
x count P(x) x·P(x)
1 1 1/36 0.0278
2 3 3/36 0.1667
3 5 5/36 0.4167
4 7 7/36 0.7778
5 9 9/36 1.2500
6 11 11/36 1.8333
Σ 36 1.000 4.4722
E(X) = 161/36 = 4.4722

Sanity check: the maximum of two dice should exceed the mean of one die
(3.5), and it does — 4.47.
S <- expand.grid(1:6, 1:6)
mx <- pmax(S$Var1, S$Var2)
round(prop.table(table(mx)), 4)
mean(mx)                       # 4.4722

Q4: Expected value of a game

A carnival game costs $3 to play. You roll one die: a 6 pays $15, a 4 or 5 pays $5, anything else pays nothing.

  1. Build the distribution of net gain.
  2. Find E(X).
  3. Should you play?
  4. What would the game have to pay on a 6 to be fair?

Solution

1.  Net gain = payout − 3

    x      P(x)      x·P(x)
   +12     1/6      +2.0000        (roll a 6:  15 − 3)
    +2     2/6      +0.6667        (roll 4 or 5:  5 − 3)
    −3     3/6      −1.5000        (roll 1, 2 or 3)
                    ─────────
          E(X)  =   +1.1667
2.  E(X) = +$1.17 per play

3.  YES — this game has a POSITIVE expected value for the player.
    Over 100 plays you would expect to be ahead by about $117.
    (Real carnivals do not offer this; the point is that E(X) is
     the number that decides.)

4.  For a FAIR game, E(X) = 0.  Let the 6 pay $W:
       (W − 3)(1/6) + (2)(2/6) + (−3)(3/6) = 0
       (W − 3)/6 + 4/6 − 9/6 = 0
       (W − 3) + 4 − 9 = 0
       W = 8
    Paying $8 on a six makes the game fair.

Q5: Insurance pricing

An insurer sells a one-year $250,000 policy for a premium of $420. The probability the insured dies in the year is 0.0009.

  1. Find the insurer's expected profit per policy.
  2. Find the standard deviation.
  3. What premium gives an expected profit of $300?

Solution

1.  x            P(x)       x·P(x)
    +420        0.9991     +419.622        (survives — keep the premium)
    −249,580    0.0009     −224.622        (pays 250,000, keeps the 420)
                           ──────────
                  E(X) =   +195.00

    Expected profit = $195.00 per policy.

2.  Σ x²P(x) = (420)²(0.9991) + (−249,580)²(0.0009)
             = 176,241.24 + 56,061,158.76
             = 56,237,400.00

    σ² = 56,237,400.00 − 195² = 56,237,400.00 − 38,025 = 56,199,375.00
    σ  = √56,199,375.00 = $7,496.62

    The standard deviation dwarfs the mean — one policy is a gamble.
    Across 100,000 policies the standard error of the mean profit is
    7,496.62 / √100,000 = $23.71, so the total profit is highly predictable.
    THAT is the insurance business model (see 08-02).

3.  Let the premium be c.  Expected profit = c − 250,000(0.0009)
                                           = c − 225
    Set c − 225 = 300  →  c = $525

Q6: Rules for E and Var

X has μ = 20 and σ = 4. Find the mean and standard deviation of:

  1. Y = X + 10
  2. Y = 3X
  3. Y = 3X − 5
  4. W = X₁ + X₂ where X₁, X₂ are independent copies of X
  5. D = X₁ − X₂

Solution

1.  E(X+10)  = 20 + 10 = 30
    SD(X+10) = 4                    adding a constant SHIFTS, never spreads

2.  E(3X)  = 3(20) = 60
    Var(3X) = 3²(16) = 144  →  SD = 12

3.  E(3X−5)  = 3(20) − 5 = 55
    SD(3X−5) = |3|(4) = 12          the −5 does not affect spread

4.  E(X₁+X₂)   = 20 + 20 = 40
    Var(X₁+X₂) = 16 + 16 = 32  →  SD = √32 = 5.657
    NOTE: 5.657, not 8. Standard deviations never add.

5.  E(X₁−X₂)   = 20 − 20 = 0
    Var(X₁−X₂) = 16 + 16 = 32  →  SD = √32 = 5.657
    VARIANCES ADD even when you subtract the variables.

Point 5 is exactly why the two-sample standard error in 11-02 has a + inside its square root.


Q7: Find a missing probability

x     0     1     2     3     4
P(x)  0.10  0.25  ?     0.20  0.15

Find P(2), then μ and σ.

Solution

Σ P(x) = 1
0.10 + 0.25 + P(2) + 0.20 + 0.15 = 1
0.70 + P(2) = 1
P(2) = 0.30

μ  = 0(0.10) + 1(0.25) + 2(0.30) + 3(0.20) + 4(0.15)
   = 0 + 0.25 + 0.60 + 0.60 + 0.60 = 2.05

Σ x²P(x) = 0 + 0.25 + 1.20 + 1.80 + 2.40 = 5.65
σ² = 5.65 − 2.05² = 5.65 − 4.2025 = 1.4475
σ  = √1.4475 = 1.2031

Q8: Simulate to verify

Verify the Q2 distribution's mean and variance by simulation.

Solution

x <- 0:3; p <- c(.15,.35,.30,.20)
set.seed(42)
sim <- sample(x, 1e6, replace = TRUE, prob = p)

c(theory_mean = sum(x*p),            sim_mean = mean(sim))
c(theory_var  = sum(x^2*p)-sum(x*p)^2, sim_var = var(sim))
round(prop.table(table(sim)), 4)     # ≈ 0.15 0.35 0.30 0.20
rng = np.random.default_rng(42)
x = np.array([0,1,2,3]); p = np.array([.15,.35,.30,.20])
sim = rng.choice(x, 1_000_000, p=p)

(x*p).sum(), sim.mean()                        # 1.55, ≈1.55
(x**2*p).sum() - (x*p).sum()**2, sim.var(ddof=1)   # 0.9475, ≈0.9475
' Build a cumulative column C from B, then:
=INDEX($A$2:$A$5, MATCH(RAND(), $C$2:$C$5, 1) + 1)   ' one draw; fill down 10,000 rows
=AVERAGE(E2:E10001)     ' ≈ 1.55
=VAR.P(E2:E10001)       ' ≈ 0.9475

What to notice: with 10,000 draws the simulated mean is within about ±0.02 of 1.55; with a million it is within ±0.002. Simulation confirms theory — it does not replace it.


⬅️ Previous: 05-03: Exercises — Bayes' Theorem and Counting Rules ➡️ Next: 06-02: Exercises — Binomial and Poisson Distributions