

Random Variables I
Grayson White
Math 141
Week 10 | Fall 2025

Question: How did folks do inference before computers?

Question: How did folks do inference before computers?

Question: How did folks do inference before computers?

Question: How did folks do inference before computers?
“All models are wrong but some are useful.” – George Box
Question: How can we use theoretical probability models to approximate our (sampling) distributions?

Before we can answer that question and apply the models, we need to learn about the theoretical probability models themselves.
A random variable is a numeric quantity whose value depends on the result of a random process.
There are two main types of random variables:
Discrete variables can take only finitely many different values.
Continuous variables can take values equal to any real number in an interval.
Examples of discrete variables:
Examples of continuous variables:
For a discrete random variable, care about its:
Distribution: \(p(x) = P(X = x)\)
Center – Mean:
\[ \mu = \sum x p(x) \]
\[ \sigma^2 = \sum (x - \mu)^2 p(x) \]
\[ \sigma = \sqrt{ \sum (x - \mu)^2 p(x)} \]
Random variables have distributions, which tell us…
Example: I play a casino game, where that the amount of money I win (in dollars) has the following distribution:
| Winnings | $5 | $10 | $20 | $50 |
|---|---|---|---|---|
| Probability | .3 | .4 | .2 | .1 |
Suppose instead that I have a purse filled with the following 100 bills:
| Type | $5 | $10 | $20 | $50 |
|---|---|---|---|---|
| Frequency | 30 | 40 | 20 | 10 |
Playing this casino game is very similar to drawing a random bill from the purse!
We often use bar charts to visualize the distribution of discrete random variables.

Heights of bars are probabilities
Informally: The expected value is the average value the random variable takes.
Formally: The expected value (or mean) of a discrete random variable \(X\) is \[ E[X] = x_1 P(X = x_1) + x_2 P(X = x_2) + \dots x_n P(X = x_n) = \sum_{i =1}^n x_i P(X = x_i) \] where \(x_1, \dots, x_n\) are all the values X could potentially take.
Recall the example: if \(X\) represents the number of Heads when flipping a fair coin, its expected value is 0.5
\[ \begin{align} E[X] &= 0 P(X=0) + 1 P(X=1)\\ &= 0(0.5) + 1(0.5) \\ &= 0.5 \end{align} \]
\[ E[X] = x_1 P(X = x_1) + x_2 P(X = x_2) + \dots x_n P(X = x_n) = \sum_{i =1}^n x_i P(X = x_i) \]
Suppose we have a data set consisting of 10 values: \(\{1,1,2,2,2,2,3,4,5,5\}\).
02:00
\[ E[X] = x_1 P(X = x_1) + x_2 P(X = x_2) + \dots x_n P(X = x_n) = \sum_{i =1}^n x_i P(X = x_i) \]
Suppose we have a data set consisting of 10 values: \(\{1,1,2,2,2,2,3,4,5,5\}\).
\[ \begin{align} E[X] =& 1 P(X = 1) + 2 P(X = 2) + 3 P(X =3) + 4 P(X = 4) + 5 P(X = 5) \\ =& 1 \frac{2}{10} + 2 \frac{4}{10} + 3 \frac{1}{10} + 4 \frac{1}{10} + 5 \frac{2}{10} \\ =& \frac{27}{10} \end{align} \]
Previously, we said that by the Law of Large numbers, the proportion of times an outcome occurs in a long sequence of trials is close to the probability for that outcome.
This is a generalization:
Theorem: The Law of Large Numbers
Let \(X\) be a random variable.
Suppose we observe the random variable \(n\) times, \(x_1,x_2,\dots,x_n\).
Let \(\bar{x}_n\) denote the mean of our \(n\) observations of \(X\).
Then, as \(n\) becomes large, \(\bar{x}_n\) will approach the expected value \(E[X]\) of the random variable \(X\).
Suppose we roll a fair 6-sided die. What is the expected value of the result?

