Transcript Chapter4-1

Chapter 4 Random Variables - 1
Outline
• Random variables
• Discrete random variables
• Expected value
2
Sample Space and Events
• Genes relating to albinism are denoted by A and a. Only those
people who receive the a gene from both parents will be
albino. Persons having the gene pair A, a are normal in
appearance and, because they can pass on the trait to their
offspring, are called carriers. Suppose that a normal couple has
two children, exactly one of whom is an albino. Suppose that
the nonalbino child mates with a person who is known to be a
carrier for albinism.
(a) What is the probability that their first offspring is an
albino?
(b) What is the conditional probability that their second
offspring is an albino given that their firstborn is not?
3
Sample space
• If we measure the appearance (phenotype),
then the sample space has two outcomes
{albino, nonalbino}.
• If we measure the genes (genotype), then the
sample space has three outcomes {(A,A),
(A,a), (a,a)}.
• If we measure the phenotypes of two chirldren,
then the sample space has four outcomes
{(a,n), (a,a), (n,a), (n,n)}.
4
Events
• We may be only interested in, for example, whether a
person is albino or nonalbino even we measured the
genotypes. When we know a person is nonalbino, we
may be interested in whether he/she is a carrier. In
these situations, we need to define events to help us to
solve our problems.
–
–
–
–
Event E: the child is nonalbino, E = {(A,A),(A,a)}
Event F: the child is albino, F = {(a,a)}
Event G: the child is a carrier, G = {(A,a)}
Event Hi: the i-th offspring is an albino, H1: the 1st
offspring is an albino
– (a) P(H1) = ?
– (b) P(H2|H1c) = ?
5
S
E
(A,A)
(A,a)
(a,a)
Albino,
Nonalbino
6
Random Variables
• Some times events are not very convenient to use.
– In an exam with ten problems of ten points each, the
student may be only interested in how many problems
he/she answered correctly.
– In a clinical trial of certain new treatment, the proportion of
patients cured.
• We are interested in some functions of the outcome of
an experiment.
• Random variables
– Real valued functions defined on sample space.
7
Flip a coin three times and record the flips. Then
S = {HHH, HHT, HTH, THH, HTT, THT, TTH,
TTT}.
Define a function X on S by X(s) = “the # of heads in
the three flips.” So X(HHH) = 3, X(HTT) = 1,
X(THT) = 1, and X(TTT) = 0. The range of the
random variable X is {0, 1, 2, 3}.
P(X=0) + P(X=1) + P(X=2) + P(X=3)
= 1/8 + 3/8 + 3/8 + 1/8 = 1
8
S
RV
HHH, HHT,
HTH, THH,
HTT, THT,
TTH, TTT
0, 1, 2, 3
9
• Roll a red die and a clear die and record the two rolls. Sample
space is S = {(1,1), (1,2),…,(6,6)} with 36 elements. There are
many random variables definable on S.
– Define X(r,c) = r+c. That is, X of a pair is the sum of the
numbers. So X(1,5) = 6 and X(6,6) = 12. Then the range of
X is {2,3,…,12}.
– Define Y(r,c) = max{r,c}. So Y(1,5) = 5 and Y(6,6) = 6.
Then the range of Y is {1,2,3,4,5,6}.
– Define Z(r,c) = r-c. So Z(1,5) = -4 and Z(6,6)=0. Then the
range of Z is {-5, -4,…, 4, 5}.
– Define W(r,c) = r/c. So W(1,5) = 1/5 and W(6,6) = 1. Then
the range of W is {1, 2, 3, 4, 5, 6, 1/2, 3/2, 5/2, 1/3, 2/3, 4/3,
5/3, 1/4, 3/4, 5/4, 1/5, 2/5, 3/5, 4/5, 6/5, 1/6, 5/6}.
10
• Ex 1d. Three balls are randomly chosen from an urn
containing 3 white, 3 red, and 5 black balls. Suppose that we
win $1 for each white ball selected and lose $1 for each red
selected. If we let X denote our total winning from the
experiment, then X is a random variable taking on the possible
values 0, ±1, ±2, ±3 with respective probabilities
 5   3  3  5 
      
3
1 1 1
55
P( X  0)        
,
165
11
 
3
 3  5 
  
2  1  15

P( X  2)  P( X  2) 

