Law of Total Probability. Method of recurrent equations

Law of total probability
Method of recurrent equations
N.I. Lobachevsky State University
of Nizhni Novgorod
Probability theory and mathematical statistics:
Law of Total Probability.
Method of recurrent equations
Associate Professor
A.V. Zorine
Law of Total Probability. Method of recurrent equations
1 / 14
Law of total probability
Method of recurrent equations
Theorem
Let H1 , H2 , . . . , Hn , . . . be a finite or denumerable sequence of
mutualually exclusive events with positive probability each, and
A ⊂ H1 ∪ H2 ∪ . . . ∪ Hn ∪ . . .. Then
P(A) = P(H1 )P(A|H1 ) + P(H2 )P(A|H2 ) + . . . + P(Hn )P(A|Hn ) + . . .
Proof. Events A ∩ H1 , A ∩ H2 , . . . , A ∩ Hn , . . . are mutually exclusive
and A = (A ∩ H1 ) ∪ (A ∩ H2 ) ∪ . . . ∪ (A ∩ Hn ) ∪ . . .. Then
P(A) = P((A ∩ H1 ) ∪ (A ∩ H2 ) ∪ . . . (A ∩ Hn ) ∪ . . .)
= P(A ∩ H1 ) + P(A ∩ H2 ) + . . . + P(A ∩ Hn ) + . . .
= P(H1 )P(A|H1 ) + P(H2 )P(A|H2 ) + . . . P(Hn )P(A|Hn ) + . . .
Law of Total Probability. Method of recurrent equations
2 / 14
Law of total probability
Method of recurrent equations
Example. There are m red balls and n blue balls in an urn. Two balls
are taken out one by one without replacement. What’s the probability
the second ball is blue (event A)?
Law of Total Probability. Method of recurrent equations
3 / 14
Law of total probability
Method of recurrent equations
Example. There are m red balls and n blue balls in an urn. Two balls
are taken out one by one without replacement. What’s the probability
the second ball is blue (event A)?
Solution by classical formula
We can use classical formula here. An outcome is an arrangement of
two balls without repetitions. Favorable outcome are those with the
second ball of the blue color. The first ball can be either blue or red.
N(Ω) = A2m+n = (m + n)(m + n − 1),
N(A) = n(n − 1) + mn,
So,
P(A) =
n(n − 1) + mn
n
=
(m + n)(m + n − 1)
m+n
Law of Total Probability. Method of recurrent equations
3 / 14
Law of total probability
Method of recurrent equations
Example. There are m red balls and n blue balls in an urn. Two balls
are taken out one by one without replacement. What’s the probability
the second ball is blue (event A)?
Law of Total Probability. Method of recurrent equations
4 / 14
Law of total probability
Method of recurrent equations
Example. There are m red balls and n blue balls in an urn. Two balls
are taken out one by one without replacement. What’s the probability
the second ball is blue (event A)?
Solution by law of total probability.
Let event H1 occur when the first ball is red and H2 occur when the
first ball is blue.
P(H1 ) =
m
,
m+n
Law of Total Probability. Method of recurrent equations
4 / 14
Law of total probability
Method of recurrent equations
Example. There are m red balls and n blue balls in an urn. Two balls
are taken out one by one without replacement. What’s the probability
the second ball is blue (event A)?
Solution by law of total probability.
Let event H1 occur when the first ball is red and H2 occur when the
first ball is blue.
P(H1 ) =
m
,
m+n
Law of Total Probability. Method of recurrent equations
P(A|H1 ) =
n
m+n−1
4 / 14
Law of total probability
Method of recurrent equations
Example. There are m red balls and n blue balls in an urn. Two balls
are taken out one by one without replacement. What’s the probability
the second ball is blue (event A)?
Solution by law of total probability.
Let event H1 occur when the first ball is red and H2 occur when the
first ball is blue.
P(H1 ) =
m
,
m+n
P(H2 ) =
n
,
m+n
Law of Total Probability. Method of recurrent equations
P(A|H1 ) =
n
m+n−1
4 / 14
Law of total probability
Method of recurrent equations
Example. There are m red balls and n blue balls in an urn. Two balls
are taken out one by one without replacement. What’s the probability
the second ball is blue (event A)?
Solution by law of total probability.
Let event H1 occur when the first ball is red and H2 occur when the
first ball is blue.
P(H1 ) =
m
,
m+n
P(A|H1 ) =
n
m+n−1
P(H2 ) =
n
,
m+n
P(A|H2 ) =
n−1
m+n−1
Law of Total Probability. Method of recurrent equations
4 / 14
Law of total probability
Method of recurrent equations
Example. There are m red balls and n blue balls in an urn. Two balls
are taken out one by one without replacement. What’s the probability
the second ball is blue (event A)?
Solution by law of total probability.
Let event H1 occur when the first ball is red and H2 occur when the
first ball is blue.
P(H1 ) =
m
,
m+n
P(A|H1 ) =
n
m+n−1
P(H2 ) =
n
,
m+n
P(A|H2 ) =
n−1
m+n−1
Then
P(A) = P(H1 )P(A|H1 ) + P(H2 )P(A|H2 )
n
n
n−1
n
m
=
·
+
·
=
n+m m+n−1 m+n m+n−1
m+n
Law of Total Probability. Method of recurrent equations
4 / 14
Law of total probability
Method of recurrent equations
Example. There 5 urns, two of them contain 2 red balls and 1 blue
ball, another two contain 3 red balls and 1 blue ball, and the last one
contains 10 blue balls. An urn is picked at random and one ball is
taken out. What’s the probability that the ball is red?
Law of Total Probability. Method of recurrent equations
5 / 14
Law of total probability
Method of recurrent equations
Example. There 5 urns, two of them contain 2 red balls and 1 blue
ball, another two contain 3 red balls and 1 blue ball, and the last one
contains 10 blue balls. An urn is picked at random and one ball is
taken out. What’s the probability that the ball is red?
Solution.
Let event H1 occur when one of the first two urns is chosen, H2 occur
when the third or the fourth urs is chosen, H3 occur when the fifth urn
is chosen. P(H1 ) = 52 , P(H2 ) = 52 , P(H3 ) = 51 , P(A|H1 ) = 23 ,
P(A|H2 ) = 43 , P(A|H3 ) = 0. Then
P(A) =
2 2 2 3 1
17
· + · + ·0=
5 3 5 4 5
30
Law of Total Probability. Method of recurrent equations
5 / 14
Law of total probability
Method of recurrent equations
There are m red balls and n blue balls in an urn. r balls are taken out
one by one without replacement, r 6 m + n. Prove that the
n
.
probability for the last ball to be blue is m+n
Law of Total Probability. Method of recurrent equations
6 / 14
Law of total probability
Method of recurrent equations
There are m red balls and n blue balls in an urn. r balls are taken out
one by one without replacement, r 6 m + n. Prove that the
n
.
probability for the last ball to be blue is m+n
Denote by π(r; m, n) the probability in question. It’s obvious that
π(1; m, n) =
n
.
m+n
Now assume that
π(2; m, n) = π(3; m, n) = . . . = π(r − 1; m, n) =
n
m+n
We have to prove that
π(r; m, n) =
Law of Total Probability. Method of recurrent equations
n
m+n
6 / 14
Law of total probability
Method of recurrent equations
Let event H1 occur when the first ball is red and H2 occur when the
first ball is blue.
P(H1 ) =
m
,
n+m
Law of Total Probability. Method of recurrent equations
P(H2 ) =
n
m+n
7 / 14
Law of total probability
Method of recurrent equations
Let event H1 occur when the first ball is red and H2 occur when the
first ball is blue.
P(H1 ) =
m
,
n+m
P(H2 ) =
n
m+n
If H1 occurs, then only n + m − 1 balls left, n of them are blue, and
we still have to take r − 1 balls out, so the conditional probability that
the last ball is blue given that the first is red equals π(r − 1; m − 1, n).
Law of Total Probability. Method of recurrent equations
7 / 14
Law of total probability
Method of recurrent equations
Let event H1 occur when the first ball is red and H2 occur when the
first ball is blue.
P(H1 ) =
m
,
n+m
P(H2 ) =
n
m+n
If H1 occurs, then only n + m − 1 balls left, n of them are blue, and
we still have to take r − 1 balls out, so the conditional probability that
the last ball is blue given that the first is red equals π(r − 1; m − 1, n).
If H2 occurs, then only n + m − 1 balls left, n − 1 of them are blue,
and we are to take r − 1 balls out, so the conditional probability that
the last ball is blue given that the first is blue equals π(r − 1; m, n − 1).
Law of Total Probability. Method of recurrent equations
7 / 14
Law of total probability
Method of recurrent equations
By assumption,
π(r − 1; m − 1, n) =
n
,
m+n−1
n−1
.
m+n−1
According to the law of total probability,
π(r − 1; m, n − 1) =
π(r; m, n) = P(H1 )π(r − 1; m − 1, n) + P(H2 )π(r − 1; m, n − 1)
m
n
n
n−1
n
=
·
+
·
=
n+m m+n−1 m+n m+n−1
m+n
Law of Total Probability. Method of recurrent equations
8 / 14
Law of total probability
Method of recurrent equations
Ruin problem
Assume Ann and Bart play Heads and Tails. If Ann wins, she pays
one rouble to Bart. If Bart wins, he pays one rouble to Ann. In the
beginning Ann has a roubles, Bart has b roubles. What’s the
probability Ann loses all her money? Ann’s ruin means that Ann has
no more roubles. The same holds for Bart’s ruin.
Law of Total Probability. Method of recurrent equations
9 / 14
Law of total probability
Method of recurrent equations
Ruin problem
Assume Ann and Bart play Heads and Tails. If Ann wins, she pays
one rouble to Bart. If Bart wins, he pays one rouble to Ann. In the
beginning Ann has a roubles, Bart has b roubles. What’s the
probability Ann loses all her money? Ann’s ruin means that Ann has
no more roubles. The same holds for Bart’s ruin.
The total sum of roubles is a + b. Denote by π(x) probabilty of Ann’s
ruin having x roubles initially. If she wins a toss, her fortune becomes
x + 1 roubles, otherwise x − 1 roubles. She wins a toss with
probability 12 and loses with probability 12 . If has x roubles and she
wins a toss, whether she gets ruined or not is defined only by the
future tosses which are independent of the past tosses, so the ruin
probability after that is π(x + 1).
Law of Total Probability. Method of recurrent equations
9 / 14
Law of total probability
Method of recurrent equations
By the total probability formula,
1
1
π(a) = π(x + 1) + π(x − 1)
2
2
(1)
π(0) = 1
(2)
besides that,
and
π(a + b) = 0.
From (1),
π(x) − π(x − 1) = π(x + 1) − π(x) = c
for a constant c, and
π(x) = π(0) + xc.
Using (2), obtain
π(x) = 1 −
x
a+b
Thus, Ann gets ruined with probability π(a) =
Law of Total Probability. Method of recurrent equations
b
a+b .
10 / 14
Law of total probability
Method of recurrent equations
A problem in runs
In any ordered sequence of elements of two kinds, each maximal
subsequence of elements of like kind is called a run. For example, the
sequence xxxyxxyyyx opens with an x run of length 3; it is followed by
runs of length 1, 2, 3, 1, respectively.
Law of Total Probability. Method of recurrent equations
11 / 14
Law of total probability
Method of recurrent equations
A problem in runs
In any ordered sequence of elements of two kinds, each maximal
subsequence of elements of like kind is called a run. For example, the
sequence xxxyxxyyyx opens with an x run of length 3; it is followed by
runs of length 1, 2, 3, 1, respectively.
Let α and β be positive integers, and consider a potentially unlimited
sequence in independent trials, such as tossing a coin or throwing
dice. Symbol x occurs in a single trial with probability p, symbol y
occurs in a single trial with probability q = 1 − p. What’s the
probability that a run of α consecutive x’s will occur before a run of β
consecutive y’s?
Law of Total Probability. Method of recurrent equations
11 / 14
Law of total probability
Method of recurrent equations
Since the trials are independent, the probability of the sequence
xxxyxxyyyx
equals
p · p · p · q · p · p · q · q · q · p = p6 q4 .
Law of Total Probability. Method of recurrent equations
12 / 14
Law of total probability
Method of recurrent equations
Since the trials are independent, the probability of the sequence
xxxyxxyyyx
equals
p · p · p · q · p · p · q · q · q · p = p6 q4 .
Let A be the event that a run of α consecutive x’s occurs before a run
of β consecutive y’s. Denote x = P(A). Let
u = P(A|”the first trial results in x”),
v = P(A|”the first trial results in y”).
Then
x = pu + qv.
Law of Total Probability. Method of recurrent equations
12 / 14
Law of total probability
Method of recurrent equations
Suppose that the first trial results in x. In this case the event A can
occur in α mutually exclusive ways:
1
The following α − 1 trials result in x’s; the probability for this is
pα−1 .
Law of Total Probability. Method of recurrent equations
13 / 14
Law of total probability
Method of recurrent equations
Suppose that the first trial results in x. In this case the event A can
occur in α mutually exclusive ways:
1
The following α − 1 trials result in x’s; the probability for this is
pα−1 .
2
The first y occurs at the rth trial where 2 6 r 6 α. Let this event
be Hr . Then P(Hr ) = pr−2 q, and P(A|Hr ) = v.
Hence
u = pα−1 + qv(1 + p + . . . + pα−2 )
Law of Total Probability. Method of recurrent equations
13 / 14
Law of total probability
Method of recurrent equations
Suppose that the first trial results in x. In this case the event A can
occur in α mutually exclusive ways:
1
The following α − 1 trials result in x’s; the probability for this is
pα−1 .
2
The first y occurs at the rth trial where 2 6 r 6 α. Let this event
be Hr . Then P(Hr ) = pr−2 q, and P(A|Hr ) = v.
Hence
u = pα−1 + qv(1 + p + . . . + pα−2 ) = pα−1 + v(1 − pα ).
Law of Total Probability. Method of recurrent equations
13 / 14
Law of total probability
Method of recurrent equations
Suppose that the first trial results in x. In this case the event A can
occur in α mutually exclusive ways:
1
The following α − 1 trials result in x’s; the probability for this is
pα−1 .
2
The first y occurs at the rth trial where 2 6 r 6 α. Let this event
be Hr . Then P(Hr ) = pr−2 q, and P(A|Hr ) = v.
Hence
u = pα−1 + qv(1 + p + . . . + pα−2 ) = pα−1 + v(1 − pα ).
If the first trial results in y, a similar argument leads to
v = pu(1 + q + . . . + qβ2 )
Law of Total Probability. Method of recurrent equations
13 / 14
Law of total probability
Method of recurrent equations
Suppose that the first trial results in x. In this case the event A can
occur in α mutually exclusive ways:
1
The following α − 1 trials result in x’s; the probability for this is
pα−1 .
2
The first y occurs at the rth trial where 2 6 r 6 α. Let this event
be Hr . Then P(Hr ) = pr−2 q, and P(A|Hr ) = v.
Hence
u = pα−1 + qv(1 + p + . . . + pα−2 ) = pα−1 + v(1 − pα ).
If the first trial results in y, a similar argument leads to
v = pu(1 + q + . . . + qβ2 ) = q(1 − qβ−1 ).
Law of Total Probability. Method of recurrent equations
13 / 14
Law of total probability
Method of recurrent equations
We have two equations for the two unknown u and v:
u = pα−1 + v(1 − pα ),
v = qu(1 − qβ−1 ).
Law of Total Probability. Method of recurrent equations
14 / 14
Law of total probability
Method of recurrent equations
We have two equations for the two unknown u and v:
u = pα−1 + v(1 − pα ),
v = qu(1 − qβ−1 ).
Solution is
pα q
,
pqβ + pα (q − qβ )
pα (q − qβ )
.
v= β
pq + pα (q − qβ )
u=
Law of Total Probability. Method of recurrent equations
14 / 14
Law of total probability
Method of recurrent equations
We have two equations for the two unknown u and v:
u = pα−1 + v(1 − pα ),
v = qu(1 − qβ−1 ).
Solution is
pα q
,
pqβ + pα (q − qβ )
pα (q − qβ )
.
v= β
pq + pα (q − qβ )
u=
Finally,
x = pu + qv = pα−1
Law of Total Probability. Method of recurrent equations
1 − pα
pα−1 + qβ−1 − pα−1 qβ−1
14 / 14
Law of total probability
Method of recurrent equations
We have two equations for the two unknown u and v:
u = pα−1 + v(1 − pα ),
v = qu(1 − qβ−1 ).
Solution is
pα q
,
pqβ + pα (q − qβ )
pα (q − qβ )
.
v= β
pq + pα (q − qβ )
u=
Finally,
x = pu + qv = pα−1
1 − pα
pα−1 + qβ−1 − pα−1 qβ−1
For example, in tossing a coin (p = 12 ) the probability that a run of
two heads appears before a run of three tails is 0,7.
Law of Total Probability. Method of recurrent equations
14 / 14