Sub topic 1
What a Random Variable Is
Prerequisites
This chapter assumes you can work with fractions, decimals, and percents. You should know how to compute a mean, and you should be able to add the probabilities of simple events. Reading a small table of values and probabilities will help.
The idea
A random variable is a numerical quantity whose value depends on the outcome of a random process. Before the process runs, you cannot know its value. Rolling a die produces a random variable X, the number that lands face up. X can be 1, 2, 3, 4, 5, or 6.
Capital letters such as X name the variable. Lowercase letters such as x name one specific value it can take.
Discrete versus continuous random variables
A discrete random variable takes countable values, such as the number of heads in three coin flips (0, 1, 2, or 3). A continuous random variable can take any value in an interval, such as a person's height. Normal distribution problems on the GRE usually model continuous quantities, but the exam often uses rounded counts and percentages.
Probability distributions
A probability distribution lists each possible value of a random variable with its probability. Each probability lies between 0 and 1, and all of them add to 1. For a continuous variable, probability is given by area under a curve instead of a list.
Expected value as a weighted average
The expected value E[X] is the mean of a random variable. Multiply each value by its probability and add the results. Values that are more likely count more.
Variance and standard deviation as spread
The variance is the probability-weighted average of the squared distances from the mean. The standard deviation is the square root of the variance.
from fractions import Fraction
values = [1, 2, 3, 4]
probs = [Fraction(1, 10), Fraction(2, 10), Fraction(3, 10), Fraction(4, 10)]
mean = sum(v * p for v, p in zip(values, probs))
variance = sum((v - mean) ** 2 * p for v, p in zip(values, probs))
print(mean, variance) # 3 1Exercise
Exercise
A discrete random variable X takes the values 0, 1, and 2 with probabilities 1/4, 1/2, and 1/4. What are E[X] and Var(X)?
Show answer
E[X] = 0(1/4) + 1(1/2) + 2(1/4) = 1. Var(X) = (0-1)^2(1/4) + (1-1)^2(1/2) + (2-1)^2(1/4) = 1/2.