,
165
11
 
3
 3  5   3  3 
      
1 2
2 1
39
P( X  1)  P( X  1)        
165
11
 
3
 3
 
3
1

P( X  3)  P( X  3) 

11 165
 
3
11
55  39  15  1  39  15  1
P( X  i) 
1

165
i  3
3
39  15  1
P( X  i) 
 1/ 3

165
i 1
3
12
Benefits of Using Random Variables
• The concept of random variables helps us to
formulate our problems better.
• It allows us to apply all our knowledge of functions to
the study of probability.
• Also, it strips away real world differences to reveal
situations that are probabilistically identical.
– For instance, if X is the number of heads in three flips of a
coin and Y is the number of girls in a family with three
children, then X and Y are probabilistically identical
(assuming the probability is 1/2 of each child being a girl)
even though the physical situations they model are quite
different.
13
Discrete Random Variables
• A random variable is discrete if it can take on
at most a countable (or countably infinite)
number of possible values.
• Countably infinite
– it is possible to make a list of the elements even
though they are infinite. For instance
• the set of positive even numbers is countably infinite: 2,
4, 6, 8,….
• The set of positive numbers of no more than two
decimal digits is countably infinite: 0.01, 0.02,…, 0.99,
1.00, 1.01, ….
– An interval like [0,1] is uncountably infinite; it is
impossible to make a list – even an infinite list – of
the real numbers between zero and one.
14
Discrete Random Variables
• Example
Flip a coin repeatedly until it shows heads. Record the
flips in order. So S = {H, TH, TTH, TTTH,
TTTTH,…}.
Define a function X on S by X(s) = “the # of flips in the
outcomes.” So X(H) = 1, X(TH) = 2, and X(TTTTH) =5.
The range of X is {1, 2, 3, 4, …} = “the set of positive
integers.”
This set is countably infinite, so X is a discrete random
variable.
15
Probability Density Functions (pdf)
• Given a discrete random variable X with sample
space S, there is an associated probability density
function (probability mass function) p defined by
p(a) = P{X=a}.
That is, the pdf tells us the probability of each
particular value of x occurring. If x is not in the range
of p, then p(x)=0.
• The sum of the values of p(x) for all x’s in the range
of X must be 1.
16
Probability Density Functions (pdf)
• Flip a coin and record the result. S = {H,T}.
Define a random variable X on S by X(H) = 1 and X(T) = 0.
The range of X is {0,1}.
The pdf for X is given by p(0) = P(X=0) = P({T}) = 1/2 and
p(1) = P(X=1) = P({H}) = 1/2.
• Flip a coin three times and record the results.
S = {TTT, TTH, THT, HTT, HHT, HTH, THH, HHH,}.
Define X(s) to be the number of heads in the three flips.
The range of X is {0,1,2,3}.
The values of the pdf for this random variable are p(0) = 1/8,
p(1) = 3/8, p(2) = 3/8, p(3) = 1/8. For instance, p(1) = P(X=1)
= P({TTH, THT, HTT}) = 3/8.
17
S
RV
PDF
HHH, HHT,
HTH, THH,
HTT, THT,
TTH, TTT
0, 1, 2, 3
0.125, 0.375
18
Probability Density Functions (pdf)
PDF for # of Heads in 3 flips of a Coin
1
0.75
Probability
• Graph the pdf for
flipping a coin
three times using
a “discrete
density graph” or
a histogram. We
can also display
them using tables.
0.5
3/8
3/8
0.25
1/8
1/8
0
0
1
2
3
4
# of Heads
19
Probability Density Functions (pdf)
PDF for # of Heads in 3 flips of a Coin
1
Probability
0.75
0.5
3/8
3/8
0.25
1/8
0
PDF for # of Heads in 3 flips of a
Coin
1/8
0
1
2
3
1/8
3/8
3/8
1/8
# of Heads
20
Cumulative Distribution Functions
(cdf)
• In many practical situations, we are interested in whether
the value of a random variable is smaller (or greater) than
a certain number.
– The hurricane is less than certain strength, the earthquake is less
than certain level, the risk of losing money in an investment is
less than certain percentage, etc…
• Cumulative distribution function is defined as
F(x) = P(X<=x)
• Every cdf is an increasing function. Its limit at negative
infinity (to the left) is 0 and its limit at positive infinity
(to the right) is 1.
• Once you know the cdf, you can easily find almost any
probability that interests you.
• If the random variable X is discrete, then the cdf is a step
function.
21
Cumulative Distribution Functions
Cumulative distribution function for the random variable X that counts the heads
in three coin flips. Note that it jumps at every value in the range of X.
CDF for # of Heads in 3 flips of a Coin
1
1
7/8
Probability
0.75
0.5
4/8
0.25
1/8
0
-2
-1
0
1
# of Heads
2
3
4
22
CDF Example
Flip a coin repeatedly until it shows heads. Record the
flips in order. So S = {H, TH, TTH, TTTH,
TTTTH,…}.
X: the number of flips in the outcomes.
So X(H) = 1, X(TH) = 2, and X(TTTTH) =5.
The range of X is {1, 2, 3, 4, …} = “the set of positive
integers.”
What does the CDF of X look like?
23
Play or Not to Play?
• Suppose I want to play a game with you. In
each round, I toss two coins and pay you $3 if
there are two heads, $2.5 if there are two tails,
and $2 if there are one head and one tail. We
play this for 100 rounds.
• If I charge you $2.4 for each round. Do you
want to play the game or not?
• What you really care is the average of the
money you make in each round.
24
Expected Value
• Expected value of X is a weighted average of the
possible values that X can take on, each value being
weighted by the probability that X assumes it.
• E[X] = Σxp(x)
• Expected value is what one should expect if the
experiment is repeated many times.
• p(0) = 1/2, p(1) = 1/2
– E[X] = 0(1/2) + 1 (1/2) = 1/2
• p(0) = 1/3, p(1) = 2/3
– E[X] = 0(1/3) + 1(2/3) = 2/3
25
Play or Not to Play
• X: amount of dollars one makes in a single
round.
– A random variable of the outcome of tossing two
coins.
• x = X(two heads) = 3, x = X(one head, one tail)
= 2, x = X(two tails) = 2.5.
• E[X] = 3×p(x=3) + 2 ×p(x=2) + 2.5×p(x=2.5)
= 3×(1/4) + 2 × (1/2) + 2.5×(1/4) = 2.375
You are charged $2.4 for each round...
26
• Ex 3b. I is an indicator variable for the event A
if
 1 if A occurs
