0% found this document useful (0 votes)
57 views13 pages

STAT 6100 - MATH 6180 Lecture 4 - Computing Expectations by Conditioning

The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive functioning. Exercise causes chemical changes in the brain that may help protect against mental illness and improve symptoms.

Uploaded by

Ramana Nimai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views13 pages

STAT 6100 - MATH 6180 Lecture 4 - Computing Expectations by Conditioning

The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive functioning. Exercise causes chemical changes in the brain that may help protect against mental illness and improve symptoms.

Uploaded by

Ramana Nimai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Computing Expectations by Conditioning

Review:

For discrete random variables 𝑋 and 𝑌, the conditional p.f. of 𝑋|𝑌 = 𝑦 is: 𝑓𝑋|𝑌=𝑦 (𝑥|𝑦) =
𝑓𝑋,𝑌 (𝑥,𝑦) 𝐽𝑜𝑖𝑛𝑡 𝑝.𝑓. 𝑜𝑓 𝑋 𝑎𝑛𝑑 𝑌
𝑃(𝑋 = 𝑥|𝑌 = 𝑦) = =
𝑓𝑌 (𝑦) 𝑀𝑎𝑟𝑔𝑖𝑛𝑎𝑙 𝑝.𝑓. 𝑜𝑓 𝑌

The conditional expectation, 𝐸[𝑋|𝑌 = 𝑦] = ∑𝑥 𝑥 𝑓𝑋|𝑌=𝑦 (𝑥|𝑦) = ∑𝑥 𝑥 𝑃(𝑋 = 𝑥|𝑌 = 𝑦)

For a particular value of 𝑦, 𝐸[𝑋|𝑌 = 𝑦] is a real number. It is an observed value of a


random variable 𝐸[𝑋|𝑌]

Theorem of Total Expectation: 𝐸𝑌 [ 𝐸(𝑋|𝑌) ] = 𝐸[𝑋]

Please read: Ross, Examples 3.2, 3.3

Note that conditional expectations have all the usual properties of unconditional
variances.

For example:
𝐸[ (𝑎𝑋 + 𝑏) |𝑌] = 𝑎 𝐸[𝑋|𝑌] + 𝑏
𝐸[ (𝑋1 + 𝑋2 ) |𝑌] = 𝐸[𝑋1 |𝑌] + 𝐸[𝑋2 |𝑌]

1
For discrete random variables 𝑋 and 𝑌, the Theorem of Total Expectation yields the
following:

𝐸[𝑋] = 𝐸𝑌 [ 𝐸(𝑋|𝑌) ] = ∑ 𝐸[𝑋|𝑌 = 𝑦] 𝑓𝑌 (𝑦) = ∑ 𝐸[𝑋|𝑌 = 𝑦] 𝑃(𝑌 = 𝑦)


𝑦 𝑦

We can use the result above to compute expectations by conditioning, i.e. find 𝐸[𝑋] by
conditioning on another random variable 𝑌.

We have already used this method – see the examples in Lecture 3. We now look at
some more examples.

Example: A miner is trapped in a mine containing three doors. The first door leads to a
tunnel that takes him to safety after two hours of travel. The second door leads to a
tunnel that returns him to the mine after three hours of travel. The third door leads to a
tunnel that returns him to his mine after five hours. The miner is at all times equally
likely to choose any one of the doors. His current choice of door is independent of his
previous choices. What is the expected length of time until the miner reaches safety?

Let 𝑋 be the time until the miner reaches safety (in hours).

Let 𝑌 be the number of the door he initially chooses (1 or 2 or 3).

We will find 𝐸[𝑋] by conditioning on 𝑌 and using the Theorem of Total Expectation.

By the Theorem of Total Expectation:


3
𝐸[𝑋] = 𝐸𝑌 [ 𝐸(𝑋|𝑌) ] = ∑ 𝐸[𝑋|𝑌 = 𝑦] 𝑓𝑌 (𝑦) = ∑ 𝐸[𝑋|𝑌 = 𝑦] 𝑃(𝑌 = 𝑦)
𝑦=1
𝑦

