tutorial: markov chains - duke university

39
Tutorial: Markov Chains Steve Gu Feb 28, 2008

Upload: others

Post on 05-Oct-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Tutorial: Markov Chains - Duke University

Tutorial: Markov Chains

Steve Gu

Feb 28, 2008

Page 2: Tutorial: Markov Chains - Duke University

Outline

• Markov chain

• Applications

– Weather forecasting

– Enrollment assessment

– Sequence generation

– Rank the web page

– Life cycle analysis

• Summary

Page 3: Tutorial: Markov Chains - Duke University

History

• The origin of Markov chains is due to Markov, a Russian mathematician who first published in the Imperial Academy of Sciences in St. Petersburg in 1907, a paper studying the statistical behavior of the letters in Onegin, a well known poem of Pushkin.

Page 4: Tutorial: Markov Chains - Duke University

A Markov Chain

"0" "1"

P01

P11

P10

P00

Page 5: Tutorial: Markov Chains - Duke University

Transition Probability Table

P

P P P

P P P

P P P

11 12 13

21 22 23

31 32 33

P = 0.7 P = 0.2 P = 0.1

P = 0. P = 0.6 P = 0.4

P = 0.3 P = 0.5 P = 0.2

11 12 13

21 22 23

31 32 33

P i n j n and Pij ijj

n

0 1 1 1

1

, = ,..., ; = ,...,

=

Page 6: Tutorial: Markov Chains - Duke University

Example 1: Weather Forecasting[1]

Page 7: Tutorial: Markov Chains - Duke University

Weather Forecasting• Weather forecasting example:

– Suppose tomorrow’s weather depends on today’s weather only.

– We call it an Order-1 Markov Chain, as the transition function depends on the current state only.

– Given today is sunny, what is the probability that the coming days are sunny, rainy, cloudy, cloudy, sunny ?

– Obviously, the answer is : (0.5)(0.4)(0.3)(0.5) (0.2) = 0.0054

sunny rainy

0.5

0.4 0.3

0.2

cloudy

0.1

0.30.3

0.4

0.5

Page 8: Tutorial: Markov Chains - Duke University

Weather Forecasting• Weather forecasting example:

– Given today is sunny, what is the probability that it will be rainy 4 days later?

– We only knows the start state, the final state and the input length = 4

– There are a number of possible combinations of states in between.

sunny rainy

0.5

0.3

0.4 0.3

0.3

0.4

0.1

0.2

cloudy

0.5

Page 9: Tutorial: Markov Chains - Duke University

Weather Forecasting• Weather forecasting example:

– Chapman-Kolmogorov Equation:

– Transition Matrix:

sunny rainy

0.5

0.3

0.4 0.3

0.3

0.4

0.1

0.2

cloudy

0.5

5.03.02.0

3.04.03.0

1.04.05.0

0

)()()(

k

m

kj

n

ik

mn

ij PPP

s r c

s

r

c

Page 10: Tutorial: Markov Chains - Duke University

Weather Forecasting• Weather forecasting example:

– Two days:

– Four days:

sunny rainy

0.5

0.3

0.4 0.3

0.3

0.4

0.1

0.2

cloudy

0.5

5.03.02.0

3.04.03.0

1.04.05.0

2

5.03.02.0

3.04.03.0

1.04.05.0

2

5.03.02.0

3.04.03.0

1.04.05.0

5.03.02.0

3.04.03.0

1.04.05.0

36.035.029.0

30.037.033.0

22.039.039.0

(00 x 01) + (01 x 11) + (02 x 21) 01

2984.03686.03330.0

2916.03706.03378.0

2820.03734.03446.0

Page 11: Tutorial: Markov Chains - Duke University

Weather Forecasting• Weather forecasting example:

– What is the probability that today is cloudy?

– There are infinite number of days before today.

– It is equivalent to ask the probability after infinite number of days.

– We do not care the “start state” as it brings little effect when there are infinite number of states.

– We call it the “Limiting probability” when the machine becomes steady.

sunny rainy

0.5

0.3

0.4 0.3

0.3

0.4

0.2

cloudy

0.5

0.1

Page 12: Tutorial: Markov Chains - Duke University

Weather Forecasting• Weather forecasting example:

– Since the start state is “don’t care”, instead of forming a 2-D matrix, the limiting probability is express a a single row matrix :

– Since the machine is steady, the limiting probability does not change even it goes one more step.

sunny rainy

0.5

0.3

0.4 0.3

0.3

0.4

0.2

cloudy

0.5

210 ,,

0.1

Page 13: Tutorial: Markov Chains - Duke University

Weather Forecasting• Weather forecasting example:

– So the limiting probability can be computed by:

– We have probability that today is cloudy =

sunny rainy

0.5

0.3

0.4 0.3

0.3

0.4

0.2

cloudy

0.5

0.1

210 ,,

5.03.02.0

3.04.03.0

1.04.05.0

210 ,,

)62

18,

62

23,

62

