Lecture 5

Random Variables, and Distributions


Grace Tompkins

Last modified — 23 May 2026

Learning Outcomes

By the end of this lecture, students are anticipated to be able to:

  • Define a random variable, and a distribution
  • Identify and define appropriate random variables from word problems
  • Write out distributions using indicator functions

1 Random Variables

Review

  • So far, we have discussed how probability measures (functions) operate on events (subsets) of the sample space.
  • For any event \(A \subseteq \Omega\), \(\mathbb{P}(A)\) is a number between 0 and 1.
  • But events are not always the most natural way to talk about possible outcomes of an experiment.
  • It is often easier to describe an event \(A \subseteq \Omega\) with a single number.
  • Recall our experiment “roll a die until you see 6”.
  • There are many sequences of rolls (elements of \(\Omega\)) in the event “first 6 on roll 12”: \(E_{12}\).
  • What if we summarize these with “12”?

Random Variables

  • A random variable is a way of summarizing events mathematically.
  • We use capital letters (usually, near the end of alphabet) to denote random variables (\(X\), \(Y\), \(Z\), etc.)

Random variable: a function from the sample space to a subset of the real numbers.

Therefore, a the random variable called \(X\) is any function

\[X \, : \, \Omega \ \rightarrow {\mathbb{R}}.\]

That is, for each \(\omega \in \Omega\),
\[X( \omega ) \in {\mathbb{R}}.\]

Random Variables

Suppose we toss a coin 3 times.

  • Sample space: \(\Omega \, = \, \Bigl\{ ( x_{1}, x_{2}, x_{3} ) \, : \ x_{i} \in \{ H, T \} \ \Bigr\}\)

Let \(X( \omega )=\) number of heads in \(\omega\).

  • If \(\omega = (HHH), X(\omega)\) = .

  • If \(\omega = (HHT), (HTH),\) or \((THH), X(\omega) =\).

  • … and so on

We can summarize this as:



Random Variables

Suppose it can either be raining, snowy, or sunny.

Let \(X = 3\) if its raining, \(X\) = 6 if it snows, and \(X\) = -2.7 if it’s sunny.

Is \(X\) a random variable?

Random Variables

Let \(\Omega = \{1,2,3,4,5,6\}\). Let \(X(\omega) = \omega\) and \(Y(\omega) = \omega^3 + 2\).

Compute \(Z(\omega)\) for all \(\omega \in \Omega\) where \(Z = XY\).