2
1
Now, 𝑃(𝑌 = 𝑖) = 𝑃(𝑚𝑖𝑛𝑒𝑟 𝑐ℎ𝑜𝑜𝑠𝑒𝑠 𝑑𝑜𝑜𝑟 𝑖) = ; 𝑖 = 1, 2, 3; since the miner is equally
3
likely to choose any one of the doors.

Given: 𝐸[𝑋|𝑌 = 1] = 2, since door 1 takes him to safety after two hours of travel.

𝐸[𝑋|𝑌 = 2] = 3 + 𝐸[𝑋]

Miner travels in a Then he returns to the mine.


tunnel for 3 hours
The procedure starts over,
since his current choice of door
is independent of his previous
choices.

Additional time to safety = 𝑋

Expected additional time to


safety = 𝐸[𝑋]

3
𝐸[𝑋|𝑌 = 3] = 5 + 𝐸[𝑋]

Miner travels in a Then he returns to the mine.


tunnel for 5 hours
The procedure starts over,
since his current choice of door
is independent of his previous
choices.

Additional time to safety = 𝑋

Expected additional time to


safety = 𝐸[𝑋]

By the Theorem of Total Expectation:

𝐸[𝑋] = 𝐸𝑌 [ 𝐸(𝑋|𝑌) ] = ∑ 𝐸[𝑋|𝑌 = 𝑦] 𝑓𝑌 (𝑦) = ∑ 𝐸[𝑋|𝑌 = 𝑦] 𝑃(𝑌 = 𝑦)


𝑦 𝑦

𝐸[𝑋] = 𝐸[𝑋|𝑌 = 1] 𝑃(𝑌 = 1) + 𝐸[𝑋|𝑌 = 2] 𝑃(𝑌 = 2) + 𝐸[𝑋|𝑌 = 3] 𝑃(𝑌 = 3)

1 1 1
𝐸[𝑋] = (2) + ( 3 + 𝐸[𝑋] ) + ( 5 + 𝐸[𝑋] )
3 3 3

Solve for 𝐸[𝑋] to obtain 𝐸[𝑋] = 10 hours.

4
Before examining the remaining examples, we will review the Geometric distribution.

Review: The Geometric Distribution

Suppose we have repeated, independent Bernoulli trials (i.e. outcome of each trial is
either success or failure), each with a probability of success 𝑝.

We repeat the trials until the first success is obtained.

Let 𝑁 = number of trials (including the first success)

Then 𝑁~𝐺𝑒𝑜𝑚𝑒𝑡𝑟𝑖𝑐(𝑝)

The probability function of 𝑁 is 𝑓𝑁 (𝑛) = (1 − 𝑝)𝑛−1 𝑝, 𝑛 = 1, 2, 3 …

1 1−𝑝
It can be shown that: 𝐸[𝑁] = , 𝑉𝑎𝑟[𝑁] =
𝑝 𝑝2

Let 𝑞 = 1 − 𝑝 = probability of failure. Suppose the experiment is: repeat the trials until
the first failure is obtained.

Let 𝑁2 = number of trials (including the first failure)


1 1−𝑞
Then it can easily be seen that 𝑁2 ~𝐺𝑒𝑜𝑚𝑒𝑡𝑟𝑖𝑐(𝑞), 𝐸[𝑁2 ] = , 𝑉𝑎𝑟[𝑁2 ] =
𝑞 𝑞2

5
Example:

A coin that comes up heads with probability 𝑝 is continually flipped until the pattern
H, T appears. (That is, you stop flipping when the most recent flip lands tails, and the
flip immediately preceding it lands on heads.) Let 𝑋 denote the number of flips made
and let 𝑞 = 1 − 𝑝.
1 𝑞
Show that 𝐸[𝑋] = 1 + +
𝑞 𝑝

Proof:

To help in visualizing the experiment, consider some possible outcomes of the