21(,, 210

62

18

Page 14: Tutorial: Markov Chains - Duke University

Example 2: Enrollment Assessment [1]

Page 15: Tutorial: Markov Chains - Duke University

Undergraduate Enrollment Model

Graduate

Freshmen Sophomore Junior Senior

Stop Out

Page 16: Tutorial: Markov Chains - Duke University

State Transition Probabilities

Fr So Jr Sr S/O Gr

Fr .2 .65 0 0 .14 .01

So 0 .25 .6 0 .13 .02

TP = Jr 0 0 .3 .55 .12 .03

Sr 0 0 0 .4 .05 .55

S/O 0.1 0.1 0.4 0.1 0.3 0

Gr 0 0 0 0 0 1

Page 17: Tutorial: Markov Chains - Duke University

Enrollment Assessment

Graduate

Freshmen Sophomore Junior Senior

Stop Out

Given:Transition probability table & Initial enrollment estimation,

we can estimate the number of students at each time point

Fr So Jr Sr S/O Gr

Fr .2 .65 0 0 .14 .01

So 0 .25 .6 0 .13 .02

TP = Jr 0 0 .3 .55 .12 .03

Sr 0 0 0 .4 .05 .55

S/O 0.1 0.1 0.4 0.1 0.3 0

Gr 0 0 0 0 0 1

Page 18: Tutorial: Markov Chains - Duke University

Example 3: Sequence Generation[3]

Page 19: Tutorial: Markov Chains - Duke University

Sequence Generation

Page 20: Tutorial: Markov Chains - Duke University

Markov Chains as Models ofSequence Generation

• 0th-order

• 1st-order

• 1th-order

• 2

• 2nd-order

N

i

ii sssssssssP2

11231211 |pp|p|pp

N

i

iii ssssssssssssssP3

1221324213212 |pp|p|pp

N

i

isssssP1

3210 pppp

4321 sssss

N

i

ii sssactatttsP2

111 |pp|p|p|pp

N

i

iii sssssacgtacttattsP3

12212 |pp|p|p|pp

N

i

isgcattsP1

0 pppppp

ttacggts

Page 21: Tutorial: Markov Chains - Duke University

A Fifth Order Markov Chain

Page 22: Tutorial: Markov Chains - Duke University

Example 4: Rank the web page

Page 23: Tutorial: Markov Chains - Duke University

PageRankHow to rank the importance of web pages?

Page 24: Tutorial: Markov Chains - Duke University

PageRank

http://en.wikipedia.org/wiki/Image:PageRanks-Example.svg

Page 25: Tutorial: Markov Chains - Duke University

PageRank: Markov Chain

For N pages, say p1,…,pN

Write the Equation to compute PageRank as:

where l(i,j) is define to be:

Page 26: Tutorial: Markov Chains - Duke University

PageRank: Markov Chain

• Written in Matrix Form:

1 1

2 2

N-1 N-1

N N

PR(p ,n +1) PR(p ,n)l(1,1) l(1,2) l(1,N)

PR(p ,n +1) PR(p ,n)l(2,1) l(2,2) l(2,N)

PR(p ,n +1) PR(p ,n)l(N,1) l(N,N -1) l(N,N)

PR(p ,n +1) PR(p ,n)

Page 27: Tutorial: Markov Chains - Duke University

Example 5: Life Cycle Analysis[4]

Page 28: Tutorial: Markov Chains - Duke University

How to model life cycles of Whales?

http://www.specieslist.com/images/external/Humpback_Whale_underwater.jpg

Page 29: Tutorial: Markov Chains - Duke University

Life cycle analysis

calf immature mature mom Post-mom

dead

In real application, we need to specify

or learn the transition probability table

Page 30: Tutorial: Markov Chains - Duke University

June 2006 Hal Caswell -- Markov Anniversary Meeting 30

Application: The North Atlantic right whale (Eubalaena glacialis)

Page 31: Tutorial: Markov Chains - Duke University

June 2006 Hal Caswell -- Markov Anniversary Meeting 31

calving

feeding

Endangered, by any

standard

N < 300 individuals

Minimal recovery since

1935

Ship strikes

Entanglement with fishing

gear

Page 32: Tutorial: Markov Chains - Duke University

June 2006 Hal Caswell -- Markov Anniversary Meeting 32

2030: died October 1999

entanglement

1014 “Staccato” died April 1999 ship strike

Mortality and serious injury

due to entanglement and ship strikes

Page 33: Tutorial: Markov Chains - Duke University

June 2006 Hal Caswell -- Markov Anniversary Meeting 33

1980 1984 1988 1992 1996

0.82

0.84

0.86

0.88

0.9

0.92

0.94

0.96Calf s

urv

ival

time trend

best model

Year

Page 34: Tutorial: Markov Chains - Duke University

June 2006 Hal Caswell -- Markov Anniversary Meeting 34

1980 1984 1988 1992 19960.6

0.65

0.7

0.75

0.8

0.85

0.9

0.95

1M

oth

er

surv

ival

time trendbest model

Year

Page 35: Tutorial: Markov Chains - Duke University

June 2006 Hal Caswell -- Markov Anniversary Meeting 35

1980 1984 1988 1992 19960.1

0.15

0.2

0.25

0.3

0.35

0.4

0.45

0.5Bir

thpro

bability

time trendbest model

Year

Page 36: Tutorial: Markov Chains - Duke University

June 2006 Hal Caswell -- Markov Anniversary Meeting 36

1980 1982 1984 1986 1988 1990 1992 1994 1996 199810

20

30

40

50

60

70

Year

Lif

e e

xp

ec

tan

cy

period

Things don’t look good for the right whale!

Page 37: Tutorial: Markov Chains - Duke University

Summary

• Markov Chains: state transition model

• Some applications

– Natural Language Modeling

– Weather forecasting

– Enrollment assessment

– Sequence generation

– Rank the web page

– Life cycle analysis

– etc (Hopefully you will find more )

Page 38: Tutorial: Markov Chains - Duke University

Thank you

Q&A

Page 39: Tutorial: Markov Chains - Duke University

Reference

[1] http://adammikeal.org/courses/compute/presentations/Markov_model.ppt[2] http://uaps.ucf.edu/doc/AIR2006MarkovChain051806.ppt[3]http://germain.umemat.maine.edu/faculty/khalil/courses/MAT500/JGraber/genes2007.ppt[4] http://www.csc2.ncsu.edu/conferences/nsmc/MAM2006/caswell.ppt