Probability • Topic 3 of 3

Random Variables & Probability Distributions

A random variable $X$ is a rule that assigns a real number to each outcome of a random experiment — for example, the number of heads in two tosses, or the number of aces in a hand of cards. It converts messy outcomes into numbers we can average and compare. (In this chapter $X$ is always discrete: it takes a finite or countable list of values.)

Probability distribution

The probability distribution of $X$ lists each value $x_i$ together with its probability $p_i=P(X=x_i)$. It is a valid distribution exactly when

$$p_i\ge 0\quad\text{for all }i,\qquad \sum_i p_i=1.$$

This normalisation is the first thing to check, and the basis of every "find the value of $k$" question: write the distribution in terms of $k$, set the total to $1$, and solve.

Mean (expected value)

The mean or expectation of $X$ is the probability-weighted average of its values — the long-run average if the experiment were repeated many times:

$$E(X)=\mu=\sum_i x_i\,p_i.$$

Variance and standard deviation

The variance measures how spread out the values are about the mean. The defining form and the convenient computing form are:

$$\operatorname{Var}(X)=\sum_i (x_i-\mu)^2 p_i=\sum_i x_i^2\,p_i-\mu^2,\qquad \sigma=\text{SD}=\sqrt{\operatorname{Var}(X)}.$$

The computing form $\sum x_i^2 p_i-\mu^2$ ("mean of squares minus square of mean") is almost always faster in exams. Useful linear rules: $E(aX+b)=aE(X)+b$ and $\operatorname{Var}(aX+b)=a^2\operatorname{Var}(X)$ — a shift $b$ moves the mean but leaves the spread unchanged.

Bernoulli trials

A sequence of independent trials forms Bernoulli trials when (i) there is a fixed finite number $n$ of trials, (ii) each trial has only two outcomes — "success" or "failure", (iii) the trials are independent, and (iv) the success probability $p$ is the same in every trial. Tossing a coin $n$ times, or drawing $n$ items with replacement, are Bernoulli; drawing without replacement is not (the probability changes).

Binomial distribution

If $X$ counts the number of successes in $n$ Bernoulli trials with success probability $p$ (and $q=1-p$), then $X$ follows the binomial distribution:

$$P(X=r)=\binom{n}{r}p^{r}q^{\,n-r},\qquad r=0,1,2,\dots,n.$$

The factor $\binom{n}{r}$ counts the ways to place the $r$ successes among the $n$ trials, while $p^{r}q^{\,n-r}$ is the probability of any one such arrangement. The terms are exactly those of the expansion $(q+p)^n$, which is why they sum to $1$. Its mean and variance have compact forms:

$$E(X)=np,\qquad \operatorname{Var}(X)=npq,\qquad \text{SD}=\sqrt{npq}.$$

Note $\operatorname{Var}=npq< np=E(X)$ always (since $q<1$), a handy sanity check.

Deeper Insight — expectation is a weighted average, the binomial is just counting. Two ideas carry this whole topic. First, $E(X)=\sum x_i p_i$ is nothing more exotic than a weighted average — the same arithmetic as a weighted mark, with probabilities as the weights; variance then asks "how far, on average squared, do values sit from that centre". Second, the intimidating binomial formula is the multiplication principle and combinations from Class 11 wearing new clothes: pick which $r$ of the $n$ trials succeed ($\binom{n}{r}$ ways) and multiply by the probability of one such pattern ($p^r q^{n-r}$). If you can see $(q+p)^n$ behind the distribution, the result $\sum P(X=r)=1$ and the shortcuts $np$ and $npq$ stop being facts to memorise and become things you understand.

Bar chart of the probability distribution of the number of heads in three coin tosses, with probabilities one-eighth, three-eighths, three-eighths, one-eighth summing to one Probability Distribution: X = heads in 3 tosses P(X) X (number of heads) 0 1/8 2/8 3/8 1/8 3/8 3/8 1/8 0 1 2 3 ∑ P(X) = 1/8 + 3/8 + 3/8 + 1/8 = 1
1
Worked Example
If $P(X=x)=kx$ for $x=1,2,3$, find $k$.
Solution

Use the normalisation $\sum p_i=1$: $k(1)+k(2)+k(3)=k(1+2+3)=6k=1$, so $k=\dfrac16.$ Answer: $k=\dfrac16$.

2
Worked Example
Find $E(X)$ for the distribution $X:1,2,3$ with $p:\tfrac16,\tfrac26,\tfrac36$.
Solution

