Random Variables Intro
Random Variables
Definition and Core Idea
A random variable is a variable that takes on numerical values, where each value has an associated probability. Just as in algebra a variable X can represent numbers like 2, π, or 7, a random variable assigns a real number to each outcome in a sample space Ω.
The key difference from an ordinary variable: probabilities can be assigned to each possible value (or range of values) of the random variable. This abstraction allows concise summarization of all possible outcomes of a random experiment.
Random variable: A function that maps outcomes in a sample space to real numbers, with a probability assigned to each value or interval.
Discrete vs. Continuous Random Variables
📊 Discrete Random Variables
A discrete random variable can take on only a countable set of distinct values.
Example: Number of heads in n coin flips. The set of possible values is {0,1,2,…,n}, a finite integer set.
Probabilities are assigned to each individual value (e.g., P(X=k)).
📈 Continuous Random Variables
A continuous random variable can take on any value within an interval (or continuum) on the real line.
Example: Height of Americans (measured in feet, meters, etc.). Possible values form a continuous range, say from roughly 3 ft to 8 ft.
Probabilities are assigned to intervals rather than exact points (since P(X=exact value)=0 for continuous distributions).
Probability Distribution (Probability Density)
The probability distribution of a random variable X gives the probability of each possible value (discrete) or the probability density for each interval (continuous). It is a function p(x) (or f(x)) that satisfies:
For discrete: P(X=xi)=p(xi), and ∑ip(xi)=1.
For continuous: the probability that X lies between a and b is ∫abf(x)dx, with ∫−∞∞f(x)dx=1.
This distribution can be visualized with a histogram (discrete) or a smooth curve (continuous). The distribution is a complete summary of all probabilistic information about the random variable.
Example: Coin Flips – Binomial Distribution
Scenario: Flip a fair coin 4 times. The sample space Ω contains 24=16 equally likely sequences of heads (H) and tails (T). Define X = number of heads in 4 flips.
Possible values: X∈{0,1,2,3,4}.
Probabilities (using binomial coefficients, also known as Pascal’s triangle):
P(X=0)=161 (only TTTT)
P(X=1)=164 (e.g., HTTT, THTT, TTHT, TTTH)
P(X=2)=166 (e.g., HHTT, HTHT, HTTH, THHT, THTH, TTHH)
P(X=3)=164
P(X=4)=161 (HHHH)
These probabilities follow the binomial distribution. In general, for n independent fair coin flips, X is binomial: P(X=k)=(kn)(0.5)n.
The distribution is plotted as a histogram:
The histogram shows P(X=k) on the y-axis (in units of 1/16) and k on the x-axis, with bars at heights 1, 4, 6, 4, 1.
This concise summary replaces the need to list all 16 possible sequences.
Continuous Random Variables: Normal Distribution
Example: The height of Americans. This is typically modeled by a normal (Gaussian) distribution – the bell curve. The normal distribution is defined by two parameters:
Mean (μ): the center, representing the average height.
Standard deviation (σ): the spread, representing how much individuals vary.
The probability density function (PDF) is:
Using this PDF, one can compute probabilities such as:
P(height<6 ft) = ∫−∞6f(x)dx
P(7 ft<height<8 ft) = ∫78f(x)dx
Additionally, as the number of coin flips n becomes large, the binomial distribution approximates a normal distribution – a key connection.
Why Use Random Variables?
1. Concise Summary of All Probabilities
Instead of enumerating an enormous sample space (e.g., 2100 sequences for 100 coin flips), the distribution P(X=k) is a simple function. No manual counting is required; the function provides probabilities directly.
2. Model of a Random Process
Probability distributions are mathematical models of real-world random processes. No real process is exactly binomial, normal, or Poisson – these are approximations that capture essential behavior. Modeling allows us to:
Describe complex random phenomena with a few parameters.
Make predictions and perform calculations without listing all outcomes.
3. Hypothesis Testing and Parameter Estimation
Hypothesis testing: Given data (e.g., 10 heads in 10 flips), does it support the assumption of a fair coin? The distribution provides the probability of such an extreme event, enabling a statistical test.
Parameter estimation: If heights are normally distributed with unknown μ,σ, a sample of 100 people can estimate these parameters. From the sample, inferences about the entire population (~300 million) become possible.
4. Visualization and Computation
Plotting the distribution gives an immediate visual sense of likely vs. unlikely values.
Probabilities over intervals are computed via summation (discrete) or integration (continuous):
Calculus allows elegant computation of expectations, variances, and other quantities.
5. Building Functions on Random Variables
You can define new random variables as functions of X, such as X2 or X, and compute their distributions. This enables:
Expected value E[X], variance Var(X), and standard deviation.
Propagation of uncertainty: Starting with a random initial condition, propagate it through a dynamical system (e.g., a chaotic differential equation) to see how uncertainty evolves. Gaussian processes and other methods rely on this principle.
Additional: Cumulative Distribution Function (CDF)
A closely related function is the cumulative distribution function (CDF), denoted F(x)=P(X≤x). For continuous variables, it is the integral of the PDF from −∞ to x:
The CDF gives the probability that the random variable is less than or equal to a given value, and it is a monotonic non-decreasing function from 0 to 1. It will be explored further in upcoming lectures.
Random variables form the backbone of probability and statistics. Upcoming lectures will cover binomial, normal, Poisson, exponential, gamma, and other common distributions, with practical examples such as waiting times at the DMV or email arrival rates. The abstraction of a random variable, once internalized, becomes a powerful tool for reasoning about uncertainty in engineering, science, and everyday life.

Ask anything
We've read this whole study set, so questions about it get the best answers.