10 Random Variables
10 Random Variables
Random Variable
A Random Variable (RV) is a variable that probabilistically takes on different values. You can think of an RV
as being like a variable in a programming language. They take on values, have types and have domains over
which they are applicable. We can define events that occur if the random variable takes one values that satisfy
a numerical test (eg does the variable equal 5, is the variable less than 8). We often think of the probabilities
of such events.
As an example, let’s say we flip three fair coins. We can define a random variable Y to be the total number
of “heads” on the three coins. We can ask about the probability of Y taking on different values using the
following notation:
Using random variables is a convenient notation technique that assists in decomposing problems. There are
many different types of random variables (indicator, binary, choice, Bernoulli, etc). The two main families of
random variable types are discrete and continuous.
6/36
1/6
5/36
4/36
P(X = x)
P(X=x)
3/36
2/36
1/36
0 0 0 0
1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11
x x
Figure: On the left, the PMF of a single 6 sided die roll. On the right, the PMF of the sum of two dice rolls.
E[X] = ∑ xP(x)
x:P(x)>0
It goes by many other names: Mean, Expectation, Weighted Average, Center of Mass, 1st Moment.
Example 1
Lets say you roll a 6-Sided Die and that a random variable X represents the outcome of the roll. What is the
E[X]? This is the same as asking what is the average value.
Example 2
Lets say a school has 3 classes with 5, 10, and 150 students. If we randomly choose a class with equal
probability and let X = size of the chosen class:
If instead we randomly choose a student with equal probability and let Y = size of the class the student is in
Example 3
Consider a game played with a fair coin which comes up heads with p = 0.5. Let n = the number of coin
flips before the first “tails”. In this game you win $2n . How many dollars do you expect to win? Let X be a
random variable which represents your winnings.
1 2 3 4 ∞ i+1
1 1 1 1 1
E[X] = 20 + 21 + 22 + 23 + · · · = ∑ 2i
2 2 2 2 i=0 2
∞
1
=∑ =∞
i=0 2
Linearity
Expectations preserve linearity which means that E[aX + b] = aE[X] + b
Disclaimer: This handout was made fresh just for you. Notice any mistakes? Let Chris know.