$E(X)=\sum x_i p_i=1\cdot\tfrac16+2\cdot\tfrac26+3\cdot\tfrac36=\dfrac{1+4+9}{6}=\dfrac{14}{6}=\dfrac{7}{3}.$ Answer: $\dfrac{7}{3}$.

3
Worked Example
Two coins are tossed; let $X$ be the number of heads. Write the probability distribution.
Solution

The equally likely outcomes are $HH, HT, TH, TT$. Counting heads: $P(X=0)=\tfrac14$ (TT), $P(X=1)=\tfrac24=\tfrac12$ (HT, TH), $P(X=2)=\tfrac14$ (HH). The probabilities sum to $1$, confirming a valid distribution. Answer: $P(0)=\tfrac14,\ P(1)=\tfrac12,\ P(2)=\tfrac14$.

4
Worked Example
For the two-coin variable $X$ above, find $E(X)$.
Solution

$E(X)=0\cdot\tfrac14+1\cdot\tfrac12+2\cdot\tfrac14=0+\tfrac12+\tfrac12=1.$ Answer: $1$.

5
Worked Example
A random variable $X$ has the distribution $X:0,1,2$ with $P:\tfrac14,\tfrac12,\tfrac14$. Find the variance and standard deviation of $X$.
Solution

First the mean: $\mu=0\cdot\tfrac14+1\cdot\tfrac12+2\cdot\tfrac14=1.$ Then $\sum x_i^2 p_i=0^2\cdot\tfrac14+1^2\cdot\tfrac12+2^2\cdot\tfrac14=\tfrac12+1=\tfrac32.$ So $\operatorname{Var}(X)=\tfrac32-1^2=\tfrac12=0.5$ and $\text{SD}=\sqrt{0.5}\approx0.707.$ Answer: $\operatorname{Var}(X)=0.5$, SD $\approx0.71$.

6
Worked Example
Find $k$ so that $P(X=x)=kx^2$ for $x=1,2,3$ is a valid distribution, then find $E(X)$.
Solution

Normalise: $k(1^2+2^2+3^2)=k(1+4+9)=14k=1$, so $k=\dfrac{1}{14}.$ The probabilities are $\tfrac{1}{14},\tfrac{4}{14},\tfrac{9}{14}$. Then $E(X)=1\cdot\tfrac{1}{14}+2\cdot\tfrac{4}{14}+3\cdot\tfrac{9}{14}=\dfrac{1+8+27}{14}=\dfrac{36}{14}=\dfrac{18}{7}.$ Answer: $k=\dfrac{1}{14}$, $E(X)=\dfrac{18}{7}\approx2.57$.

7
Worked Example
A fair die is thrown once and $X$ is the number that appears. Find $E(X)$ and $\operatorname{Var}(X)$.
Solution

Each value $1$ to $6$ has probability $\tfrac16$. Mean: $E(X)=\tfrac16(1+2+3+4+5+6)=\tfrac{21}{6}=\tfrac72=3.5.$ Mean of squares: $\sum x^2 p=\tfrac16(1+4+9+16+25+36)=\tfrac{91}{6}.$ So $\operatorname{Var}(X)=\tfrac{91}{6}-\left(\tfrac72\right)^2=\tfrac{91}{6}-\tfrac{49}{4}=\dfrac{182-147}{12}=\dfrac{35}{12}\approx2.92.$ Answer: $E(X)=3.5$, $\operatorname{Var}(X)=\dfrac{35}{12}\approx2.92$.

8
Worked Example
A fair coin is tossed $6$ times. Find the probability of getting exactly $4$ heads.
Solution

These are Bernoulli trials with $n=6,\ p=\tfrac12,\ q=\tfrac12$. Using the binomial formula, $P(X=4)=\binom{6}{4}\left(\tfrac12\right)^4\left(\tfrac12\right)^2=15\cdot\left(\tfrac12\right)^6=\dfrac{15}{64}.$ Answer: $\dfrac{15}{64}$.

9
Worked Example
A die is thrown $5$ times. Getting a number greater than $4$ is a "success". Find the probability of at most $2$ successes.
Solution

