1 of 64

ME5751�Robotics Motion Planning

Yizhe Chang chang@cpp.edu

Lecture Note Set #15-16

2 of 64

Outline

  • Probability and Conditional Probability
  • Bayes Rule
  • Self-study: Gaussian Mixture Model
  • Markov Chain
  • Hidden Markov model
  • Using HMM: Markov Localization

3 of 64

People

Andrey Andreyevich Markov (1856–1922)

Russian Mathematician

Professor, Saint Petersburg State University

Thomas Bayes (1701- 1761)

English statistician, philosopher and Presbyterian minister

One known mathematics publication

Bayes’ Theorem was presented after his death by Richard Price

Richard Price (1723-1791)

British moral philosopher, nonconformist preacher and mathematician

Formally described Bayes’ theorem Considered Bayes’ theorem helped prove the existence of God

Image from Wikipedia.org

4 of 64

Basic concept

  •  

5 of 64

Basic concept

  •  

6 of 64

Basic concept

  •  

7 of 64

Joint distribution

  •  

8 of 64

Conditional probability

  •  

9 of 64

Conditional probability: example

  • In a group of 100 sports car buyers,
    • 40 bought alarm systems,
    • 30 purchased bucket seats,
    • and 20 purchased an alarm system and bucket seats.
  • If a car buyer chosen at random bought an alarm system, what is the probability they also bought bucket seats?

10 of 64

Conditional probability: example

  • In a group of 100 sports car buyers,
    • 40 bought alarm systems,
    • 30 purchased bucket seats,
    • and 20 purchased an alarm system and bucket seats.
  • If a car buyer chosen at random bought an alarm system, what is the probability they also bought bucket seats?

11 of 64

Conditional probability

  •  

12 of 64

Conditional probability

  • We throw two dices in a sequence
    • probability of first throw P(A=5) to get 5?
    • probability of second throw to get 5, given first throw is 5? P(B=5|A=5)
  • Your intuition answer is?

13 of 64

Conditional probability

  •  

14 of 64

Theorem of total probability

  •  

15 of 64

Bayes rule

  •  

16 of 64

Bayes rule

  • Bayes rule relate conditional probability p(x|y) to its inverse p(y|x)

17 of 64

Bayes rule example

  • In brushfire prevention
    • Dangerous fire is rare P(X=Fire)=0.01
    • Smoke observation is common P(Y=Smoke)=0.1, (because people make barbecue…)
    • Chance of smoke is timely observed when dangerous fire happen: P(Y=Smoke|X=Fire)=0.9
  • What is the probability of having dangerous fire, when we observed observe smoke? P(X=Fire|Y=Smoke)?

18 of 64

Bayes rule example

  •  

19 of 64

Bayes rule example

  • You are planning a picnic today, but the morning is cloudy
    • We go to whether department, 50% rain starts with a cloudy moring: P(Cloudy|Rain) =0.5
    • We ask our grandma: P(Cloudy) = 0.4
    • We checked climate book, in this “dry” month: P(Rain) = 0.1
  • What is the probability of rain today? P(Rain|Cloudy)

20 of 64

Bayes rule example: Evidence not clear

  •  Suppose that we have two bags each containing black and white balls.
    • Bag A contains three times as many white balls as blacks.
    • Bag B contains three times as many black balls as white.
  • Suppose we choose one of these bags at random.
  • For this bag we draw five balls randomly; we put the ball back after drawing. The result is that we find 4 white balls and one black.
  • What is the probability that we were using bag A (mainly white balls?)

21 of 64

Bayes rule example: Evidence not clear

  •  

22 of 64

Bayes rule example: Evidence not clear

  •  

23 of 64

Evidence not needed: normalization

  •  

24 of 64

Evidence not needed: normalization

  •  

25 of 64

Outline

  • Probability and Conditional Probability
  • Bayes Rule
  • Self-study: Gaussian Mixture Model
  • Markov Chain
  • Hidden Markov model
  • Using HMM: Markov Localization

26 of 64

Gaussian mixture model

  •  

μ = 3, σ = 2

μ = 4, σ = 3

??

27 of 64

Gaussian mixture model

  •  

28 of 64

Gaussian mixture model

  •  

μ = 3, σ = 2

μ = 4, σ = 3

??

29 of 64

Gaussian mixture model

  •  

30 of 64

Gaussian mixture model

31 of 64

