Educerie

Educerie · IB Diploma · Mathematics: analysis and approaches

IB Mathematics AA 4.7 · SL and HL

Discrete random variables

When the result of a trial is a number, how do you describe every value it could take and how likely each one is, and what should you expect it to be on average?

What you will learn

  • Understand a discrete random variable as a number decided by chance, with values that can be listed.
  • Know that a probability distribution, as a table or a formula, has probabilities that add to 1.
  • Understand expected value as the long-run average of a random variable.
  • Know that a game is fair when the player's expected gain is zero.

You must be able to

  1. Calculate E(X) from a table or a formula.
  2. Find an unknown constant using the fact that the probabilities add to 1.
  3. Draw up a probability distribution from a sample space or a tree diagram.
  4. Determine whether a game is fair, and find the prize or stake that makes it fair.
  5. Calculate two unknown probabilities from the sum to 1 and a given E(X).
  6. Calculate probabilities such as P(X ≥ 2) from a distribution.

In the exam. Paper 1 and Paper 2, as a Section A question of 5 to 7 marks or the middle of a Section B question: an unknown constant from the sum to 1 (2 to 3 marks, 1 to 2 more when a quadratic root must be rejected), P(X≥a)\mathrm{P}(X \ge a) (1 to 2 marks), E(X)\mathrm{E}(X) (2 marks), a second unknown from a given E(X)\mathrm{E}(X) (3 to 4 marks), and whether a game is fair or what prize makes it fair (2 to 4 marks). A distribution built from a tree, often without replacement, is a common way into Section B, and "show that" an equation or a probability is frequent. It all returns in 4.8, where the binomial distribution is a discrete random variable with a formula.

1Random variables

  • A random variable = a quantity whose value is decided by the outcome of a trial. It gets a capital letter, usually X\boldsymbol{X}. A value it might take gets the lower-case letter, x\boldsymbol{x}.
  • P(X=x)\boldsymbol{\mathrm{P}(X = x)} reads "the probability that XX takes the value xx". Events become short: "the larger score is at least 3" is X≥3X \ge 3.
  • A random variable is discrete when its values can be listed one by one. They are usually counts or scores: the discrete data of 4.1, with chance attached.
    • The values need not be positive or whole. Shoe sizes, or a gain of −4-4 dollars, are fine.
    • The list may never end, like the number of throws needed for a first six (section 3).

A quantity measured on a scale, such as a time or a mass, is continuous (4.9 and, at HL, 4.14). The test is count or measure:

QuantityTypeWhy
Emails received in one hourdiscretecounted: 0,1,2,…0, 1, 2, \dots
Time taken to download a filecontinuousmeasured: any value in an interval
A mark out of 40discreteonly listed values

Example: two fair four-sided dice, each numbered 1 to 4, are rolled. XX is the larger of the two scores (if they match, XX is that score). Figure 1 lays out the 16 equally likely outcomes in a sample space diagram. Each cell shows its value of XX.

Figure 1 · A random variable turns outcomes into numbers 1 1 2 2 3 3 4 4 1 2 3 4 2 2 3 4 3 3 3 4 4 4 4 4 first die second die x 1 2 3 4 cells 1 3 5 7 P(X = x) 1/16 3/16 5/16 7/16 amber: the 5 outcomes where X = 3 Two fair four-sided dice. X is the larger score. The 16 outcomes give only four values of X.
Figure 1 · A random variable turns outcomes into numbers
  • Sixteen outcomes collapse into four unequally likely values. Only (1,1)(1, 1) gives X=1X = 1. Five cells give X=3X = 3: (3,1)(3, 1), (3,2)(3, 2), (3,3)(3, 3), (1,3)(1, 3), (2,3)(2, 3).
  • That is the method of 4.5: count equally likely outcomes, then group them by value.

2Probability distributions

The probability distribution of a discrete random variable = every possible value with its probability. From Figure 1:

xx11223344
P(X=x)\mathrm{P}(X = x)116\dfrac{1}{16}316\dfrac{3}{16}516\dfrac{5}{16}716\dfrac{7}{16}

Figure 2 draws it as a bar chart with one bar per value.

