Lecture #11: Discrete Random Variables

STAT 200 – Introductory Statistics

Torin Quinlivan

Knox College

January 19, 2026

Today’s Objective

After today’s lecture, you should:

  • explain what a random variable is
  • understand the difference between discrete and continuous (random) variables
  • know the purpose of the probability mass function (pmf)
  • explain the three requirements for a function to be a pmf
  • calculate probabilities using the pmf.
  • calculate the expected value and variance of a distribution.

Random Variables

A random variable is a variable whose numeric value is determined by the outcome of a probability experiment.

Examples:

  • a statistician’s favorite ice cream flavor.
  • a student’s level of approval of a Congressional decision.
  • the year a Knox College professor is born.
  • the number of pages read by a student each night.

Probability

Random variables have (or follow) probability distributions. This fact allows us to understand the randomness of a random variable… and of our sample.

It might sound counter-intuitive, but remember that probability is predictable in the long run.

I can’t tell you what will happen on the next coin flip, but I can tell you approximately what proportion of 1000 coin flips will land heads.

Gambler’s Fallacy

Misunderstanding this distinction can lead to all kinds of incorrect reasoning.

The Gambler’s Fallacy is the mistaken belief that a random event is more likely to happen because it has not happened multiple times in a row.

If you haven’t had a good hand all night, you’re not any more likely to get a good hand this round than any other.

The Axioms of Probability

At their core, random variables are just functions, sending the set of possible outcomes to their probabilities.

There are three requirements for a function to be a probability mass function, which defines a random variable.

  1. All of the probabilities are between 0 and 1, inclusive.

\[ 0 \le \mathbb{P}[X = x] \le 1 \]

The Axioms of Probability

At their core, random variables are just functions, sending the set of possible outcomes to their probabilities.

There are three requirements for a function to be a probability mass function, which defines a random variable.

  1. The sum of the probabilities is 1.

\[ \sum_{x \in S} \mathbb{P}[X = x] = 1 \]

The Axioms of Probability

At their core, random variables are just functions, sending the set of possible outcomes to their probabilities.

There are three requirements for a function to be a probability mass function, which defines a random variable.

  1. The probability of a union is no more that the sum of the individual probabilities.

\[ \mathbb{P}[A \cup B] \le \mathbb{P}[A] + \mathbb{P}[B] \]

Quick Coin Example

Let us create a probability mass function for this experiment:

Flip a coin three times and count the number of heads flipped.

Solution: The first step is to determine the set of possible outcomes, the sample space, \(S\). From the description of the experiment, these are the only outcomes possible:

\[ S = \{ 0, 1, 2, 3 \} \]

Quick Coin Example

Let us create a probability mass function for this experiment:

Flip a coin three times and count the number of heads flipped.

Solution:

The second step is to determine the probability of each of the elements of the sample space.

To do this, we will rely on two assumptions:

  • The coin is fair.
  • The flips are independent of each other.

Quick Coin Example

A graphic is one way of showing the probability mass function. This is a graphic of the probability mass function for this problem.

Quick Coin Example

A formula is another way of showing the probability mass function. This becomes more handy when the sample space becomes much larger.

\[ \mathbb{P}[X = x] = \begin{cases} 0.125 & \textrm{if } x = 0 \\ 0.375 & \textrm{if } x = 1 \\ 0.375 & \textrm{if } x = 2 \\ 0.125 & \textrm{if } x = 3 \\ 0 & \textrm{otherwise} \end{cases} \]

Note: You need the last line in there to fully define the function.

Quick Coin Example

The formula isn’t necessarily unique either. This also defines the same probability mass function:

\[ \mathbb{P}[X = x] = \binom{3}{x} 0.5^x (1 - 0.5)^{3-x}, \quad x \in {0,1,2,3} \]

Expected Value

The expected value of a distribution (or of a random variable) is the “long-run” average of the distribution’s outcomes.

The expected value of a discrete random variable \(X\) is equal to the mean of the probability distribution of \(X\) and is given by

\[ \mathbb{E}[X] = \sum_{x \in S} x\,\mathbb{P}[X = x] \]

Variance

The variance of a distribution (or of a random variable) is a measure of uncertainty in each outcome. It has the opposite meaning of precision.

The variance of a discrete random variable \(X\) is given by

