Back to the on-screen lesson ·

Discrete random variables

A number attached to each outcome, the mass function that records its weight, and reading an event as a set of values.

Paper packet. Every task here also exists on screen, where it is checked automatically; answers written on paper are not assessed by Nydus. When you are back at a device, enter your answers there.

1. What you will learn

You will define a random variable as a function on a sample space, list the values it can take, and build its probability mass function by collecting the outcomes that share each value. You will also read an event described in words as a set of values of the variable, and decide whether to add the entries or take a complement.

2. Outcomes that are not numbers

Every sample space so far has been a set of outcomes, and outcomes are often words: heads, a red ball, the machine stopped. Nothing has been averaged, ranked or added, because there has been nothing to add. This lesson supplies the numbers, and the whole second half of the course rests on it.

3. Words for this lesson

A random variable $X$ is a function from the sample space to the numbers: it attaches one number to each outcome. It is discrete when the values it can take form a list. Its probability mass function is $p(x) = P(X = x)$, and the set of values with $p(x) > 0$ is its range or support. Nothing about a random variable is random and nothing about it is a variable; the name is historical and it is too late to change it.

4. A number attached to each outcome

The sample space is a set of outcomes, and outcomes are often not numbers — heads, a red ball, the machine stopped. A random variable supplies the numbers: $X : \Omega \to \mathbb{R}$, one value per outcome.

Once the numbers exist, the probabilities come along with them. The event $\{X = x\}$ is the set of outcomes the function sends to $x$, and

$$p(x) = P(X = x) = \sum_{\omega : X(\omega) = x} P(\{\omega\}).$$

Two properties follow immediately from the axioms and are worth stating as a test: $p(x) \ge 0$ for every $x$, and $\sum_x p(x) = 1$. The second holds because the events $\{X = x\}$ are disjoint and cover $\Omega$ — the values of $X$ partition the sample space, so a mass function is nothing but additivity written as a table.

Every probability question about $X$ is then a question about a set of values: $P(X \le 2)$ adds the entries up to $2$, $P(X \ge 1)$ is easier as $1 - p(0)$, and choosing between adding and complementing is the only judgement involved.

Another way: picture

The sample space drawn as a scatter of dots, with arrows from each dot to a point on a number line. Several dots may land on the same number; the mass piled up there is the sum of those dots' probabilities. That pile is the mass function.

Another way: steps

  1. Write the sample space and the rule that gives $X$ its value.
  2. List the values $X$ can take.
  3. For each value, collect the outcomes sending to it and add their probabilities.
  4. Check the column adds to $1$.

5. One experiment, three random variables

Two fair dice, thirty-six equally likely ordered outcomes. Three different functions on the same sample space:

VariableRange$P(\cdot = \text{smallest})$
$S$, the total$2$ to $12$$P(S = 2) = 1/36$
$M$, the larger of the two faces$1$ to $6$$P(M = 1) = 1/36$
$D$, the absolute difference$0$ to $5$$P(D = 0) = 6/36$

Nothing about the experiment changed between the rows. A random variable is a question you ask of the outcome, and different questions give different mass functions over the same probabilities.

6. Where this goes wrong

Treating $X$ as an unknown number. It is a function. Before the experiment it has no value, and after the experiment it has one, exactly like reading a measurement off an object.

Forgetting that several outcomes can share a value. One head in two tosses is two outcomes, and its probability is the sum of theirs.

A mass function that does not add to one. The commonest arithmetic failure, and the cheapest to catch. Add the column.

Reading a discrete range as an interval. $X$ taking values $0$, $1$, $2$ does not take the value $1.5$, and $P(X \le 1.5) = P(X \le 1)$. This matters the moment the cumulative distribution function arrives.

7. From outcomes to a mass function

  1. Two fair coins, four equally likely outcomes; $X$ is the number of heads.

    Name the rule first.

  2. $X = 0$ on one outcome, $X = 1$ on two, $X = 2$ on one.

    Collect the outcomes by value.

  3. So $p(0) = 1/4$, $p(1) = 1/2$, $p(2) = 1/4$, adding to $1$.

    The check is the last line.

8. A variable that is not a count

  1. One fair die; $X$ is $3$ if the roll is even and $-1$ if it is odd.

    Any rule will do.

  2. Three outcomes give $3$ and three give $-1$.

    Collect by value.

  3. So $p(3) = p(-1) = 1/2$, and the range is $\{-1, 3\}$.

    Nothing was counted; the rule supplied the numbers.

9. Your turn: three fair coins; $X$ is the number of heads; find $p(1)$ and $P(X \ge 2)$

  1. There are eight equally likely outcomes, and $X = 1$ on three of them.

    Collect the outcomes.

  2. So $p(1) = 3/8$.

  3. Your turn: work this step out. Its working is at the end of the packet.

    $P(X \ge 2) = p(2) + p(3) = 3/8 + 1/8 = 1/2$.

10. Guided practice

A bag holds $10$ balls, $7$ of them red. Two balls are drawn, the first replaced before the second. Let $X$ be the number of red balls drawn. Give the mass function of $X$.

Probability
$P(X = 0)$
$P(X = 1)$
$P(X = 2)$

11. Guided practice

With the same bag of $10$ balls, $8$ of them red, and two draws with replacement, $X$ counts the red balls drawn. What is $P(X \ge 1)$?

Answer:

12. Practice

The same experiment gives $100$ equally likely ordered outcomes. Plot, for each value of $X$, how many of those $100$ outcomes give it.

Plot your answer on the grid:

123100value of Xoutcomes out of 100

13. Practice

The bag holds $10$ balls, $5$ of them red; two draws with replacement; $X$ counts the reds. Give the two probabilities.

$P(X = 2)$ is p and $P(X \le 1)$ is q.

14. Somewhere new

Two fair coins are tossed. A game pays $6$ for each head and takes away $1$ for each tail. Match each outcome to the value the payout variable gives it.

$12$$5$$-2$
Heads then heads
Heads then tails
Tails then heads
Tails then tails

15. Lesson test

Lesson test: one question per skill, one attempt each, no hints. Your answers are checked when you submit.

16. Test question

With two draws from the bag and $X$ counting the red balls drawn, give the set of values $X$ can take.

This task has no paper form; do it on a device.

17. What you can do now

You can build a mass function from a sample space, check that it adds to one, and read an event as a set of values of the variable. Say in your own words why two different outcomes can be given the same value, and what that does to the mass function.

Working for the steps left to you

9. Your turn: three fair coins; $X$ is the number of heads; find $p(1)$ and $P(X \ge 2)$, step 3