S1.5 Discrete random variables
⤓ Presentation⤓ PowerPointPresentation: opens offline in any browser, simulations live. PowerPoint: editable.
Statistics 1 (AS). Basic probability comes from S1.3 and is used here without re-teaching; the binomial and Poisson distributions and continuous random variables belong to S2, and the Normal distribution is S1.6.
What this page covers
7 points
- Discrete random variables and their probability distributions, given as a table, a formula \(p(x)\) or built from an experiment
- Using \(\sum\text{P}(X=x)=1\) to find an unknown constant
- The cumulative distribution function \(F(x)=\text{P}(X\le x)\), and moving between \(F(x)\) and \(p(x)\)
- \(\text{E}(X)\), \(\text{E}(X^2)\), \(\text{E}(g(X))\) and \(\text{Var}(X)\), with the standard deviation
- \(\text{E}(aX+b)=a\text{E}(X)+b\) and \(\text{Var}(aX+b)=a^2\text{Var}(X)\)
- Finding unknown probabilities from conditions such as a given mean
- The discrete uniform distribution: its mean and variance, and uniform distributions that do not start at 1
In one minute
6 points
- A discrete random variable \(X\) takes separate values \(x\) with probabilities \(\text{P}(X=x)\); these probabilities are all between 0 and 1 and add to 1, and everything on this page is a sum built from that list.
- The cumulative distribution function is \(F(x)=\text{P}(X\le x)\). For whole-number values, \(\text{P}(X=x)=F(x)-F(x-1)\).
- Mean: \(\text{E}(X)=\sum x\,\text{P}(X=x)\). More generally \(\text{E}(g(X))=\sum g(x)\,\text{P}(X=x)\).
- Variance: \(\text{Var}(X)=\text{E}(X^2)-[\text{E}(X)]^2\); the standard deviation is its square root.
- Linear change: \(\text{E}(aX+b)=a\text{E}(X)+b\) and \(\text{Var}(aX+b)=a^2\text{Var}(X)\): adding a constant shifts the mean but not the spread.
- Discrete uniform on \(1,2,\ldots,n\): each value has probability \(\tfrac1n\), mean \(\tfrac{n+1}{2}\), variance \(\tfrac{n^2-1}{12}\).
Contents
14 sections
- What is a discrete random variable?
- How do you work with a probability function p(x)?
- What does the cumulative distribution function F(x) tell you?
- How do you find E(X), E(X²) and E(g(X))?
- How do you find the variance and standard deviation?
- What happens to the mean and variance of aX + b?
- How do you find unknown probabilities from given conditions?
- What is the discrete uniform distribution?
- Exam tips for S1.5
- Common misconceptions
- How this topic connects
- Key formulae
- Check your understanding
- Specification checklist
What is a discrete random variable?
Capital letters name the variable (\(X\), \(Y\)); lower-case letters name a value it can take (\(x\), \(y\)). \(\text{P}(X=3)\) means "the probability that \(X\) takes the value 3". A distribution can be a table, a formula \(p(x)=\text{P}(X=x)\), or a vertical line diagram. Counts (heads, calls, a score on a dice) give discrete variables; measurements such as a time or a mass are continuous and are treated differently in S2.
To build a distribution from an experiment, list the equally likely outcomes (a sample-space grid or a tree), work out the value of \(X\) for each, and collect the probabilities.
Two fair spinners, each numbered 1, 2, 3, 4, are spun. The random variable \(X\) is the larger of the two scores (if the scores are equal, \(X\) is that score). (a) Show that \(\text{P}(X=3)=\tfrac{5}{16}\). (b) Find the probability distribution of \(X\), and show that it can be written as \(\text{P}(X=x)=\dfrac{2x-1}{16}\). (c) Find \(\text{P}(X\ge3)\).
(a) (1, 3), (2, 3), (3, 3), (3, 2), (3, 1): 5 of the 16 equally likely outcomes, so \(\text{P}(X=3)=\tfrac{5}{16}\) as required.
(b) Counting cells for each value:
| \(x\) | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| \(\text{P}(X=x)\) | \(\tfrac1{16}\) | \(\tfrac3{16}\) | \(\tfrac5{16}\) | \(\tfrac7{16}\) |
1, 3, 5, 7 are \(2x-1\) for \(x=1,2,3,4\), so \(\text{P}(X=x)=\dfrac{2x-1}{16}\); check: \(\dfrac{1+3+5+7}{16}=1\).
(c) \(\text{P}(X\ge3)=\tfrac{5}{16}+\tfrac{7}{16}=\) \(\tfrac34\).
How do you work with a probability function p(x)?
A probability function gives \(\text{P}(X=x)\) as a formula, often with an unknown constant \(k\) and sometimes in pieces for different ranges of \(x\). Outside the listed values, \(p(x)=0\). The method is always the same: write out every probability in terms of \(k\) first, then use \(\sum p(x)=1\) to find \(k\).
The mode is the value with the largest probability, visible at a glance on a line diagram. Probabilities of events are sums: \(\text{P}(X\text{ is odd})\) adds the probabilities of the odd values. Conditional probability works as in S1.3: \(\text{P}(A\mid B)=\dfrac{\text{P}(A\cap B)}{\text{P}(B)}\).
The discrete random variable \(X\) has probability function \(p(x)=kx\) for \(x=1,2,3\) and \(p(x)=k(8-x)\) for \(x=4,5\), where \(k\) is a constant; \(p(x)=0\) otherwise. (a) Find the value of \(k\). (b) Find \(\text{P}(X\text{ is odd})\). (c) Find \(\text{P}(X=4\mid X\ge3)\).
(a) \(k+2k+3k+4k+3k=13k=1\Rightarrow\) \(k=\tfrac{1}{13}\).
(b) Odd values 1, 3, 5: \(\dfrac{1+3+3}{13}=\) \(\tfrac{7}{13}\).
(c) \(X=4\) is inside \(X\ge3\), so the intersection is just \(X=4\): \(\dfrac{\text{P}(X=4)}{\text{P}(X\ge3)}=\dfrac{4/13}{(3+4+3)/13}=\dfrac{4}{10}=\) \(\tfrac25\).
What does the cumulative distribution function F(x) tell you?
\(F\) is a running total of the probabilities. It never decreases and reaches 1 at the largest value of \(X\). Plotted, it is a step graph: flat between values, jumping up at each value by exactly \(\text{P}(X=x)\). That picture gives every rule you need:
- For whole-number values, \(\text{P}(X=x)=F(x)-F(x-1)\); the first probability is just \(F\) at the smallest value.
- Ranges come straight from \(F\): \(\text{P}(a<X\le b)=F(b)-F(a)\). Convert other inequalities first: \(\text{P}(X<4)=\text{P}(X\le3)=F(3)\) and \(\text{P}(X\ge2)=1-F(1)\).
- If \(F\) is given as a formula with a constant, use \(F(\text{largest value})=1\) to find it.
The discrete random variable \(X\) takes the values 1, 2, 3, 4 and has cumulative distribution function \(F(x)=\dfrac{2^x+k}{20}\) for \(x=1,2,3,4\), where \(k\) is a constant. (a) Find \(k\). (b) Find \(\text{P}(X=3)\). (c) Find the probability distribution of \(X\). (d) Find \(\text{P}(1<X\le3)\).
(a) \(F\) at the largest value is 1: \(F(4)=\dfrac{16+k}{20}=1\Rightarrow\) \(k=4\).
(b) \(\text{P}(X=3)=F(3)-F(2)=\dfrac{12}{20}-\dfrac{8}{20}=\) \(\tfrac15\).
(c) \(F(1)=\tfrac{6}{20}\), \(F(2)=\tfrac{8}{20}\), \(F(3)=\tfrac{12}{20}\), \(F(4)=1\); take differences:
| \(x\) | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| \(\text{P}(X=x)\) | 0.3 | 0.1 | 0.2 | 0.4 |
(d) \(\text{P}(1<X\le3)=F(3)-F(1)=\tfrac{12}{20}-\tfrac{6}{20}=\) 0.3 (check: \(0.1+0.2\)).
Reading \(F(3)\) as \(\text{P}(X=3)\). \(F(3)=0.6\) is the probability that \(X\) is at most 3; the probability that \(X\) is exactly 3 is the jump, \(F(3)-F(2)=0.2\).
How do you find E(X), E(X²) and E(g(X))?
\(\text{E}(X)\) is a long-run average over many observations; it need not be a value \(X\) can actually take. Think of the probabilities as weights on a beam: \(\text{E}(X)\) is the balance point of the line diagram. Lay the work out in rows: \(x\), \(\text{P}(X=x)\), \(x\text{P}(X=x)\), \(x^2\text{P}(X=x)\), and add the last two rows. For any function \(g\), apply \(g\) to each value, not to the mean: in general \(\text{E}(g(X))\ne g(\text{E}(X))\).
The random variable \(X\) has the probability distribution below. Find (a) \(\text{E}(X)\), (b) \(\text{E}(X^2)\), (c) \(\text{E}\!\left(\dfrac{1}{X+2}\right)\), and compare (c) with \(\dfrac{1}{\text{E}(X)+2}\).
| \(x\) | −1 | 0 | 1 | 2 | 4 |
|---|---|---|---|---|---|
| \(\text{P}(X=x)\) | 0.2 | 0.1 | 0.3 | 0.25 | 0.15 |
(a) \((-1)(0.2)+0(0.1)+1(0.3)+2(0.25)+4(0.15)=-0.2+0+0.3+0.5+0.6=\) 1.2
(b) \(1(0.2)+0+1(0.3)+4(0.25)+16(0.15)=0.2+0.3+1+2.4=\) 3.9
(c) \(g(x)=\dfrac{1}{x+2}\) takes the values \(1,\tfrac12,\tfrac13,\tfrac14,\tfrac16\): \(0.2+0.05+0.1+0.0625+0.025=\) 0.4375. But \(\dfrac{1}{1.2+2}=0.3125\), which is not 0.4375: the function must be applied to each value before averaging.
How do you find the variance and standard deviation?
Variance measures spread about the mean, in squared units; the standard deviation is back in the units of \(X\). Find \(\text{E}(X^2)\) and \(\text{E}(X)\) first, then subtract, keeping exact values until the last line. A variance can never be negative: a negative answer usually means you forgot to square the mean. With the standard deviation you can describe a range such as "within one standard deviation of the mean" and find its probability from the table.
For the random variable \(X\) in Worked example 4, (a) find \(\text{Var}(X)\), (b) find the standard deviation of \(X\), (c) find \(\text{P}(\mu-\sigma<X<\mu+\sigma)\).
(a) \(\text{Var}(X)=3.9-1.2^2=3.9-1.44=\) 2.46
(b) \(\sigma=\sqrt{2.46}=1.5684\ldots=\) 1.57 (3 s.f.)
(c) \(\mu\pm\sigma=1.2\pm1.5684\ldots\), from −0.37 to 2.77. The values inside are 0, 1, 2: \(0.1+0.3+0.25=\) 0.65.
Check by the second form: \(\sum(x-1.2)^2\text{P}(X=x)=0.968+0.144+0.012+0.16+1.176=2.46\).
What happens to the mean and variance of aX + b?
Adding \(b\) moves every value by the same amount, so it changes the mean but not the spread. Multiplying by \(a\) stretches every gap by \(a\), so the variance gains a factor \(a^2\). The sign of \(a\) does not matter for the variance: \(\text{Var}(4-2X)=(-2)^2\text{Var}(X)=4\text{Var}(X)\). The same rules work backwards (given \(\text{E}(Y)\) and \(\text{Var}(Y)\) for \(Y=aX+b\), solve for the unknowns), and they match the coding rules for data in S1.2. A rearrangement that is often needed: \(\text{E}(X^2)=\text{Var}(X)+[\text{E}(X)]^2\).
In a game, the number of points \(X\) that a player scores has \(\text{E}(X)=4\) and \(\text{Var}(X)=2.25\). The prize, in pence, is \(Y=20X-30\). (a) Find \(\text{E}(Y)\) and the standard deviation of \(Y\). (b) Find \(\text{E}(X^2)\). (c) A second scoring rule uses \(T=aX+b\), where \(a>0\) and \(b\) are constants, chosen so that \(\text{E}(T)=50\) and \(\text{Var}(T)=9\). Find \(a\) and \(b\).
(a) \(\text{E}(Y)=20\times4-30=\) 50p; \(\text{Var}(Y)=20^2\times2.25=900\), so s.d. = 30p.
(b) \(\text{E}(X^2)=\text{Var}(X)+[\text{E}(X)]^2=2.25+16=\) 18.25
(c) Variance first (it involves \(a\) only): \(a^2\times2.25=9\Rightarrow a^2=4\Rightarrow a=2\) (since \(a>0\)). Then \(2\times4+b=50\Rightarrow b=42\). \(a=2,\ b=42\).
How do you find unknown probabilities from given conditions?
Each piece of information gives an equation. "Probabilities add to 1" is always one; a given \(\text{E}(X)\), a given value of \(F\) or a stated relationship (such as \(\text{P}(X=2)=2\text{P}(X=1)\)) give others. Two unknowns need two equations: solve them simultaneously, then check that every probability lies between 0 and 1. Once the table is complete, carry on as usual.
The random variable \(X\) has the probability distribution below, where \(p\) and \(q\) are constants. Given that \(\text{E}(X)=3.25\), (a) find \(p\) and \(q\), (b) find \(\text{Var}(X)\), (c) find \(\text{Var}(4-2X)\), (d) find \(\text{P}(X\le3)\).
| \(x\) | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| \(\text{P}(X=x)\) | 0.1 | \(p\) | \(q\) | 0.3 | 0.2 |
(a) Sum = 1: \(0.1+p+q+0.3+0.2=1\Rightarrow p+q=0.4\). Mean: \(0.1+2p+3q+1.2+1.0=3.25\Rightarrow2p+3q=0.95\). Subtract 2 × the first: \(q=0.95-0.8=0.15\), so \(p=0.25,\ q=0.15\).
(b) \(\text{E}(X^2)=0.1+4(0.25)+9(0.15)+16(0.3)+25(0.2)=12.25\); \(\text{Var}(X)=12.25-3.25^2=12.25-10.5625=\) 1.6875.
(c) \(a=-2\), so the factor is \((-2)^2=4\): \(\text{Var}(4-2X)=4\times1.6875=\) 6.75.
(d) \(\text{P}(X\le3)=0.1+0.25+0.15=\) 0.5.
Write the two equations on separate lines with the conditions they come from ("sum = 1", "mean = 3.25"). If you get a negative probability or one bigger than 1, recheck the equations rather than carrying on.
What is the discrete uniform distribution?
Where the formulae come from. The mean uses the arithmetic series sum from P2: \(\text{E}(X)=\tfrac1n(1+2+\cdots+n)=\tfrac1n\times\tfrac{n(n+1)}{2}=\tfrac{n+1}{2}\). For the variance, \(\sum r^2=\tfrac16n(n+1)(2n+1)\) gives \(\text{E}(X^2)=\tfrac{(n+1)(2n+1)}{6}\), so \(\text{Var}(X)=\tfrac{(n+1)(2n+1)}{6}-\tfrac{(n+1)^2}{4}=\tfrac{(n+1)(n-1)}{12}\). For a fair six-sided dice (\(n=6\)): mean \(\tfrac72=3.5\) and variance \(\tfrac{35}{12}\).
The formulae are for values 1 to \(n\). For other equally spaced values, write \(X\) as \(aU+b\) with \(U\) uniform on \(1,\ldots,n\). A whole number chosen at random from 5, 6, …, 14 is \(X=U+4\) with \(U\) uniform on \(1,\ldots,10\), so \(\text{E}(X)=5.5+4=9.5\) and \(\text{Var}(X)=\tfrac{10^2-1}{12}=8.25\), unchanged by the shift.
A fair spinner has \(n\) equal sectors numbered \(1,2,\ldots,n\). The score \(X\) on one spin has a discrete uniform distribution, and \(\text{Var}(X)=10\). (a) Find the value of \(n\). (b) Write down \(\text{E}(X)\) and find \(\text{P}(X>\text{E}(X))\). (c) A player's points are \(Y=3X-2\). Find \(\text{E}(Y)\) and \(\text{Var}(Y)\). (d) Find \(\text{P}(Y>20)\). (e) The spinner is spun twice. Find the probability that both scores are greater than \(\text{E}(X)\).
(a) \(\dfrac{n^2-1}{12}=10\Rightarrow n^2=121\Rightarrow\) \(n=11\) (\(n>0\)).
(b) \(\text{E}(X)=\dfrac{11+1}{2}=6\); \(X>6\) for 7, 8, 9, 10, 11, so \(\text{P}=\tfrac{5}{11}\).
(c) \(\text{E}(Y)=3\times6-2=\) 16; \(\text{Var}(Y)=3^2\times10=\) 90.
(d) \(3X-2>20\Rightarrow X>\tfrac{22}{3}=7.33\ldots\), so \(X\ge8\): values 8, 9, 10, 11, \(\text{P}=\tfrac{4}{11}\). \(X\) must be a whole number, so \(X>7.33\ldots\) means \(X\ge8\), not \(X\ge7\).
(e) Independent spins: \(\left(\tfrac{5}{11}\right)^2=\) \(\tfrac{25}{121}\).
Exam tips for S1.5
After finding a constant or filling in a table, add the probabilities and confirm the total is exactly 1. It takes seconds and catches most slips before they spread into the mean and variance.
Write \(\text{E}(X)\) and \(\text{E}(X^2)\) as sums of products, such as \((-1)(0.2)+0(0.1)+\cdots\), before giving the total. The method is then visible even if a product is mistyped on the calculator.
For a whole-number variable, write "\(X<4\)" as "\(X\le3\)" and "\(X\ge2\)" as "\(1-\text{P}(X\le1)\)" before using \(F\). Listing the values included avoids the off-by-one slip.
\(\text{Var}(5-3X)=9\text{Var}(X)\), never \(-3\text{Var}(X)+5\). A standard deviation scales by \(|a|\).
The results \(\tfrac{n+1}{2}\) and \(\tfrac{n^2-1}{12}\) are for \(1,2,\ldots,n\). For values such as 5 to 14 or 2, 4, …, 20, write the variable as \(aU+b\) first.
Common misconceptions
| Misconception | Why it is wrong | Correct idea |
|---|---|---|
| \(\text{E}(X)\) must be one of the values \(X\) can take. | It is a long-run average, a balance point. | In Worked example 4, \(\text{E}(X)=1.2\) although \(X\) only takes −1, 0, 1, 2, 4. |
| \(\text{Var}(X)=\text{E}(X^2)\). | That ignores where the distribution is centred. | \(\text{Var}(X)=\text{E}(X^2)-[\text{E}(X)]^2\). |
| \(\text{E}(g(X))=g(\text{E}(X))\), e.g. \(\text{E}(X^2)=[\text{E}(X)]^2\). | Averaging then applying \(g\) is not the same as applying \(g\) then averaging. | Apply \(g\) to every value: \(\sum g(x)\text{P}(X=x)\). For \(x^2\) the two agree only when the variance is 0. |
| \(\text{Var}(aX+b)=a\text{Var}(X)+b\). | Adding a constant does not change the spread, and stretching by \(a\) multiplies squared distances by \(a^2\). | \(\text{Var}(aX+b)=a^2\text{Var}(X)\). |
| \(F(x)\) is the probability that \(X\) equals \(x\). | \(F\) is cumulative: it includes all smaller values too. | \(\text{P}(X=x)=F(x)-F(x-1)\). |
| A random whole number from 5 to 14 has mean \(\tfrac{14+1}{2}=7.5\). | The formula \(\tfrac{n+1}{2}\) assumes the values start at 1. | Write \(X=U+4\) with \(U\) uniform on \(1,\ldots,10\): mean 9.5, variance 8.25. |
How this topic connects
S1.3 Probability and S1.2 Measures of location and dispersion
Building a distribution from an experiment uses sample spaces, trees, independence and conditional probability. \(\text{E}(X)\) and \(\text{Var}(X)\) are the mean and variance of a frequency distribution with probabilities in place of relative frequencies, and the rules for \(aX+b\) are the coding rules.
S2 The binomial and Poisson distributions
These are discrete distributions with formulae for \(p(x)\), for which \(\text{E}(X)\) and \(\text{Var}(X)\) reduce to \(np\), \(np(1-p)\) and \(\lambda\); continuous random variables replace sums with integrals.
P2 Series
The mean of the discrete uniform distribution uses the sum \(1+2+\cdots+n\) of an arithmetic series.
Key formulae
| Formula | Use | In the formulae list? |
|---|---|---|
| \(\sum\text{P}(X=x)=1\), \(0\le\text{P}(X=x)\le1\) | checking a distribution; finding an unknown constant | No – learn it |
| \(F(x_0)=\text{P}(X\le x_0)=\sum_{x\le x_0}\text{P}(X=x)\) | cumulative probabilities | No – learn it |
| \(\text{P}(X=x)=F(x)-F(x-1)\) | distribution from \(F\), whole-number values | No – derive it |
| \(\text{E}(X)=\sum x\,\text{P}(X=x)\) | mean | Yes |
| \(\text{E}(g(X))=\sum g(x)\,\text{P}(X=x)\) | \(\text{E}(X^2)\) and other expectations | Yes |
| \(\text{Var}(X)=\text{E}(X^2)-[\text{E}(X)]^2=\sum(x-\mu)^2\text{P}(X=x)\) | variance; \(\sigma=\sqrt{\text{Var}(X)}\) | Yes |
| \(\text{E}(aX+b)=a\text{E}(X)+b\) | mean of a linear function | No – learn it |
| \(\text{Var}(aX+b)=a^2\text{Var}(X)\) | variance of a linear function | No – learn it |
| Uniform on \(1,\ldots,n\): \(\text{P}(X=x)=\tfrac1n\), \(\text{E}(X)=\tfrac{n+1}{2}\), \(\text{Var}(X)=\tfrac{n^2-1}{12}\) | discrete uniform distribution | No – learn it |
Check your understanding
1. Can a discrete random variable have \(\text{P}(X=1)=0.6\) and \(\text{P}(X=2)=0.6\)?
No. The probabilities of all the values must add to 1, and these two alone add to 1.2.
2. \(\text{E}(X)=3\) and \(\text{Var}(X)=2\). Find \(\text{E}(X^2)\).
\(\text{E}(X^2)=\text{Var}(X)+[\text{E}(X)]^2=2+9=11\).
3. \(\text{Var}(X)=2\). Find \(\text{Var}(5-3X)\).
\((-3)^2\times2=18\). The 5 does not affect the spread, and the minus sign disappears when squared.
4. For a whole-number random variable, \(F(3)=0.55\) and \(F(4)=0.7\). Find \(\text{P}(X=4)\).
\(F(4)-F(3)=0.7-0.55=0.15\).
5. Find the mean and variance of the score on one roll of a fair six-sided dice.
Discrete uniform with \(n=6\): mean \(\tfrac72=3.5\), variance \(\tfrac{6^2-1}{12}=\tfrac{35}{12}\).
Specification checklist
- (S1 5.1) I can explain what a discrete random variable is and write its probability distribution as a table, as a probability function \(p(x)\) or as a line diagram.
- (S1 5.1) I can build a probability distribution from a simple experiment, and use the fact that the probabilities add to 1 to find an unknown constant.
- (S1 5.2) I can find the cumulative distribution function \(F(x)\) from \(p(x)\), and \(p(x)\) from \(F(x)\), including when \(F\) is given as a formula with a constant.
- (S1 5.2) I can use \(F(x)\) to find probabilities of ranges, converting strict and non-strict inequalities correctly.
- (S1 5.3) I can find \(\text{E}(X)\), \(\text{E}(X^2)\), \(\text{E}(g(X))\), \(\text{Var}(X)\) and the standard deviation from a distribution.
- (S1 5.3) I can use \(\text{E}(aX+b)=a\text{E}(X)+b\) and \(\text{Var}(aX+b)=a^2\text{Var}(X)\), forwards and backwards.
- (S1 5.3) I can set up and solve equations for unknown probabilities from given conditions such as the total and the mean.
- (S1 5.4) I can recognise a discrete uniform distribution, state and derive its mean and variance, and adapt them to values that do not start at 1.