\[ \mathbb{V}[X] = \sum_{x \in S} (x - \mu)^2\,\mathbb{P}[X = x] \]

Median

The median of a distribution (or of a random variable) is an \(x\)-value such that at least half is no more than it, and at least half is no less than it.

The median** of a discrete random variable \(X\) is given by

\[ \tilde{X} = \left\{ x \,\vert\, \mathbb{P}[X \le x] \ge 0.50 \textrm{ and } \mathbb{P}[X \ge x] \ge 0.50 \right\} \]

Median

Note that the actual definition:

  • explains why I hand-waved during the times I discussed the median of a sample.
  • is much easier in the case of continuous distributions, as it reduces to \(\mathbb{P}[X \le \tilde{x}] = 0.50\).
  • implies that the median is not necessarily unique for discrete random variables.

Three Coins Example

Let us return to our original example, flipping a coin three times. The probability mass function is:

\[ \mathbb{P}[X = x] = \begin{cases} 0.125 & \textrm{if } x = 0 \\ 0.375 & \textrm{if } x = 1 \\ 0.375 & \textrm{if } x = 2 \\ 0.125 & \textrm{if } x = 3 \\ 0 & \textrm{otherwise} \end{cases} \]

With this probability mass function, let us calculate the mean, variance and median.

Three Coins Example

First, here is the probability mass function as a graphic:

From the graphic, what do we expect the mean and median to be?

Three Coins Example

The mean is defined as:

\[ \mathbb{E}[X] = \sum_{x \in S} x\,\mathbb{P}[X = x] \]

Since \(S = \{0, 1, 2, 3\}\), the expected number of heads is:

\[ \begin{aligned} \mathbb{E}[X] &= \sum_{x \in S} x\,\mathbb{P}[X = x] \\ &= 0(0.125) + 1(0.375) + 2(0.375) + 3(0.125) \\ &= 0 + 0.375 + 0.750 + 0.375 \\ &= 1.500 \end{aligned} \]

Thus, the expected number of heads of three flips of a fair coin is \(1.5\).

Three Coins Example

The variance is defined as:

\[ \mathbb{V}[X] = \sum_{x \in S} (x - \mu)^2\,\mathbb{P}[X = x] \]

Three Coins Example

Since \(S = \{0, 1, 2, 3\}\), the variance of the number of heads is:

\[ \begin{aligned} \mathbb{V}[X] &= \sum_{x \in S} (x - \mu)^2\,\mathbb{P}[X = x] \\ &= (0-1.5)^2(0.125) + (1-1.5)^2(0.375) \\ &\qquad\qquad + (2-1.5)^2(0.375) + (3-1.5)^2(0.125) \\ &= 2.25(0.125) + 0.25(0.375) + 0.25(0.375) + 1.25(0.125) \\ &= 0.75 \end{aligned} \]

Thus, the variance of the heads of three flips of a fair coin is \(0.75\), and the standard deviation is \(\sqrt{0.75} \approx 0.866\).

Three Coins Example

The median is defined as:

\[ \tilde{X} = \left\{ x \,\vert\, \mathbb{P}[X \le x] \ge 0.50 \textrm{ and } \mathbb{P}[X \ge x] \ge 0.50 \right\} \]

Three Coins Example

How do we use this formula? Start low and keep adding until you first get to/over \(0.500\):

\[ \begin{aligned} X = 0 &: 0.125 \not\ge 0.500 \\ X = 1 &: 0.125 + 0.375 \ge 0.500 \end{aligned} \]

We have the cumulative probabilities at least \(0.500\), and we are done with the calculations. Because the cumulative probabilities equal \(0.500\), both \(1\) and \(2\) are medians.

Technically, the medians are all numbers in the set \(1 \le \tilde{X} \le 2\). For the sake of convenience, we will state \(\tilde{X} = 1.5\).

Three Coins Example

If we understand discrete distributions and how R works, we could use R to get these answers, or at least help us get the answers.

x = 0:3
p = c(0.125,0.375,0.375,0.125) 

sum(x*p)
[1] 1.5

Three Coins Example

If we understand discrete distributions and how R works, we could use R to get these answers, or at least help us get the answers.

x = 0:3
p = c(0.125,0.375,0.375,0.125) 

sum((x-1.5)^2*p)
[1] 0.75
sqrt(sum((x-1.5)^2*p))
[1] 0.8660254