Outline

  • Probability and Conditional Probability
  • Bayes Rule
  • Self-study: Gaussian Mixture Model
  • Markov Chain
  • Hidden Markov model
  • Using HMM: Markov Localization

32 of 64

Bayes rule

  • Bayes rule relate conditional probability p(x|y) to its inverse p(y|x)

33 of 64

Markov Chain 101

  • Suppose the weather can be rainy and sunny, the following diagram depicts the transition from one day to another:
    • A - Rainy
    • B - Sunny

  • What does this diagram mean??
    • P(A|A) = 0.3
    • P(B|A) = 0.7
    • P(A|B) = 0.8
    • P(B|B) = 0.2

Previous state

Next state

Previous Next

A

B

A

0.3

0.7

B

0.8

0.2

34 of 64

Markov Chain: forward propagation

  • State transition: A-A-B, or A-B-B
  • P(A|A) = 0.3
  • P(B|A) = 0.7

A

B

A: Rainy 0.3

B: Sunny 0.7

Day 1- Rainy: 0.3*0.7

Day 1- Sunny: 0.7*0.2

Day 1

Day 2

Day 3

35 of 64

Markov Chain: forward propagation

  • What is the probability the 3rd day sunny?

  • State transition: A-A-B, or A-B-B
  • P(x3=B, x2=A, x1=A) = 0.3*0.7= 0.21
  • P(x3=B, x2=B, x1=A) = 0.7*0.2 = 0.14
  • P(x3=B) = 0.21+0.14= 0.35

A

B

A: Rainy 0.3

B: Sunny 0.7

Day 1- Rainy: 0.3*0.3

Day 1- Sunny: 0.7*0.2

Day 1

Day 2

Day 3

36 of 64

Markov Chain: forward propagation

  • What if we ask the probability the third day is raining? (A)

  • State transition: A-A-B, or A-B-B
  • P(x3=A, x2=A, x1=A) = 0.3*0.3= 0.09
  • P(x3=A, x2=B, x1=A) = 0.7*0.8 = 0.56
  • P(x3=A) =0.09+0.56= 0.65

P(x3=B) + P(x3=A) =1

A

A

A: Rainy 0.3

B: Sunny 0.7

Day 1- Rainy: 0.3*0.3

Day 1- Sunny: 0.7*0.8

Day 1

Day 2

Day 3

37 of 64

A 1st order Markov Chain

  • The state at Xt+1 is only related to the state at Xt
  • That is:
    • P(Xt+1|Xt) = P(Xt+1|Xt,Xt-1, Xt-2, … X0)

38 of 64

E.g. Student Markov chain

39 of 64

Student Markov Chain

40 of 64

Student Markov Chain

  • n-step transition

pn = p*p*p…

Every element represent

the chance after nth transition

41 of 64

More classical transitions for Markov chain

  • Drunkard’s walk: 5 bars on a street, 50% go next, 50% go previous. If the drunkard starts in bar 2, what is the chance he ends up in bar 0 in
    • 2 steps?
    • 3 steps?
    • 4 steps?

42 of 64

More classical transitions for Markov chain

  • Land of Oz
    • This strange place will never have 2 consecutive good nice whether day

43 of 64

Outline

  • Probability and Conditional Probability
  • Bayes Rule
  • Self-study: Gaussian Mixture Model
  • Markov Chain
  • Hidden Markov model
  • Using HMM: Markov Localization

44 of 64

Hidden Markov model

  • What if
    • The state a transition:

  • We cannot directly observe the state x
  • We know the transition depends on previous input u, and previous state x
  • We can observe an output/observance z
  • Can we infer the next state? P(xt+1)?

X0

X1

X2

u0

u1

z0

z1

z2

45 of 64

Hidden Markov model

  • What if we have a model:

  • We know:

X0

X1

X2

u0

u1

z0

z1

z2

Previous

Rain

Sunny

x=Rain, u =Rain

0.8

0.2

x=Rain, u =sun

0.4

0.6

x= Sun, u= Rain

0.7

0.3

X= Sun, u= sun

0.6

0.4

State

Cat Sleep

Cat Outdoor

Rain

0.8

0.2

Sun

0.2

0.8

46 of 64

Hidden Markov Model

  • Question
  • We know
    • we know day 0 it is x0 = rain
    • we “prayed” at day 0 u0 = rain, day 2 u1 = rain

  • We also observed:
    • Cat sleeps at day 1 z1 = L, sleeps at day 2 z2= L
  • What is the chance that at day 2 it is rainy? sunny?

