Week 4: Learning Objectives: at The End of Week 4 You Should Be Able To
Week 4: Learning Objectives: at The End of Week 4 You Should Be Able To
Objectives
At the end of Week 4 you should be able to:
Understand the concept of a random variable
and how it relates to probability problems
Work with probability mass functions
Calculate the expected value, variance and
standard deviation of random variables
Solve probability problems involving the
binomial
probability model
Random
A
Variables is a function from the
random variable
sample space S to a set of numbers that
makes sense for the sample space
we will use capital letters to denote a r.v., e.g. X
you can define many r.v. for the same sample
space
Suppose you roll two dice
sample space consists of 36 outcomes
S={(1,1), (1,2),
(2,1), . . ., (6,6)}
one possible r.v. will represent the sum of the
potential outcomes on the two dice, let’s call the
r.v. X
X will have a different value for each point of the2
The two-dice
example
Out- X Out- X Out- X Out- X Out- X Out- X
value value value value value value
come come come come come come
(1,1) 2 (2,1) 3 (3,1) 4 (4,1) 5 (5,1) 6 (6,1) 7
(1,2) 3 (2,2) 4 (3,2) 5 (4,2) 6 (5,2) 7 (6,2) 8
(1,3) 4 (2,3) 5 (3,3) 6 (4,3) 7 (5,3) 8 (6,3) 9
(1,4) 5 (2,4) 6 (3,4) 7 (4,4) 8 (5,4) 9 (6,4) 10
(1,5) 6 (2,5) 7 (3,5) 8 (4,5) 9 (5,5) 10 (6,5) 11
(1,6) 7 (2,6) 8 (3,6) 9 (4,6) 10 (5,6) 11 (6,6) 12
3
Some more
examples
Select a random student amongst the
class, and measure his/her height in cm.
S=set of students
r.v. X is ‘height’ which is a function from the
set of students to the set of real numbers that
correspond to heights of students
I toss a coin 3 times, and measure the
number of heads
S= {HHH, HHT, HTH, HTT, THH, THT, TTH, TTT}
Random variable Y is a function from S to {0, 1,
2, 3}
4
Types of random
variables
Discrete
A r.v. is discrete if the values it can take are finite
or
countably infinite (link to week 1 slides for these)
The examples with the coin and the dice
correspond to
finite cases
A countably infinite case would be e.g. a r.v.
measuring the number of accidents in a year in
the M1
Continuous
A r.v. is continuous if the values it can take are
uncountably infinite
e.g. the r.v. measuring the height of students 5
Probability mass function
(pmf)
Let X be a discrete random variable
Given any value a in the set of possible
values for X, what is the probability that X
will have that value a?
Another way to write this:
P(X=a) : the probability that X will
take the value a, or even simpler
P(a)
6
Definitions and properties of
pmf
The probability mass function (pmf) of a
discrete r.v. will give us the value of
P(X=a) for each element a in the set of
possible values of the random variable
X
For a function to be a probability mass
function of a discrete r.v., 2 conditions
must hold:
P(X=a)0, for all possible a
∑ (P(X=a)) = 1, for all possible a
Both conditions should feel familiar!!!
Also, to find the probability that the r.v takes 7
Exampl
e
p.m.f of X=Sum
X of two dice What is the p.m.f. for
(the P(X=a) or P(a) the dice-rolling
r.v.)
2 1/36 example, where the
3 2/36 random variable X is
4 3/36 the sum of the two
5 4/36
6 5/36
dice?
7 6/36
8 5/36 How did we find
9 4/36
10 3/36 these probability
11 2/36 values?
12 1/36 Do they sum up to
1? 8
A graphical
illustration
0.18
0.16
0.14
0.12
Probability of
0.1
0.08
0.06
X
0.04
0.02
0
1 2 3 4 5 6 7 8 9 10 11 12
Values of X=Sum of two dice
9
Another
example
Consider the case of tossing a coin 3
times
S= {HHH, HHT, HTH, HTT, THH, THT, TTH, TTT}
Let X be a r.v. that records the number of
heads {0, 1, 2, 3}. Find the p.m.f. of X
1 OR 2:
10
Expectation &
distribution parameters
Using the probability mass function
you can figure three important
parameters:
Expected Value
The long-term average value that you would
expect to see after an experiment is
repeated a theoretically infinite number of
times
Variance
The amount of variability you would need to
expect from one set of results of the
experiment to another
Standard Deviation
11
Expected value of a
random variable
The expected value of a random variable X,
E(X), is the long-run theoretical average
value of X
You can also see it as the weighted
average of all possible values of X,
weighted by how often we expect each
value to occur over the long- term
, where x is a value of the r.v. X,
E( X ) and
x p(x) the probability of observing that value
Another way to describe E(X) is as the
mean of X, denoted with the letter
12
Methodology &
Example
To find the expected value of a
random variable:
Multiply the value of X by its
probability
Repeat the step for all values of X
Sum the results
In the example of rolling the two
dice and the
r.v. X recording the sum of the
dice:
E( X ) 2(1/ 36) 3(2 / 36) 4(3 / 36) 5(4 / 36)
6(5 / 36
8(5 / 36) 9(4 / 36) 13
The variance of a random
variable
The variance V(X) of a r.v. is the amount of
variability you would expect in the
results after repeating the experiment a
theoretically infinite number of times
V(X) = E(X2)-2 =E(X2)-[E(X)]2
In other words, this is the difference
between the expected value of X2 and the
square of the expected value of X
To find E(X2) you just need to calculate
x2p(x) for all x that are values of the r.v. X
Always, V(X)0
14
An
example
Consider the case where we toss a coin 3
times and the r.v. X counts the number of
heads. Calculate E(X) and V(X)
x xp(x) = 0X(1/8) + 1X(3/8) + 2X(3/8) +
E( X ) all
=
3X(1/8)
3/2
V ( X ) E( X 2 ) (E( X )) 2 ( x 2 p(x)) (E( X )) 2
all x
[(02 (1/ 8)) (12 (3 / 8)) (22 (3 / 8)) (32 (1/
8))] (3 / 2)2
3/4
15
Standard
deviation
The standard deviation of a random variable
is simply the square root of its variance
we use the letter to denote the standard
deviation
Standard deviation allows us to easier
interpret the variation within the
outcomes of the random variable.
It shows us the variability of X in the original
units of X and not in their square, as does
V(X) 16
Probability
Distributions
A number of probability distributions have
specific characteristics and can be used to
model experiments when certain
conditions are met
they are distributions that occur in many
probability problems, so people have
studied them and their properties well
Discrete Uniform, Binomial, Normal,
Bernoulli, Poisson, Gaussian, etc.
For each distribution there are:
Conditions that must be met
Formulas for pmf, E(X), V(X) 17
The Binomial
probability
distribution
Binomial means ‘two names’ and
is associated with situations
involving two outcomes, e.g.
success/failure
The conditions to have a Binomial
model are:
A fixed number of trials, n
The outcome of each trial is either in one of
two groups, e.g. success or failure
The probability of success is the same in
each trial, let it be p, and therefore 1-p the
probability of failure
18
Checking the
conditions
Do the following examples
satisfy the conditions of the
Binomial model?
You toss a coin 10 times and
count the number of heads
You toss a coin until you get 4
heads
You have a drawer with 10 red pens, 10
blue and 10 black. You take a pen out
and record its colour (then you do not
put it back in). You repeat the process 5
times, and you are interested in the 19
The pmf of the
Binomial
The probability mass function of the Binomial
model for a r.v. X is given by:
P(X=x) is the probability of having
exactly x successes, P(X=x) =C(n,x)px(1-
p)n-x, where:
n is the fixed number of trials
x is the specified number of successes, so n-x
is the number of failures
p is the probability of success in any given
trial, so 1-p
is the probability of failure in any given trial
C(n,x) is our known formula for combinations of
x items chosen from n items (here: x successes
chosen from the total of n trials) 20
Expected value and
variance
In the Binomial model, for a r.v. X:
E(X)=np, where:
n is the number of trials, and p the
probability of success in any given trial
V(X)=np(1-p), where:
n is the number of trials, and p the
probability of success in any given trial
The standard deviation np(1 p)
=
21
Summary of
lecture
In Week 4 we covered:
Random variables
Probability mass function
Expected value, variance and
standard deviation
The Binomial probability
distribution
22