Three Coins Example

If we understand discrete distributions and how R works, we could use R to get these answers, or at least help us get the answers.

x = 0:3
p = c(0.125,0.375,0.375,0.125) 

cumsum(p)
[1] 0.125 0.500 0.875 1.000

Ice Hockey Example

A STAT 225 course project had students predict the outcome of an ice hockey game between the Portland Winterhawks and the Prince George Cougars. Together (averaged), they determined that the following was the probability mass function for the number of points scored by the Winterhawks:

Score \(0\) \(1\) \(2\) \(3\) \(4\) \(5\)
Probability \(0.1\) \(0.1\) \(0.2\) \(0.4\) \(0.1\) \(0.1\)

With this information, let us calculate the expected number of goals, the variance, and the median.

Ice Hockey Example

First, here is the probability mass function as a graphic:

From the graphic, what do we expect the mean and median to be?

Ice Hockey Example

Since \(S = \{0, 1, 2, 3, 4, 5\}\), the expected number of goals is:

\[ \begin{aligned} \mathbb{E}[X] &= \sum_{x \in S} x\,\mathbb{P}[X = x] \\ &= 0(0.1) + 1(0.1) + 2(0.2) + 3(0.4) + 4(0.1) + 5(0.1) \\ &= 2.6 \end{aligned} \]

Thus, the expected number of goals to be made by the Winterhawks is \(2.6\).

Ice Hockey Example

Since \(S = \{0, 1, 2, 3\}\), the variance of the number of goals is:

\[ \begin{aligned} \mathbb{V}[X] &= \sum_{x \in S} (x - \mu)^2\,\mathbb{P}[X = x] \\ &= (0-2.6)^2(0.1) + (1-2.6)^2(0.1) + (2 - 2.6)^2(0.2) \\ &\qquad\qquad + (3-2.6)^2(0.4) + (4-2.6)^2(0.1) + (5-2.6)^2(0.1) \\ &= 6.76(0.1) + 2.56(0.1) + 0.36(0.2) \\ &\qquad\qquad + 0.16(0.4) + 1.96(0.1) + 5.76(0.1) \\ &= 1.84 \end{aligned} \]

Ice Hockey Example

Aside: The Empirical Rule: Recall the Empirical Rule. Since the standard deviation is \(\sqrt{1.84} \approx 1.356\), we can estimate the probability of the Winterhawks scoring between \(\mu - \sigma = 1.244\) and \(\mu + \sigma = 3.956\) is about 68%.

Again, remember that the Empirical Rule is only an approximation. Since we have the entire probability mass function, we know that the probability of the Winterhawks scoring between \(1.244\) and \(3.956\) goals is \(0.2 + 0.4 = 60\%\) (not \(68\%\)).

Still, this is a rather close estimate, right?

Ice Hockey Example

Again, start low and keep adding until you first get to/over \(0.500\):

\[ \begin{aligned} x = 0 &: 0.1 \not\ge 0.500 \\ x = 1 &: 0.1 + 0.1 = 0.2 \not\ge 0.500 \\ x = 2 &: 0.1 + 0.1 + 0.2 = 0.4 \not\ge 0.500 \\ x = 3 &: 0.1 + 0.1 + 0.2 + 0.4 = 0.8 \ge 0.500 \end{aligned} \]

Thus, a median is \(3\).

Note: since the cumulative sum does not equal 0.500, the only median is 3.

Ice Hockey Example

If we understand discrete distributions and how R works, we could use R to get these answers, or at least help us get the answers.

x = 0:5
p = c(0.1,0.1,0.2,0.4,0.1,0.1)

sum(x*p)
[1] 2.6

Ice Hockey Example

If we understand discrete distributions and how R works, we could use R to get these answers, or at least help us get the answers.

x = 0:5
p = c(0.1,0.1,0.2,0.4,0.1,0.1)

sum((x-1.5)^2*p)
[1] 3.05
sqrt(sum((x-1.5)^2*p))
[1] 1.746425

Ice Hockey Example

If we understand discrete distributions and how R works, we could use R to get these answers, or at least help us get the answers.

x = 0:5
p = c(0.1,0.1,0.2,0.4,0.1,0.1)

cumsum(p)
[1] 0.1 0.2 0.4 0.8 0.9 1.0