"Greater than $4$" means $5$ or $6$, so $p=\tfrac26=\tfrac13$ and $q=\tfrac23$, with $n=5$. "At most $2$" means $r=0,1,2$. $P(0)=\binom{5}{0}\left(\tfrac23\right)^5=\tfrac{32}{243}$; $P(1)=\binom{5}{1}\tfrac13\left(\tfrac23\right)^4=5\cdot\tfrac13\cdot\tfrac{16}{81}=\tfrac{80}{243}$; $P(2)=\binom{5}{2}\left(\tfrac13\right)^2\left(\tfrac23\right)^3=10\cdot\tfrac19\cdot\tfrac{8}{27}=\tfrac{80}{243}.$ Sum $=\dfrac{32+80+80}{243}=\dfrac{192}{243}=\dfrac{64}{81}.$ Answer: $\dfrac{64}{81}$.

10
Worked Example
For a binomial distribution with $n=10$ and $p=0.4$, find the mean, variance and standard deviation.
Solution

Here $q=1-p=0.6$. Mean $=np=10(0.4)=4.$ Variance $=npq=10(0.4)(0.6)=2.4.$ Standard deviation $=\sqrt{2.4}\approx1.55.$ Note the variance is less than the mean, as expected for a binomial. Answer: mean $4$, variance $2.4$, SD $\approx1.55$.

11
Worked Example
The mean of a binomial distribution is $4$ and its variance is $3$. Find $n$, $p$ and $P(X=1)$.
Solution

From $np=4$ and $npq=3$ we get $q=\dfrac{npq}{np}=\dfrac34$, so $p=1-q=\tfrac14$. Then $n=\dfrac{4}{p}=\dfrac{4}{1/4}=16.$ Finally $P(X=1)=\binom{16}{1}\left(\tfrac14\right)^1\left(\tfrac34\right)^{15}=16\cdot\tfrac14\cdot\left(\tfrac34\right)^{15}=4\left(\tfrac34\right)^{15}.$ Answer: $n=16,\ p=\tfrac14,\ P(X=1)=4\left(\tfrac34\right)^{15}$.

12
Worked Example
Two cards are drawn with replacement from a well-shuffled deck. Let $X$ be the number of kings drawn. Find the probability distribution of $X$, and hence $E(X)$.
Solution

With replacement, each draw is an independent Bernoulli trial with $p=\tfrac{4}{52}=\tfrac{1}{13}$ and $q=\tfrac{12}{13}$, and $n=2$. So $P(X=0)=\left(\tfrac{12}{13}\right)^2=\tfrac{144}{169}$, $P(X=1)=\binom{2}{1}\tfrac{1}{13}\cdot\tfrac{12}{13}=\tfrac{24}{169}$, $P(X=2)=\left(\tfrac{1}{13}\right)^2=\tfrac{1}{169}.$ Then $E(X)=np=2\cdot\tfrac{1}{13}=\dfrac{2}{13}$ (or directly $0\cdot\tfrac{144}{169}+1\cdot\tfrac{24}{169}+2\cdot\tfrac{1}{169}=\tfrac{26}{169}=\tfrac{2}{13}$). Answer: $P(0)=\tfrac{144}{169},\ P(1)=\tfrac{24}{169},\ P(2)=\tfrac{1}{169}$; $E(X)=\dfrac{2}{13}$.

Key Points

  • A random variable $X$ assigns a number to each outcome; its distribution lists $x_i$ with $p_i=P(X=x_i)$.
  • Validity: $p_i\ge0$ and $\sum p_i=1$ — use this to find unknown constants.
  • Mean $E(X)=\mu=\sum x_i p_i$; linearity $E(aX+b)=aE(X)+b$.
  • Variance $\operatorname{Var}(X)=\sum x_i^2 p_i-\mu^2$, SD $=\sqrt{\operatorname{Var}(X)}$; $\operatorname{Var}(aX+b)=a^2\operatorname{Var}(X)$.
  • Bernoulli trials: fixed $n$, two outcomes, independent, constant $p$ (drawing with replacement qualifies; without does not).
  • Binomial: $P(X=r)=\binom{n}{r}p^{r}q^{\,n-r}$ for $r=0,\dots,n$, the terms of $(q+p)^n$.
  • Binomial mean $=np$, variance $=npq$, SD $=\sqrt{npq}$; always $npq
Tap an option to check your answer0 / 4
Q1.For a valid distribution, $\sum p_i=$
Explanation: Probabilities sum to $1$.
Q2.If $P(X=x)=kx$ for $x=1,2,3$, then $k=$
Explanation: $6k=1$.
Q3.$E(X)$ is defined as:
Explanation: Probability-weighted average.
Q4.Two coins tossed, $X=$ heads; $E(X)=$
Explanation: $0(\tfrac14)+1(\tfrac12)+2(\tfrac14)=1$.