01 / 20

Random Variables
& Distributions

Explore how random variables map outcomes to numbers, and how distribution functions capture their probabilistic behavior.

Statistics

What Is a Random Variable?

A random variable is a function \( X : \Omega \to \mathbb{R} \) that assigns a real number to every outcome in a sample space \( \Omega \). It transforms abstract experimental outcomes into numerical quantities we can analyze mathematically.

\(\Omega\) \(\omega_1\) \(\omega_2\) \(\omega_3\) \(X\) \(\mathbb{R}\) \(2\) \(7\) \(12\)

Discrete vs Continuous

Random variables fall into two fundamental classes based on the nature of their range.

Discrete
Takes countably many values. Described by a probability mass function (PMF): \( p(x) = P(X = x) \).
Continuous
Takes uncountably many values. Described by a probability density function (PDF): \( f(x) \) where \( P(a \leq X \leq b) = \int_a^b f(x)\,dx \).

Why Do Distributions Matter?

A distribution function completely characterizes the probabilistic behavior of a random variable. Every quantity of interest: means, variances, tail probabilities, quantiles: derives from it.

1
Prediction: Compute \( P(X \in A) \) for any event \( A \).
2
Expectation: Calculate \( E[g(X)] = \int g(x)\,dF(x) \) for any measurable \( g \).
3
Inference: Estimate parameters \( \theta \) from data via the likelihood \( L(\theta) = \prod f(x_i;\theta) \).
4
Modeling: Choose an appropriate family (normal, Poisson, exponential, ...) for real-world phenomena.

The Cumulative Distribution Function

The CDF is the universal descriptor for any random variable. It is defined as:

1
Non-decreasing: If \( a < b \), then \( F(a) \leq F(b) \).
2
Right-continuous: \( \lim_{x \to a^+} F(x) = F(a) \).
3
Boundary limits: \( \lim_{x \to -\infty} F(x) = 0 \) and \( \lim_{x \to +\infty} F(x) = 1 \).

Visualizing the CDF

PMF vs PDF: Key Distinction

PMF \( p(x) \) PDF \( f(x) \)
Type Discrete Continuous
Gives \( P(X = x) \) directly Density, not probability
Values \( 0 \leq p(x) \leq 1 \) \( f(x) \geq 0 \), can exceed 1
Sums/Integrates to \( \sum_x p(x) = 1 \) \( \int_{-\infty}^{\infty} f(x)\,dx = 1 \)
CDF from \( F(x) = \sum_{t \leq x} p(t) \) \( F(x) = \int_{-\infty}^{x} f(t)\,dt \)

Expectation and Variance

Expectation \( E[X] \)
Discrete: \( E[X] = \sum_x x \cdot p(x) \)
Continuous: \( E[X] = \int_{-\infty}^{\infty} x \cdot f(x)\,dx \)
The "center of mass" of the distribution.
Variance \( \text{Var}(X) \)
\( \text{Var}(X) = E[(X - \mu)^2] = E[X^2] - (E[X])^2 \)
Measures spread around the mean. Standard deviation: \( \sigma = \sqrt{\text{Var}(X)} \).

How to Apply: Working with Distributions

1
Identify the variable: What quantity are you measuring? Is it discrete (counts) or continuous (measurements)?
2
Specify PMF/PDF: Write down \( p(x) \) or \( f(x) \). Verify it satisfies the axioms: non-negative and sums/integrates to 1.
3
Derive the CDF: Compute \( F(x) \) by summing or integrating.
4
Compute moments: Find \( E[X] \), \( \text{Var}(X) \), and any other quantities of interest.
5
Answer probability questions: Use \( F(b) - F(a) = P(a < X \le b) \).

Example 1: Discrete PMF

Let \( X \) have PMF: \( p(1) = 0.2 \), \( p(2) = 0.3 \), \( p(3) = 0.3 \), \( p(4) = 0.2 \). Find \( E[X] \) and \( \text{Var}(X) \).

Example 2: Continuous PDF

Let \( f(x) = 2x \) for \( 0 \leq x \leq 1 \), and 0 otherwise. Find \( P(X > 0.5) \) and \( E[X] \).

Example 3: The Normal Distribution

If \( X \sim N(\mu, \sigma^2) \), its PDF is:

Important Named Distributions

Distribution PMF/PDF \( E[X] \) \( \text{Var}(X) \)
Bernoulli(\( p \)) \( p^x(1-p)^{1-x} \) \( p \) \( p(1-p) \)
Binomial(\( n,p \)) \( \binom{n}{x}p^x(1-p)^{n-x} \) \( np \) \( np(1-p) \)
Poisson(\( \lambda \)) \( \frac{e^{-\lambda}\lambda^x}{x!} \) \( \lambda \) \( \lambda \)
Exponential(\( \lambda \)) \( \lambda e^{-\lambda x} \) \( 1/\lambda \) \( 1/\lambda^2 \)
Normal(\( \mu,\sigma^2 \)) \( \frac{1}{\sigma\sqrt{2\pi}}\exp\!\left(-\frac{(x-\mu)^2}{2\sigma^2}\right) \) \( \mu \) \( \sigma^2 \)

Moment Generating Functions

The moment generating function (MGF) of \( X \) is defined as:

1
Moments from MGF: \( E[X^n] = M_X^{(n)}(0) \). The \( n \)-th derivative at \( t = 0 \) gives the \( n \)-th moment.
2
Uniqueness theorem: If \( M_X(t) = M_Y(t) \) in a neighborhood of 0, then \( X \) and \( Y \) have the same distribution.
3
Sum of independents: If \( X \perp Y \), then \( M_{X+Y}(t) = M_X(t) \cdot M_Y(t) \).

Common Mistakes to Avoid

✕ PDF as Probability
Treating \( f(x) \) as \( P(X = x) \). For continuous RVs, \( P(X = x) = 0 \) always. The PDF is a density.
✕ Forgetting Support
Computing \( E[X] = \int_{-\infty}^{\infty} x f(x)\,dx \) without restricting to where \( f(x) > 0 \). Check the support.
✕ Variance Shortcut Error
Writing \( \text{Var}(X) = E[X^2] - E[X] \) instead of \( E[X^2] - (E[X])^2 \). Don't forget to square the mean.

Question 1 of 5

Which of the following is a valid probability mass function?

Question 2 of 5

If \( X \) has PDF \( f(x) = 3x^2 \) for \( 0 \leq x \leq 1 \), what is \( E[X] \)?

Question 3 of 5

For the standard normal distribution, which property of the CDF \( \Phi(x) \) is true?

Question 4 of 5

If \( X \sim \text{Poisson}(\lambda = 4) \), what are \( E[X] \) and \( \text{Var}(X) \)?

Question 5 of 5

The MGF of \( X \) is \( M_X(t) = e^{3t + 2t^2} \). What is \( \text{Var}(X) \)?