We can see that the expected value is \(3.5\)
The variance of a discrete random variable \(X\) with mean \(E(X) = \mu\) is \[ \begin{align} \mathrm{Var}(X) =& (x_1 - \mu)^2 P(X = x_1) + (x_2- \mu)^2 P(X = x_2) + \dots + (x_n-\mu)^2 P(X = x_n) \\ =& \sum_{i =1}^n (x_i-\mu)^2 P(X = x_i) \end{align} \]
The variance of \(X\) is the sum the squared deviations of \(X\) from its mean \(\mu\), weighted by the corresponding probabilities.
We also define the standard deviation of a random variable \(X\) to be \[ \textrm{SD}(X) = \sqrt{\mathrm{Var}(X)} \]
We often use:
\[ \begin{align} \mathrm{Var}(X) =& (x_1 - \mu)^2 P(X = x_1) + (x_2- \mu)^2 P(X = x_2) + \dots + (x_n-\mu)^2 P(X = x_n) \\ =& \sum_{i =1}^n (x_i-\mu)^2 P(X = x_i) \end{align} \]
Suppose we have a data set consisting of 5 values: \(\{1,1,3,5, 5\}\). Let \(X\) be a value chosen from this data set randomly. What is the variance of \(X\)?
\[ \begin{align} \mathrm{Var}(X) =& (1 - 3)^2 P(X = 1) + (3 - 3)^2 P(X = 3) + (5 - 3)^2 P(X =5) \\ =& (-2)^2 \frac{2}{5} + (0)^2 \frac{1}{5} + 2^2 \frac{2}{5} = \frac{16}{5} \end{align} \]
03:00
Consider a random variable \(X\) which is the number of heads in a single coin flip.
Q: What are the possible values for \(X\)? What are the probabilities each value of \(X\)?
Q: Compute the expected value and variance for \(X\) (the number of heads in a single coin flip)
\[ E[X] = (0)\frac{1}{2} + (1)\frac{1}{2} = \frac{1}{2} \]
\[ Var[X] = (0-1/2)^2\frac{1}{2} + (1-1/2)^2\frac{1}{2} = \frac{1}{4} \]
Theorem: Expectation of Sum
Let \(X\) and \(Y\) be random variables. Then \[ E(X + Y) = E(X) + E(Y) \]
Theorem: Scalar Multiplication with Expectation
Let \(X\) be a random variable, and let \(c\) be a number. Then \[ E(cX) = cE(X) \]
\[ X = \text{face of die roll} \quad \quad \quad E(5 X) = 5 E(X) = 5(3.5) = 17.5 \]
Theorem: Variance of Sum
Let \(X\) and \(Y\) be random variables. Additionally, let \(X\) and \(Y\) be independent. Then \[ \mathrm{Var}(X + Y) = \mathrm{Var}(X) + \mathrm{Var}(Y) \]
Theorem: Scalar Multiplication with Variance
Let \(X\) be a random variable, and let \(c\) be a number. Then \[ \mathrm{Var}(cX) = c^2\mathrm{Var}(X) \]
Now let \(Y\) be the number of heads in two coin flips.
Q: What are the possible values for \(Y\)? What are the probabilities each value of \(Y\)?
Q: Compute the expected value and variance for \(Y\) (the number of heads in two coin flips.)
We could use the definitions of expected value and variance directly…
\[ E[Y] = (0)\frac{1}{4} + (1)\frac{1}{2} +(2)\frac{1}{4} = 1 \]
\[ Var[Y] = (0-1)^2\frac{1}{4} + (1-1)^2\frac{1}{2}+ (2-1)^2\frac{1}{4}= \frac{1}{2} \]
…or, we could use our rules for expected value and variance:
\[Y = X_1 + X_2\] where \(X_1\) and \(X_2\) are two independent versions of our random variable, \(X\).
Thus,
\[ E[Y] = E[X_1] + E[X_2] = 0.5 + 0.5 = 1 \]
\[ Var[Y] = Var[X_1] + Var[X_2] = 0.25+ 0.25 = 0.5 \]
That’s a lot simpler!
Let \(Z\) be the number of heads in \(23\) independent coin tosses.
Q: What is \(E(Z)\)?
Q: What is \(\mathrm{Var}(Z)\)?
Q: Suppose \(W\) represents the number of heads in \(n\) independent coin tosses. What is \(E(W)\) and \(\mathrm{Var}(W)\)?
05:00
Let \(Z\) be the number of heads in \(23\) independent coin tosses.
Q: What is \(E(Z)\)?
Q: What is \(\mathrm{Var}(Z)\)?
\[ \mathrm{Var}(Z) = \mathrm{Var}(X_1) + \dots + \mathrm{Var}(X_{23}) = 0.25+\dots+0.25 = 23(0.25) \]
Q: Suppose \(W\) represents the number of heads in \(n\) independent coin tosses. What is \(E(W)\) and \(\mathrm{Var}(W)\)?