procedure:
1) 𝐻, 𝑇 𝑋=2
2) 𝐻, 𝐻, 𝑇 𝑋=3
3) 𝑇, 𝐻, 𝑇 𝑋=3
4) 𝐻, 𝐻, 𝐻, 𝑇 𝑋=4
5) 𝑇, 𝐻, 𝐻, 𝑇 𝑋=4
6) 𝑇, 𝑇, 𝐻, 𝑇 𝑋=4
and so on….

Let 𝑌 be the result of the first flip. We will find 𝐸[𝑋] by conditioning on 𝑌 and using
the Theorem of Total Expectation.
𝑃(𝑌 = 𝐻) = 𝑝, 𝑃(𝑌 = 𝑇) = 𝑞

By the Theorem of Total Expectation:

𝐸[𝑋] = 𝐸𝑌 [ 𝐸(𝑋|𝑌) ] = ∑ 𝐸[𝑋|𝑌 = 𝑦] 𝑓𝑌 (𝑦) = ∑ 𝐸[𝑋|𝑌 = 𝑦] 𝑃(𝑌 = 𝑦)


𝑦 𝑦

6
𝐸[𝑋] = 𝐸[𝑋|𝑌 = 𝐻] 𝑃(𝑌 = 𝐻) + 𝐸[𝑋|𝑌 = 𝑇] 𝑃(𝑌 = 𝑇)

𝐸[𝑋] = 𝑝 𝐸[𝑋|𝑌 = 𝐻] + 𝑞 𝐸[𝑋|𝑌 = 𝑇] (1)

We must find 𝐸[𝑋|𝑌 = 𝐻] and 𝐸[𝑋|𝑌 = 𝑇].

𝐸[𝑋|𝑌 = 𝐻] = 1 + 𝑒𝑥𝑝𝑒𝑐𝑡𝑒𝑑 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑓𝑙𝑖𝑝𝑠 𝑢𝑛𝑡𝑖𝑙 𝑡ℎ𝑒 𝑓𝑖𝑟𝑠𝑡 𝑇

First flip is First flip: H


H (given) The subsequent flips can be:

1) T – stop, since the pattern H,T has been obtained.


(Complete sequence: H,T)

2) H,T – stop, since the pattern H,T has been obtained.


(Complete sequence: H,H,T)

3) H,H,T – stop, since the pattern H,T has been obtained.


(Complete sequence: H,H,H,T)…and so on

Expected number of additional flips = expected number


of flips of a coin until the first T

If we consider H to be a “success” with probability 𝑝, and T to be a failure with


probability 𝑞, then:
𝐸[𝑋|𝑌 = 𝐻] = 1
+ 𝑒𝑥𝑝𝑒𝑐𝑡𝑒𝑑 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑖𝑛𝑑𝑒𝑝𝑒𝑛𝑑𝑒𝑛𝑡 𝐵𝑒𝑟𝑛𝑜𝑢𝑙𝑙𝑖 𝑡𝑟𝑖𝑎𝑙𝑠 𝑢𝑛𝑡𝑖𝑙 𝑓𝑖𝑟𝑠𝑡 𝑓𝑎𝑖𝑙𝑢𝑟𝑒

7
1
𝐸[𝑋|𝑌 = 𝐻] = 1 + (2)
𝑞

Now find 𝐸[𝑋|𝑌 = 𝑇]

𝐸[𝑋|𝑌 = 𝑇] = 1 + 𝑒𝑥𝑝𝑒𝑐𝑡𝑒𝑑 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑓𝑙𝑖𝑝𝑠 𝑢𝑛𝑡𝑖𝑙 𝐻, 𝑇 𝑎𝑝𝑝𝑒𝑎𝑟𝑠

First flip is T First flip: T. The pattern is ruined. Procedure starts over.
(given) We must continue flipping until the pattern H,T has been
obtained, i.e. the procedure starts over, as the flips are
independent.

Number of additional flips required = number of flips


required to obtain H,T = 𝑿

Expected number of additional flips required = 𝐸[𝑋]

𝐸[𝑋|𝑌 = 𝑇] = 1 + 𝐸[𝑋] (3)