Canucks Hockey

  • Suppose the Canucks play 2 games next week.
  • Each game can be won (W), lost (L), or lost in overtime (O).
  • The Canucks get points for wins (2), overtime losses (1), and losses (0).
  1. Write out the sample space \(\Omega\).
  2. Define \(Z = \text{\# games played}\). Is \(Z\) a random variable? If so, enumerate how it operates on each \(\omega \in \Omega\)
  3. Define \(X = \text{\# points}\). Enumerate how it operates on each \(\omega \in \Omega\).
  4. Which outcomes are in the event \(A = \{X \geq 3\}\)?

Canucks Hockey

Random Variables and Events

  • Random variables are naturally used to describe events of interest.
  • For example \(\Bigl\{ X > 3 \Bigr\}\) or \(\Bigl\{ Y \le 2 \Bigr\}\)
  • Formally, this notation means:

\[\Bigl\{ X > 3 \Bigr\} \, = \, \Bigl\{ \omega \in \Omega \, : \, X \left( \omega \right) > 3 \Bigr\},\]

and

\[\Bigl\{ Y \le 2 \Bigr\} \, = \, \Bigl\{ \omega \in \Omega \, : \, Y \left( \omega \right) \le 2 \Bigr\}.\]

In other words, \(\Bigl\{ X > 3 \Bigr\}\) and \(\Bigl\{ Y \le 2 \Bigr\}\) are events.

The Indicator Function

The indicator function is a useful mathematical shorthand.

It is also a random variable: it is a function from \(\Omega \to {\mathbb{R}}\).

The indicator of the event \(A\) is the random variable given by \[ I_A(\omega) = \begin{cases} 1 & \omega \in A\\ 0 & \text{else}.\end{cases} \]

The Indicator Function

Let \[ A = (1,2,3,4,5,6) \] \(I_A(5)\) = 1 because 5 is in the set A.

\(I_A(9)\) = 0 because 9 is not in the set A.

The Indicator Function

Consider a 6-sided fair die, where \(\Omega = \{1,2,3,4,5,6\}\)

What is \(Y = X + I_{\{6\}}\).?

The Indicator Function

Let \(A\) and \(B\) be events, and let \(X = I_A \times I_B\). Is \(X\) an indicator function? If so, of what event?

2 Distributions

Distributions

  • A probability associates each \(\omega \in \Omega\) with a number between 0 and 1 and satisfies the Probability axioms.

  • Random variables also operate on \(\Omega\). Taking these together induces a probability on \({\mathbb{R}}\).

Suppose we flip a fair coin with \(\Omega = \{H, T\}\), and we know that \(\mathbb{P}(H) = \mathbb{P}(T) = 0.5\).

Then, considering the RV \(I_H\), we see \(\mathbb{P}(I_H =1) = \mathbb{P}(\{\omega : I_H(\omega) = 1\}) = \mathbb{P}(H)\)

Distributions

Distribution: If \(X\) is a random variable, then the distribution of \(X\) is the collection of probabilities \(\mathbb{P}(X \in B)\) for all subsets \(B\) of \({\mathbb{R}}\).

Consider \(\Omega = \{H, T\}\), and \(\mathbb{P}(H) = \mathbb{P}(T) = 0.5\)

  • This defines \(\mathbb{P}\) on all subsets \(2^\Omega = \{\varnothing, \{T\}, \{H\}, \Omega\}\).

  • But considering a random variable \(X\), it isn’t really enough to know it’s probability only on it’s range.

  • We need to know more than that: we need to know, for every \(B \subset {\mathbb{R}}\), what is \(\mathbb{P}(X \in B) = \mathbb{P}(\{s\in\Omega : X(s) \in B\})\).

  • To fully specify the distribution, we need to do this for every (nice) subset \(B\). The collection of these subsets is denoted \(\mathcal{B}\).

The mathematical details are at least at the level of Math 420.

Distribution Example

Consider shuffling a deck of 50 Pokemon cards where 20 are grass-type (\(G\)), 13 are fighting-type (\(F\)), 7 are water-type (\(W\)), and 10 are electric-type (\(E\)). Professor Grace really likes the grass and water types.

Consider the random variable \(Z\), which indicates if Grace will really like the card chosen. Compute \(\mathbb{P}(Z = z)\) for any \(z\).

Distribution Example

More Hockey

  • Suppose the Canucks play 2 games next week. Each game can be won (W), lost (L), or lost in overtime (O). The Canucks get points for wins (2), overtime losses (1), and losses (0).
  • The Canucks are not very good. Suppose for each game (independently), \[\mathbb{P}(\omega) = \begin{cases} 0.3 & \omega = W\\ 0.2 & \omega = O \\ 0.5 &\omega = L.\end{cases}\]
  1. Let \(X\) be the number of wins. Compute \(\mathbb{P}(X = x)\) for all \(x\in{\mathbb{R}}\). Hint: Start by solving for \(\mathbb{P}(X = 0)\), \(\mathbb{P}(X = 1)\), and \(\mathbb{P}(X = 2)\)
  2. Write a formula for \(\mathbb{P}(X\in B)\) for any \(B\subset{\mathbb{R}}\). Hint: indicators!
  3. Let \(Y\) be the number of points. Compute \(\mathbb{P}(Y = y)\) for all \(y\in{\mathbb{R}}\).

More Hockey

More Hockey

More Hockey

Midterm info:

  • Your midterm will cover materials from Lectures 1 - 8
  • DATE: in class on Tuesday June 2
  • LENGTH: 1 hour and 50 minutes in length.
  • You may bring in one (1) “cheat sheet”:
    • Must be HAND WRITTEN with pen/pencil on said sheet of paper (not typed, not photo copied, not printed, not written on an iPad)
    • Must be on 8.5 by 11 inch sheet of paper or smaller d
    • You may write on both sides
    • No magnifying glasses or anything else silly
    • I will confiscate cheatsheets that do not follow these rules 🥀
    • I do not care what is written on it
  • Exam is hand written on paper, bring something to write with
  • You may bring a non-programmable, non-graphing calculator.

To do:

  • Read Chapters 2.3 before Friday’s class
  • Assignment 1 due TONIGHT 11:59pm. Submit on Gradescope.