I 
c
0
if
A
occurs

Find E[I]
p(1) = P(A), p(0) = 1-P(A), we have
E[I] = 1×P(A) + 0×(1-P(A))
The expected value of the indicator variable
for the event A is equal to the probability that
A occurs.
27
• Ex 3d. A school class of 120 students are driven in 3
buses to a symphonic performance. There are 36
students in one of the buses, 40 in another, and 44 in
the third bus. When the buses arrive, one of the 120
students is randomly chosen. Let X denote the
number of students on the bus of that randomly
chosen student, find E[X].
• The range of X is {36, 40, 44}.
• P(X=36) = 36/120, P(X=40) = 40/120, P(X=44) =
44/120
• E[X] = 36(36/120) + 40(40/120) + 44(44/120) =
40.2667
28
Two Envelop Problem
• Let's say you are given two indistinguishable
envelopes, each of which contains a positive
sum of money. One envelope contains twice as
much as the other. You may pick one envelope
and keep whatever amount it contains. You
pick one envelope at random but before you
open it you're offered the possibility to take the
other envelope instead.
• What will you do?
29
The Switching Argument
• Let’s denote by A the amount in your selected envelope.
• The probability that A is the smaller amount is 1/2, and that it's
the larger also 1/2
• The other envelope may contain either 2A or A/2
– If A is the smaller amount the other envelope contains 2A
– If A is the larger amount the other envelope contains A/2
– The other envelope contains 2A with probability 1/2 and A/2 with
probability 1/2
• So the expected value of the money in the other envelope is:
1 1 A 5
2A    A  A
2 2 2 4
30
The Contradiction
• Since the expected value in the other envelop is larger
than what is in the envelop you selected, you should
switch.
• After the switch one can reason in exactly the same
manner as above
– The most rational thing to do is to switch back again
– To be rational one will thus end up switching envelopes
indefinitely
• As it seems more rational to open just any envelope
than to switch indefinitely we have a contradiction!
31