Figure 2 · The probability distribution of X 0.1 0.2 0.3 0.4 0.5 x, the larger score P(X = x) 1 1/16 2 3/16 3 5/16 4 7/16 Every bar is a probability between 0 and 1, and the four bars add to 16/16 = 1.
Figure 2 · The probability distribution of X

Two rules hold for every probability distribution, and questions test both.

0≤P(X=x)≤10 \le \mathrm{P}(X = x) \le 1 for every xx, and ∑P(X=x)=1\sum \mathrm{P}(X = x) = 1. The total is 1 because XX takes exactly one of its values.

  • Here 116+316+516+716=1616=1\dfrac{1}{16} + \dfrac{3}{16} + \dfrac{5}{16} + \dfrac{7}{16} = \dfrac{16}{16} = 1. A total other than 1 means an error: find it first.
  • When all nn values are equally likely, each has probability 1n\dfrac{1}{n} and XX is called uniform. The score on one fair die is uniform. The larger score here is not.

Reading probabilities off a distribution. Add the probabilities of the values that qualify. For a discrete variable << and ≤\le differ, so list those values first.

P(X≥3)=P(X=3)+P(X=4)=516+716=34\mathrm{P}(X \ge 3) = \mathrm{P}(X = 3) + \mathrm{P}(X = 4) = \frac{5}{16} + \frac{7}{16} = \frac{3}{4}P(X<3)=P(X=1)+P(X=2)=416=14or 1−P(X≥3)\mathrm{P}(X < 3) = \mathrm{P}(X = 1) + \mathrm{P}(X = 2) = \frac{4}{16} = \frac{1}{4} \qquad \textcolor{#838c91}{\text{or }1 - \mathrm{P}(X \ge 3)}P(1<X≤3)=P(X=2)+P(X=3)=816=121 excluded, 3 included\mathrm{P}(1 < X \le 3) = \mathrm{P}(X = 2) + \mathrm{P}(X = 3) = \frac{8}{16} = \frac{1}{2} \qquad \textcolor{#838c91}{\text{1 excluded, 3 included}}

Conditional probability from 4.6 works on a distribution too. Given that XX is at least 3, the chance it is 4 is

P(X=4∣X≥3)=P(X=4)P(X≥3)=7/1612/16=712\mathrm{P}(X = 4 \mid X \ge 3) = \frac{\mathrm{P}(X = 4)}{\mathrm{P}(X \ge 3)} = \frac{7/16}{12/16} = \frac{7}{12}

The numerator is P(X=4 and X≥3)\mathrm{P}(X = 4 \text{ and } X \ge 3), which is just P(X=4)\mathrm{P}(X = 4).

Mode and median

  • The mode is the value with the greatest probability, here x=4x = 4.
  • The median is the first value at which the running total of probabilities reaches or passes 12\dfrac{1}{2}. P(X≤2)=416\mathrm{P}(X \le 2) = \dfrac{4}{16} falls short and P(X≤3)=916\mathrm{P}(X \le 3) = \dfrac{9}{16} is enough, so the median is 3.
  • The mean (section 5) is a third measure of centre.

3Building a distribution

Questions rarely hand you the table. The first marks are for making it: list the values, find each probability, tabulate, and check the total. Figure 1 was one route, a sample space. Here are three more.

From a tree without replacement

Example: a tray holds 9 seedlings, 3 white-flowered and 6 purple. Two are picked at random, one after the other, without replacement. Let XX be the number of white-flowered seedlings picked, so X∈{0,1,2}X \in \{0, 1, 2\}. The second branch has 8 seedlings left, so the denominators change.

P(X=0)=69×58=3072=512\mathrm{P}(X = 0) = \frac{6}{9} \times \frac{5}{8} = \frac{30}{72} = \frac{5}{12}P(X=1)=69×38+39×68=3672=12two routes, so two products added\mathrm{P}(X = 1) = \frac{6}{9} \times \frac{3}{8} + \frac{3}{9} \times \frac{6}{8} = \frac{36}{72} = \frac{1}{2} \qquad \textcolor{#838c91}{\text{two routes, so two products added}}P(X=2)=39×28=672=112\mathrm{P}(X = 2) = \frac{3}{9} \times \frac{2}{8} = \frac{6}{72} = \frac{1}{12}
xx001122
P(X=x)\mathrm{P}(X = x)512\dfrac{5}{12}612\dfrac{6}{12}112\dfrac{1}{12}
  • A common denominator makes the check quick: 1212=1\dfrac{12}{12} = 1.
  • The usual slip is to record one route for X=1X = 1 and then wonder why the total is short.

From observed frequencies

  • Example: a survey of 40 households records the number of cars.
    • 6 have none, 18 have one, 12 have two, 4 have three.
    • Dividing each frequency by 40 gives a model for a household chosen at random.
xx00112233
P(X=x)\mathrm{P}(X = x)0.150.150.450.450.30.30.10.1

When the values never stop

  • Example: a learner driver passes the test with probability 0.3 at each attempt. XX is the number of attempts up to and including the first pass. XX can be 1,2,3,…1, 2, 3, \dots with no largest value, and P(X=x)=0.7x−1×0.3\mathrm{P}(X = x) = 0.7^{x-1} \times 0.3 (x−1x - 1 fails, then a pass).
    • For P(X≤3)\mathrm{P}(X \le 3), add three terms, 0.3+0.21+0.147=0.6570.3 + 0.21 + 0.147 = 0.657. Or use the complement, 1−0.73=0.6571 - 0.7^{3} = 0.657.
    • The infinitely many probabilities still add to 1. That is the sum to infinity of a geometric series (1.8).

4Distributions with an unknown constant

The guide says a distribution will be given as a table or a formula. A usual first part puts an unknown in it. One fact finds it: the probabilities add to 1.

From a formula. Example: a random variable has P(X=x)=k(x2+2)\mathrm{P}(X = x) = k\left(x^{2}+2\right) for x∈{0,1,2,3}x \in \{0, 1, 2, 3\}. Find kk.

P(X=0)+P(X=1)+P(X=2)+P(X=3)=1\mathrm{P}(X = 0) + \mathrm{P}(X = 1) + \mathrm{P}(X = 2) + \mathrm{P}(X = 3) = 1k(0+2)+k(1+2)+k(4+2)+k(9+2)=1k(0+2) + k(1+2) + k(4+2) + k(9+2) = 12k+3k+6k+11k=12k + 3k + 6k + 11k = 122k=1, so k=12222k = 1\text{, so } k = \frac{1}{22}
  • Write each term, as here: the method mark is for showing every value substituted.
  • The distribution is 222,322,622,1122\dfrac{2}{22}, \dfrac{3}{22}, \dfrac{6}{22}, \dfrac{11}{22}, drawn in Figure 3.
Figure 3 · A distribution given by a formula 0.1 0.2 0.3 0.4 0.5 0.6 x P(X = x) 0 2/22 1 3/22 2 6/22 3 11/22 P(X = x) = (x² + 2)/22 for x = 0, 1, 2, 3. The constant k = 1/22 makes the bars add to 1.
Figure 3 · A distribution given by a formula
P(X≥2)=622+1122=1722\mathrm{P}(X \ge 2) = \frac{6}{22} + \frac{11}{22} = \frac{17}{22}

From a table. Collect the unknown terms, move the known ones across.

xx1122334455
P(X=x)\mathrm{P}(X = x)0.10.12m2m0.20.2mm0.10.1
  • Then 0.1+2m+0.2+m+0.1=10.1 + 2m + 0.2 + m + 0.1 = 1, so 3m=0.63m = 0.6 and m=0.2m = 0.2.
  • Always substitute back. The probabilities are 0.1,0.4,0.2,0.2,0.10.1, 0.4, 0.2, 0.2, 0.1, each between 0 and 1, total 1. A value of the unknown that pushes any probability below 0 or above 1 is impossible.

A quadratic in the unknown. When the table has both tt and t2t^{2}, the sum-to-1 equation is quadratic and has two roots. The extra mark is for rejecting one with a reason.

xx00112233
P(X=x)\mathrm{P}(X = x)0.350.353t23t^{2}tt0.330.33
0.35+3t2+t+0.33=10.35 + 3t^{2} + t + 0.33 = 13t2+t−0.32=0a "show that" part often gives this line3t^{2} + t - 0.32 = 0 \qquad \textcolor{#838c91}{\text{a "show that" part often gives this line}}t=−1±1+3.846=−1±2.26, so t=0.2 or t=−815t = \frac{-1 \pm \sqrt{1 + 3.84}}{6} = \frac{-1 \pm 2.2}{6}\text{, so } t = 0.2 \text{ or } t = -\frac{8}{15}
  • t=−815t = -\frac{8}{15} would make P(X=2)=t\mathrm{P}(X = 2) = t negative, which no probability can be, so t=0.2t = 0.2.
  • Name the probability that fails; "it does not work" earns nothing.
  • The probabilities are 0.35,0.12,0.2,0.330.35, 0.12, 0.2, 0.33, total 1. Carry only t=0.2t = 0.2 forward.

A range for the unknown. Every probability must lie between 0 and 1, and that can limit the unknown.

Example: P(X=1)=0.4\mathrm{P}(X = 1) = 0.4, P(X=2)=q\mathrm{P}(X = 2) = q and P(X=3)=0.6−q\mathrm{P}(X = 3) = 0.6 - q. Then q≥0q \ge 0 and 0.6−q≥00.6 - q \ge 0, so 0≤q≤0.60 \le q \le 0.6. The mean, using section 5, is

E(X)=0.4+2q+3(0.6−q)=2.2−q\mathrm{E}(X) = 0.4 + 2q + 3(0.6 - q) = 2.2 - q

so E(X)\mathrm{E}(X) falls as qq rises, from 2.2 at q=0q = 0 down to 1.6 at q=0.6q = 0.6. A question asking for the greatest possible value of E(X)\mathrm{E}(X) wants the end of that range: 2.22.2, when q=0q = 0.

5Expected value

Roll the two four-sided dice 1600 times. By the expected-number rule of 4.5 you would expect:

  • X=1X = 1 about 1600×116=1001600 \times \dfrac{1}{16} = 100 times
  • X=2X = 2 about 300 times
  • X=3X = 3 about 500 times
  • X=4X = 4 about 700 times

The mean of those 1600 values is

1×100+2×300+3×500+4×7001600=50001600=3.125\frac{1 \times 100 + 2 \times 300 + 3 \times 500 + 4 \times 700}{1600} = \frac{5000}{1600} = 3.125

Each value is weighted by how often it occurs, which is its probability. The 1600 cancels. That is the definition.

E(X)=∑x P(X=x)\boldsymbol{\mathrm{E}(X) = \sum x\,\mathrm{P}(X = x)}: multiply each value by its probability, and add. This is the expected value, or mean, of XX.

E(X)=1×116+2×316+3×516+4×716=1+6+15+2816=5016=258=3.125\begin{aligned}\mathrm{E}(X) &= 1 \times \frac{1}{16} + 2 \times \frac{3}{16} + 3 \times \frac{5}{16} + 4 \times \frac{7}{16} \\[6pt] &= \frac{1 + 6 + 15 + 28}{16} \\[6pt] &= \frac{50}{16} = \frac{25}{8} = 3.125\end{aligned}

Three facts about E(X)\mathrm{E}(X) clear up most confusion.

  • It is a long-run average, not a forecast for one trial. One roll gives 1, 2, 3 or 4. Over many rolls the average settles near 3.125.
  • It need not be a value XX can take. Nobody rolls 3.125.
  • It is the balance point. Picture each bar in Figure 4 as a weight on a beam.
    • It sits at its xx and is as heavy as its probability. The beam balances at E(X)\mathrm{E}(X).
    • The bars lean towards 4, so it sits above the middle value 2.5.
Figure 4 · E(X) is where the distribution balances 0.1 0.2 0.3 0.4 0.5 x, the larger score P(X = x) 1 1/16 2 3/16 3 5/16 4 7/16 E(X) = 3.125 Treat each bar as a weight on a beam. The beam balances at E(X) = 25/8 = 3.125, which is not a value X can take. It is the long-run average of many observations.
Figure 4 · E(X) is where the distribution balances

For the formula distribution of section 4:

E(X)=0×222+1×322+2×622+3×1122=0+3+12+3322=4822=2411≈2.18\begin{aligned}\mathrm{E}(X) &= 0 \times \frac{2}{22} + 1 \times \frac{3}{22} + 2 \times \frac{6}{22} + 3 \times \frac{11}{22} \\[6pt] &= \frac{0 + 3 + 12 + 33}{22} = \frac{48}{22} = \frac{24}{11} \approx 2.18\end{aligned}
  • For the car survey of section 3, E(X)=0+0.45+0.6+0.3=1.35\mathrm{E}(X) = 0 + 0.45 + 0.6 + 0.3 = 1.35 cars per household.
  • So 200 households would be expected to own about 200×1.35=270200 \times 1.35 = 270 cars. Multiply by the number of trials to turn a mean into a total.

Using E(X)\mathrm{E}(X) to find a second unknown. Two unknowns need two equations: the total is 1, and E(X)\mathrm{E}(X) is given.

xx11223344
P(X=x)\mathrm{P}(X = x)0.10.1aabb0.30.3

Given E(X)=2.9\mathrm{E}(X) = 2.9, find aa and bb.

0.1+a+b+0.3=1, so a+b=0.6probabilities add to 10.1 + a + b + 0.3 = 1\text{, so } a + b = 0.6 \qquad \textcolor{#838c91}{\text{probabilities add to 1}}1(0.1)+2a+3b+4(0.3)=2.9, so 2a+3b=1.6E(X)=2.91(0.1) + 2a + 3b + 4(0.3) = 2.9\text{, so } 2a + 3b = 1.6 \qquad \textcolor{#838c91}{\mathrm{E}(X) = 2.9}substitute a=0.6−b: 1.2−2b+3b=1.6, so b=0.4\text{substitute } a = 0.6 - b\text{: } 1.2 - 2b + 3b = 1.6\text{, so } b = 0.4a=0.6−0.4=0.2a = 0.6 - 0.4 = 0.2check: E(X)=0.1+0.4+1.2+1.2=2.9\text{check: } \mathrm{E}(X) = 0.1 + 0.4 + 1.2 + 1.2 = 2.9
  • On Paper 1 solve the pair by hand. On Paper 2 the GDC's equation solver is quicker, but write both equations first: they carry the method marks.
  • The GDC can also sum the products from two lists (values, probabilities). Write the substitution anyway, so a mistyped entry still earns method marks.

A payoff that depends on XX

  • For the mean of a quantity worked out from XX, add a row of the new values (a charge of $5\$5 per item plus a $2\$2 fee, say).
  • Then use ∑(value)×P(X=x)\sum (\text{value}) \times \mathrm{P}(X = x).
  • The shortcut E(aX+b)=a E(X)+b\mathrm{E}(aX + b) = a\,\mathrm{E}(X) + b and the variance Var⁡(X)\operatorname{Var}(X) are HL content (4.14). At SL the tabulated route is all you need.

6Applications: games, fairness and decisions

The guide's application is games of chance. Let XX be the player's gain: what they receive minus what they paid. E(X)\mathrm{E}(X) is then the average gain per game over many games.

A game is fair when E(X)=0\mathrm{E}(X) = 0, where XX is the player's gain. If E(X)<0\mathrm{E}(X) < 0 the organiser profits in the long run; if E(X)>0\mathrm{E}(X) > 0 the player does.

A worked game. Example: at a school fair a player pays $4 and rolls one fair die. A 6 wins $12, a 4 or a 5 wins $4, and anything else wins nothing. Is the game fair?

  • Work in gains, not prizes, because the $4 is paid every time.
    • A 6 gives 12−4=$812 - 4 = \$8.
    • A 4 or 5 gives 4−4=$04 - 4 = \$0.
    • A 1, 2 or 3 gives −$4-\$4.
gain, x ($)x\ (\$)−4-40088
P(X=x)\mathrm{P}(X = x)12\dfrac{1}{2}13\dfrac{1}{3}16\dfrac{1}{6}
E(X)=−4×12+0×13+8×16=−2+0+43=−23≈−0.67\begin{aligned}\mathrm{E}(X) &= -4 \times \frac{1}{2} + 0 \times \frac{1}{3} + 8 \times \frac{1}{6} \\[6pt] &= -2 + 0 + \frac{4}{3} \\[6pt] &= -\frac{2}{3} \approx -0.67\end{aligned}

The expected gain is −$0.67-\$0.67, so the game is not fair. A player loses about 67 cents a game on average, and the organiser keeps it. Figure 5(a) shows the balance point below zero.

Making it fair. What prize pp for a 6 would make the game fair? The gain on a 6 becomes p−4p - 4. The other gains stay.

E(X)=−4×12+0×13+(p−4)×16=0\mathrm{E}(X) = -4 \times \frac{1}{2} + 0 \times \frac{1}{3} + (p - 4) \times \frac{1}{6} = 0p−46=2\frac{p - 4}{6} = 2p−4=12, so p=16p - 4 = 12\text{, so } p = 16

A $16 prize makes the game fair. Figure 5(b) shows the gain on a 6 at $12 and the beam balancing at 0.

Figure 5 · The player's gain, before and after the prize is changed (a) Prize $12 for a six 0.2 0.4 0.6 gain, x ($) P(X = x) −4 1/2 0 1/3 8 1/6 E(X) = −2/3 (b) Prize $16 for a six 0.2 0.4 0.6 gain, x ($) P(X = x) −4 1/2 0 1/3 12 1/6 E(X) = 0 Stake $4. Left: a six wins $12, so E(gain) = −$0.67 and the organiser profits. Right: a six wins $16, the gain on a six becomes $12, and E(gain) = 0: a fair game.
Figure 5 · The player's gain, before and after the prize is changed
  • Or keep the prizes and change the stake. The expected prize is 12×16+4×26=2+43=10312 \times \dfrac{1}{6} + 4 \times \dfrac{2}{6} = 2 + \dfrac{4}{3} = \dfrac{10}{3}. A stake of $3.33\$3.33 (3 s.f.) makes the game fair.
  • That is because a fair game charges exactly the expected prize.

An unknown probability

  • The unknown can sit in the prize, the stake or a probability. The method never changes: write E(X)\mathrm{E}(X) with the unknown in it and set it equal to 0.
  • Example: in a card game a player's gain is $10\$10 with probability ww and −$2-\$2 otherwise. Fair means 10w−2(1−w)=010w - 2(1 - w) = 0, so 12w=212w = 2 and w=16w = \dfrac{1}{6}.
  • Casinos and lotteries never run fair games. E(X)<0\mathrm{E}(X) < 0 for the player is how they cover costs and profit.
    • Whether that is "fair" in the everyday sense is a TOK question; mathematically it is not.

Pricing risk. Example (invented figures): an electronics shop sells a two-year warranty for $45. From its records, a warranty leads to a $200 repair with probability 0.10, a $480 replacement with probability 0.03, and no claim otherwise. Let YY be the shop's profit on one warranty.

profit, y ($)y\ (\$)454545−200=−15545 - 200 = -15545−480=−43545 - 480 = -435
P(Y=y)\mathrm{P}(Y = y)0.870.870.100.100.030.03
E(Y)=45(0.87)+(−155)(0.10)+(−435)(0.03)=39.15−15.5−13.05=10.6\begin{aligned}\mathrm{E}(Y) &= 45(0.87) + (-155)(0.10) + (-435)(0.03) \\[6pt] &= 39.15 - 15.5 - 13.05 \\[6pt] &= 10.6\end{aligned}
  • The shop expects $10.60 per warranty, about 2000×10.6=$21,2002000 \times 10.6 = \$21{,}200 across 2000 warranties before running costs.
  • The 0.87 is 1−0.10−0.031 - 0.10 - 0.03: the total must be 1 even when a question states only two probabilities.

Choosing between two options

  • Example: a market stall can trade at Site A or Site B.
    • Site A. A day's profit of $800 with probability 0.5, $200 with probability 0.3, and a loss of $400 with probability 0.2.
    • Site B. $450 with probability 0.8 and nothing otherwise.
  • Then E(A)=400+60−80=380\mathrm{E}(A) = 400 + 60 - 80 = 380 and E(B)=360\mathrm{E}(B) = 360. On expected profit A is better.
    • Expected value ignores risk, so say so: A can lose $400 in a day and B never loses.

Practice questions

28 questions on this note, from easy to hard. Each one you get right lights a star of this topic's constellation.