Subs. (2) and (3) into (1):


1
𝐸[𝑋] = 𝑝 𝐸[𝑋|𝑌 = 𝐻] + 𝑞 𝐸[𝑋|𝑌 = 𝑇] = 𝑝 (1 + ) + 𝑞(1 + 𝐸[𝑋])
𝑞

1 𝑞
Solve for 𝐸[𝑋] to obtain 𝐸[𝑋] = 1 + + ∎
𝑞 𝑝

8
Example (Ross, Chapter 3, Page 177, Exercise 27):

A coin that comes up heads with probability 𝑝 is continually flipped until the pattern
T, T, H appears. (That is, you stop flipping when the most recent flip lands heads, and
the two flips immediately preceding it land on tails.)

Let 𝑋 denote the number of flips made and let 𝑞 = 1 − 𝑝.

Find an equation involving 𝐸[𝑋], 𝑝 and 𝑞. You do not need to solve the equation.

Let 𝑌 be the result of the first flip. We will find 𝐸[𝑋] by conditioning on 𝑌 and using
the Theorem of Total Expectation.

By the Theorem of Total Expectation:

𝐸[𝑋] = 𝐸𝑌 [ 𝐸(𝑋|𝑌) ] = ∑ 𝐸[𝑋|𝑌 = 𝑦] 𝑓𝑌 (𝑦) = ∑ 𝐸[𝑋|𝑌 = 𝑦] 𝑃(𝑌 = 𝑦)


𝑦 𝑦

𝐸[𝑋] = 𝐸[𝑋|𝑌 = 𝐻] 𝑃(𝑌 = 𝐻) + 𝐸[𝑋|𝑌 = 𝑇] 𝑃(𝑌 = 𝑇)


𝐸[𝑋] = 𝑝 𝐸[𝑋|𝑌 = 𝐻] + 𝑞 𝐸[𝑋|𝑌 = 𝑇] (1)

We must find 𝐸[𝑋|𝑌 = 𝐻] and 𝐸[𝑋|𝑌 = 𝑇].

9
𝐸[𝑋|𝑌 = 𝐻] = 1 + 𝑒𝑥𝑝𝑒𝑐𝑡𝑒𝑑 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑓𝑙𝑖𝑝𝑠 𝑢𝑛𝑡𝑖𝑙 𝑇, 𝑇, 𝐻 𝑎𝑝𝑝𝑒𝑎𝑟𝑠

First flip is First flip: H. The pattern is ruined. Procedure starts over.
H (given) We must continue flipping until the pattern T,T,H has
been obtained, i.e. the procedure starts over, as the flips
are independent.

Number of additional flips required = number of flips


required to obtain T,T,H = 𝑿

Expected number of additional flips required = 𝐸[𝑋]

𝐸[𝑋|𝑌 = 𝐻] = 1 + 𝐸[𝑋] (2)

To find 𝐸[𝑋|𝑌 = 𝑇], conditioning on the result of the second flip and use the Theorem of
Total Expectation.

Let 𝑍 be the result of the second flip.

By the Theorem of Total Expectation:

𝐸[𝑋|𝑌 = 𝑇] = 𝐸𝑍 [ 𝐸(𝑋|𝑌 = 𝑇, 𝑍 = 𝑧) ] = ∑ 𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝑧] 𝑃(𝑍 = 𝑧)


𝑧

𝐸[𝑋|𝑌 = 𝑇] = 𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝐻] 𝑃(𝑍 = 𝐻) + 𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝑇] 𝑃(𝑍 = 𝑇)


𝐸[𝑋|𝑌 = 𝑇] = 𝑝 𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝐻] + 𝑞 𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝑇] (3)

So we must find 𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝐻] and 𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝑇]

10
𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝐻] = 𝐸[𝑋 | 𝑓𝑖𝑟𝑠𝑡 𝑡𝑤𝑜 𝑓𝑙𝑖𝑝𝑠 𝑎𝑟𝑒 𝑇, 𝐻]

𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝐻] = 2 + 𝑒𝑥𝑝𝑒𝑐𝑡𝑒𝑑 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑓𝑙𝑖𝑝𝑠 𝑢𝑛𝑡𝑖𝑙 𝑇, 𝑇, 𝐻 𝑎𝑝𝑝𝑒𝑎𝑟𝑠

First two First two flips: T,H. The pattern is ruined. Procedure starts
flips are T,H over.
(given) We must continue flipping until the pattern T,T,H has
been obtained, i.e. the procedure starts over, as the flips
are independent.

Number of additional flips required = number of flips


required to obtain T,T,H = 𝑿

Expected number of additional flips required = 𝐸[𝑋]

𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝐻] = 2 + 𝐸[𝑋] (4)

11
𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝑇] = 𝐸[𝑋 | 𝑓𝑖𝑟𝑠𝑡 𝑡𝑤𝑜 𝑓𝑙𝑖𝑝𝑠 𝑎𝑟𝑒 𝑇, 𝑇]

𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝑇] = 2 + 𝑒𝑥𝑝𝑒𝑐𝑡𝑒𝑑 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑓𝑙𝑖𝑝𝑠 𝑢𝑛𝑡𝑖𝑙 𝑡ℎ𝑒 𝑓𝑖𝑟𝑠𝑡 𝐻

First two First two flips: T,T


flips are T,T The subsequent flips can be:
(given)
1) H – stop, since the pattern T,T,H has been obtained.
(Complete sequence: T,T,H)

2) T,H – stop, since the pattern T,T,H has been obtained.


(Complete sequence: T,T,T,H)

3) T,T,H – stop, since the pattern T,T,H has been obtained.


(Complete sequence: T,T,T,T,H)…and so on

Expected number of additional flips = expected number


of flips of a coin until the first H

If we consider H to be a “success” with probability 𝑝, and T to be a failure with


probability 𝑞, then:
𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝑇]
=2
+ 𝑒𝑥𝑝𝑒𝑐𝑡𝑒𝑑 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑖𝑛𝑑𝑒𝑝𝑒𝑛𝑑𝑒𝑛𝑡 𝐵𝑒𝑟𝑛𝑜𝑢𝑙𝑙𝑖 𝑡𝑟𝑖𝑎𝑙𝑠 𝑢𝑛𝑡𝑖𝑙 𝑓𝑖𝑟𝑠𝑡 𝑠𝑢𝑐𝑐𝑒𝑠𝑠

1
𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝑇] = 2 + (5)
𝑝

12
Subs. (4) and (5) into (3):

𝐸[𝑋|𝑌 = 𝑇] = 𝑝 𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝐻] + 𝑞 𝐸[𝑋|𝑌 = 𝑇, 𝑍 = 𝑇]

1
𝐸[𝑋|𝑌 = 𝑇] = 𝑝 (2 + 𝐸[𝑋]) + 𝑞 (2 + ) (6)
𝑝

Subs. (2) and (6) into (1):

𝐸[𝑋] = 𝑝 𝐸[𝑋|𝑌 = 𝐻] + 𝑞 𝐸[𝑋|𝑌 = 𝑇]

1
𝐸[𝑋] = 𝑝 ( 1 + 𝐸[𝑋] ) + 𝑞 [ 𝑝 (2 + 𝐸[𝑋]) + 𝑞 (2 + ) ]
𝑝

If you wish, you can solve for 𝐸[𝑋] and obtain:


1
𝐸[𝑋] =
𝑝 𝑞2

Exercise (Ross, Chapter 3, Page 177, Exercise 24):: A coin, having probability 𝑝 of
landing heads, is flipped repeatedly until at least one head and at least one tail have
been obtained. Note that the head and the tail do not have to be consecutive.

Let 𝑋 denote the number of flips made and let 𝑞 = 1 − 𝑝. Find 𝐸[𝑋] in terms of 𝑝 and 𝑞.

Hint: Condition on the result of the first flip.

1 1
Answer: 𝐸[𝑋] = 𝑝 (1 + ) + 𝑞 (1 + )
𝑞 𝑝

13

You might also like