47 of 64

Hidden Markov Model

  •  

48 of 64

Hidden Markov Model

X0

X1

X2

u0

u1

z0

z1

z2

Previous

X=R

X=S

x=R, u =R

0.8

0.2

x=R, u =S

0.4

0.6

x= S, u= R

0.7

0.3

X= S, u= S

0.6

0.4

State

Sleep (L)

Out (O)

Rain

0.8

0.2

Sun

0.2

0.8

 

49 of 64

Hidden Markov Model

X0

X1

X2

u0

u1

z0

z1

z2

 

R

0.8

S

0.2

50 of 64

Posterior for day 1 being rainy and sunny

  •  

51 of 64

HMM: update after a new observation

X0

X1

X2

u0

u1

z0

z1

z2

 

R

0.8

S

0.2

 

R

0.941

S

0.059

52 of 64

Probability for day 2, given cat sleeps on day 1

  •  

Posterior from previous day!

53 of 64

HMM: new state prior from previous update

X0

X1

X2

u0

u1

z0

z1

z2

 

R

0.8

S

0.2

 

R

0.941

S

0.059

 

R

0.794

S

0.206

54 of 64

Posterior for day 2 being rainy

  •  

55 of 64

HMM: update after a new observation

X0

X1

X2

u0

u1

z0

z1

z2

 

R

0.8

S

0.2

 

R

0.941

S

0.059

 

R

0.794

S

0.206

 

R

0.939

S

0.061

56 of 64

What happened just now?

  • We update the posterior P(Xn|Zn) by:
    • Update Day1 Prior -> Posterior

    • Day 2 Prior -> Posterior

Prior (Related to state transition, and previous posterior)

Posterior (After a new observation)

P(X1 = R|X0,U0=R)

P(X1 = S|X0,U0=R)

P(X1 = R|z1 = L)

P(X1=S|z1 = L)

0.8

0.2

0.941

0.059

Prior (Related to state transition, and previous posterior)

Posterior (After a new observation )

P(X2 = R|X1,U1=R)

P(X2 = S|X1,U1=R)

P(X2 = R|z2 = L)

P(X2=S|z2 = L)

0.794

0.206

0.939

0.061

57 of 64

Outline

  • Probability and Conditional Probability
  • Bayes Rule
  • Self-study: Gaussian Mixture Model
  • Markov Chain
  • Hidden Markov model
  • Using HMM: Markov Localization

58 of 64

A simple 2D localization story

  • Our robot is approaching a wall
    • We have a wheel encoder, we know the update of position for each interval follows a distribution h(xt|xt-1,ut-1) (State transition table)
    • We have a lidar, every time gap, we are sensing the distance to the wall (thus we know the position of the robot). We know the error of lidar follow a distribution P(zt|xt) (output table)
  • Can we know where are we? (i.e. calculate bel(xt|zt))?

8

7

6

5

4

3

2

1

0

xt

59 of 64

A simple 2D localization story

  • In this configuration, how many column and rows we expect for state transition diagram?
  • Or it is a distribution h(xt|xt-1,ut-1)

Previous

X=R

X=S

x=R, u =R

0.8

0.2

x=R, u =S

0.4

0.6

x= S, u= R

0.7

0.3

X= S, u= S

0.6

0.4

Previous

X=0

X=1

X=8

x=0, u =1

x=0, u =2

x=0, u= -1

X=0, u= -2

X=1, u=0

X=1, u=1

X=7, u= 0

X=7, u =1

60 of 64

A simple 2D localization story

  • How about output (emission?)
  • By your intuition, what should be the biggest value for x=0?
  • Or it is continuous o(zt|xt)

State

Sleep (L)

Out (O)

Rain

0.8

0.2

Sun

0.2

0.8

State

Z = 0

Z=1

Z=7

Z=8

X=0

X=1

X=2

X=3

X=8

8

7

6

5

4

3

2

1

0

xt

61 of 64

Change of story for robotics

  •  

Prior (Related to state transition, and previous posterior)

Posterior (Related to output and prior)

P(X1 = R|X0,U0=R)

P(X1 = S|X0,U0=R)

P(X1 = R|z1 = L)

P(X1=S|z1 = L)

0.8

0.2

0.941

0.059

62 of 64

Change of predict belief

  •  

63 of 64

Change of correction belief

  •  

64 of 64

Markov localization