CS 287 Lecture 11 (Fall 2019) Probability Review, Bayes Filters, - - PowerPoint PPT Presentation

cs 287 lecture 11 fall 2019 probability review bayes
SMART_READER_LITE
LIVE PREVIEW

CS 287 Lecture 11 (Fall 2019) Probability Review, Bayes Filters, - - PowerPoint PPT Presentation

CS 287 Lecture 11 (Fall 2019) Probability Review, Bayes Filters, Gaussians Pieter Abbeel UC Berkeley EECS Many slides adapted from Thrun, Burgard and Fox, Probabilistic Robotics Outline n Probability Review n Bayes Filters n Gaussians Why


slide-1
SLIDE 1

CS 287 Lecture 11 (Fall 2019) Probability Review, Bayes Filters, Gaussians

Pieter Abbeel UC Berkeley EECS

Many slides adapted from Thrun, Burgard and Fox, Probabilistic Robotics

slide-2
SLIDE 2

Outline

n Probability Review n Bayes Filters n Gaussians

slide-3
SLIDE 3

n Often the state of the robot and of its environment are unknown

and only noisy sensors are available

n Probability provides a framework to fuse sensory information à Result: probability distribution over possible states of robot and environment

n Dynamics is often stochastic, hence can’t optimize for a particular

  • utcome, but only optimize to obtain a good distribution over
  • utcomes

n Probability provides a framework to reason in this setting à Ability to find good control policies for stochastic dynamics and environments

Why probability in robotics?

slide-4
SLIDE 4

n

State: position, orientation, velocity, angular rate

n

Sensors:

n GPS : noisy estimate of position (sometimes also velocity) n Inertial sensing unit: noisy measurements from

(i)

3-axis gyro [=angular rate sensor],

(ii) 3-axis accelerometer [measures acceleration + gravity; e.g., measures

(0,0,0) in free-fall],

(iii) 3-axis magnetometer

n

Dynamics:

n Noise from: wind, unmodeled dynamics in engine, servos, blades

Example 1: Helicopter

slide-5
SLIDE 5

n

State: position and heading

n

Sensors:

n Odometry (=sensing motion of actuators): e.g., wheel encoders n Laser range finder:

n Measures time of flight of a laser beam between departure and return n Return is typically happening when hitting a surface that reflects the beam

back to where it came from

n Dynamics:

n Noise from: wheel slippage, unmodeled variation in floor

Example 2: Mobile robot inside building

slide-6
SLIDE 6

Outline

n Probability Review n Bayes Filters n Gaussians

slide-7
SLIDE 7

Axioms of Probability Theory

1 ) Pr( £ £ A

Pr(Ω) =1 Pr(A∪B) = Pr(A)+ Pr(B)− Pr(A∩B) Pr(φ) = 0

Pr(A) denotes probability that the outcome ω is an element of the set of possible outcomes A. A is often called an event. Same for B. Ω is the set of all possible outcomes. ϕ is the empty set.

slide-8
SLIDE 8

Using the Axioms

Pr(A∪(Ω \ A)) = Pr(A)+ Pr(Ω \ A)− Pr(A∩(Ω \ A)) Pr(Ω) = Pr(A)+ Pr(Ω \ A)− Pr(φ) 1 = Pr(A)+ Pr(Ω \ A)− 0 Pr(Ω \ A) = 1− Pr(A)

slide-9
SLIDE 9

Discrete Random Variables

n

X denotes a random variable.

n

X can take on a countable number of values in {x1, x2, …, xn}.

n

P(X=xi), or P(xi), is the probability that the random variable X takes

  • n value xi.

n

P(.) is called probability mass function.

n

E.g., X models the outcome of a coin flip, x1 = head, x2 = tail, P( x1 ) = 0.5 , P( x2 ) = 0.5

x1

Ω

x2 x4 x3

slide-10
SLIDE 10

Continuous Random Variables

n

X takes on values in the continuum.

n

p(X=x), or p(x), is a probability density function.

n

E.g.

ò

= Î

b a

dx x p b a x ) ( )) , ( Pr(

x p(x)

slide-11
SLIDE 11

Joint and Conditional Probability

n

P(X=x and Y=y) = P(x,y)

n

X and Y are independent iff P(x,y) = P(x) P(y)

n

P(x | y) is the probability of x given y P(x | y) = P(x,y) / P(y) P(x,y) = P(x | y) P(y)

n

If X and Y are independent then P(x | y) = P(x)

n

Same for probability densities, just P à p

slide-12
SLIDE 12

Law of Total Probability, Marginals

å

=

y

y x P x P ) , ( ) (

å

=

y

y P y x P x P ) ( ) | ( ) (

å

=

x

x P 1 ) (

Discrete case

ò

=1 ) ( dx x p

Continuous case

ò

= dy y p y x p x p ) ( ) | ( ) (

ò

= dy y x p x p ) , ( ) (

slide-13
SLIDE 13

Bayes Rule

evidence prior likelihood ) ( ) ( ) | ( ) ( ) ( ) | ( ) ( ) | ( ) , ( × = = Þ = = y P x P x y P y x P x P x y P y P y x P y x P

slide-14
SLIDE 14

Normalization

) ( ) | ( 1 ) ( ) ( ) | ( ) ( ) ( ) | ( ) (

1

x P x y P y P x P x y P y P x P x y P y x P

x

å

= = = =

  • h

h

y x x y x y x

y x P x x P x y P x

| | |

aux ) | ( : aux 1 ) ( ) | ( aux : h h = " = = "

å

Algorithm:

slide-15
SLIDE 15

Conditioning

n

Law of total probability:

ò ò ò

= = = dz y z P z y x P y x P dz z P z x P x P dz z x P x P ) | ( ) , | ( ) ( ) ( ) | ( ) ( ) , ( ) (

slide-16
SLIDE 16

Bayes Rule with Background Knowledge

) | ( ) | ( ) , | ( ) , | ( z y P z x P z x y P z y x P =

slide-17
SLIDE 17

equivalent to and

Conditional Independence

) | ( ) | ( ) , ( z y P z x P z y x P = ) , | ( ) ( y z x P z x P = ) , | ( ) ( x z y P z y P =

slide-18
SLIDE 18

Simple Example of State Estimation

n

Suppose a robot obtains measurement z

n

What is P(open|z)?

slide-19
SLIDE 19

Causal vs. Diagnostic Reasoning

n P(open|z) is diagnostic. n P(z|open) is causal. n Often causal knowledge is easier to obtain. n Bayes rule allows us to use causal knowledge:

) ( ) ( ) | ( ) | ( z P

  • pen

P

  • pen

z P z

  • pen

P =

count frequencies!

slide-20
SLIDE 20

Example

n

P(z|open) = 0.6 P(z|¬open) = 0.3

n

P(open) = P(¬open) = 0.5

67 . 3 2 5 . 3 . 5 . 6 . 5 . 6 . ) | ( ) ( ) | ( ) ( ) | ( ) ( ) | ( ) | ( = = × + × × = ¬ ¬ + = z

  • pen

P

  • pen

p

  • pen

z P

  • pen

p

  • pen

z P

  • pen

P

  • pen

z P z

  • pen

P

  • z raises the probability that the door is open.

P(open | z) = P(z | open)P(open) P(z)

slide-21
SLIDE 21

Combining Evidence

n Suppose our robot obtains another observation z2. n How can we integrate this new information? n More generally, how can we estimate

P(x| z1...zn )?

slide-22
SLIDE 22

Recursive Bayesian Updating

) , , | ( ) , , | ( ) , , , | ( ) , , | (

1 1 1 1 1 1 1

  • =

n n n n n n

z z z P z z x P z z x z P z z x P ! ! ! !

Markov assumption: zn is independent of z1,...,zn-1 if we know x.

P(x | z1,…, zn) = P(zn | x) P(x | z1,…, zn − 1) P(zn | z1,…, zn − 1) =η P(zn | x) P(x | z1,…, zn − 1) =η1...n P(zi | x)

i=1...n

# $ % & ' (P(x)

slide-23
SLIDE 23

Example: Second Measurement

n

P(z2|open) = 0.5 P(z2|¬open) = 0.6

n

P(open|z1)=2/3

625 . 8 5 3 1 5 3 3 2 2 1 3 2 2 1 ) | ( ) | ( ) | ( ) | ( ) | ( ) | ( ) , | (

1 2 1 2 1 2 1 2

= = × + × × = ¬ ¬ + = z

  • pen

P

  • pen

z P z

  • pen

P

  • pen

z P z

  • pen

P

  • pen

z P z z

  • pen

P

  • z2 lowers the probability that the door is open.
slide-24
SLIDE 24

A Typical Pitfall

n Two possible locations

x1 and x2

n P(x1)=0.99 n P(z|x2)=0.09

P(z|x1)=0.07

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 5 10 15 20 25 30 35 40 45 50 p( x | d) Number of integrations p(x2 | d) p(x1 | d)

If measurements are not independent but are treated as independent à can quickly end up overconfident

slide-25
SLIDE 25

Outline

n Probability Review n Bayes Filters n Gaussians

slide-26
SLIDE 26

Actions

n Often the world is dynamic since

n actions carried out by the robot, n actions carried out by other agents, n or just the time passing by

change the world.

n How can we incorporate such actions?

slide-27
SLIDE 27

Typical Actions

n

The robot turns its wheels to move

n

The robot uses its manipulator to grasp an object

n

Plants grow over time…

n

Actions are never carried out with absolute certainty.

n

In contrast to measurements, actions generally increase the uncertainty.

slide-28
SLIDE 28

Modeling Actions

n To incorporate the outcome of an action u into the

current “belief”, we use the conditional pdf P(x’|u,x)

n This term specifies the pdf that executing u changes

the state from x to x’.

slide-29
SLIDE 29

Example: Closing the door

slide-30
SLIDE 30

State Transitions

P(x’|u,x) for u = “close door”:

If the door is open, the action “close door” succeeds in 90% of all cases.

  • pen

closed 0.1 1 0.9

slide-31
SLIDE 31

Integrating the Outcome of Actions

P(x' | u) = P(x' | u, x)P(x)dx

P(x' | u) = P(x' | u, x)P(x)

Continuous case: Discrete case:

slide-32
SLIDE 32

Example: The Resulting Belief

P(closed | u) = P(closed | u, x)P(x)

= P(closed | u,open)P(open) + P(closed | u,closed)P(closed) = 9 10 ∗ 5 8 +1 1∗ 3 8 = 15 16 P(open | u) = P(open | u, x)P(x)

= P(open | u,open)P(open) + P(open | u,closed)P(closed) = 1 10 ∗ 5 8 + 0 1 ∗ 3 8 = 1 16 =1− P(closed | u)

slide-33
SLIDE 33

n Bayes rule

Measurements

P(x z) = P(z | x) P(x) P(z) = likelihood ⋅prior evidence

slide-34
SLIDE 34

Bayes Filters: Framework

n

Given:

n

Stream of observations z and action data u:

n

Sensor model P(z|x).

n

Action model P(x’|u,x).

n

Prior probability of the system state P(x).

n

Wanted:

n

Estimate of the state X of a dynamical system.

n

The posterior of the state is also called Belief:

) , , , | ( ) (

1 1 t t t t

z u z u x P x Bel ! = } , , , {

1 1 t t t

z u z u d ! =

slide-35
SLIDE 35

Markov Assumption

Underlying Assumptions

n

Static world

n

Independent noise

n

Perfect model, no approximation errors

p(xt | x1:t−1,z1:t−1,u1:t) = p(xt | xt−1,ut)

p(zt | x0:t,z1:t−1,u1:t) = p(zt | xt)

slide-36
SLIDE 36

1 1 1

) ( ) , | ( ) | (

  • ò

=

t t t t t t t

dx x Bel x u x P x z P h

Bayes Filters

) , , , | ( ) , , , , | (

1 1 1 1 t t t t t

u z u x P u z u x z P ! ! h =

Bayes z = observation u = action x = state

) , , , | ( ) (

1 1 t t t t

z u z u x P x Bel ! =

Markov

) , , , | ( ) | (

1 1 t t t t

u z u x P x z P ! h =

Markov

1 1 1 1 1

) , , , | ( ) , | ( ) | (

  • ò

=

t t t t t t t t

dx u z u x P x u x P x z P ! h

1 1 1 1 1 1 1

) , , , | ( ) , , , , | ( ) | (

  • ò

=

t t t t t t t t

dx u z u x P x u z u x P x z P ! ! h

Total prob. Markov

1 1 1 1 1 1

) , , , | ( ) , | ( ) | (

  • ò

=

t t t t t t t t

dx z z u x P x u x P x z P ! h

slide-37
SLIDE 37

1. h = 0 2. If d is a perceptual data item z then 3. For all x do 4. 5. 6. For all x do 7. 8. Else if d is an action data item u then 9. For all x do 10. 11. Return Bel’(x)

) ( ) | ( ) ( ' x Bel x z P x Bel = ) ( ' x Bel + =h h ) ( ' ) ( '

1

x Bel x Bel

  • =h

' ) ' ( ) ' , | ( ) ( ' dx x Bel x u x P x Bel

ò

=

1 1 1

) ( ) , | ( ) | ( ) (

  • ò

=

t t t t t t t t

dx x Bel x u x P x z P x Bel h

Bayes Filters

slide-38
SLIDE 38

Summary

n Bayes rule allows us to compute probabilities that are hard to

assess otherwise.

n Under the Markov assumption, recursive Bayesian updating can

be used to efficiently combine evidence.

n Bayes filters are a probabilistic tool for estimating the state of

dynamic systems.

slide-39
SLIDE 39

Example: Robot Localization

t=0

1 Prob

Example from Michael Pfeiffer

Sensor model: never more than 1 mistake Know the heading (North, East, South or West) Motion model: may not execute action with small prob.

slide-40
SLIDE 40

Example: Robot Localization

t=1

1 Prob

Lighter grey: was possible to get the reading, but less likely b/c required 1 mistake

slide-41
SLIDE 41

Example: Robot Localization

t=2

1 Prob

slide-42
SLIDE 42

Example: Robot Localization

t=3

1 Prob

slide-43
SLIDE 43

Example: Robot Localization

t=4

1 Prob

slide-44
SLIDE 44

Example: Robot Localization

t=5

1 Prob

slide-45
SLIDE 45

Outline

n Probability Review n Bayes Filters n Gaussians

slide-46
SLIDE 46

n Univariate Gaussian n Multivariate Gaussian n Law of Total Probability n Conditioning (Bayes’ rule)

Disclaimer: lots of linear algebra in next few lectures. See course homepage for pointers for brushing up your linear algebra. In fact, pretty much all computations with Gaussians will be reduced to linear algebra!

Gaussians -- Outline

slide-47
SLIDE 47

Univariate Gaussian

n Gaussian distribution with mean µ, and standard deviation s:

slide-48
SLIDE 48

n Densities integrate to one: n Mean: n Variance:

Properties of Gaussians

slide-49
SLIDE 49

Central limit theorem (CLT)

n Classical CLT:

n Let X1, X2, … be an infinite sequence of independent random variables

with E Xi = µ, E(Xi - µ)2 = s2

n Define Zn = ((X1 + … + Xn) – n µ) / (s n1/2) n Then for the limit of n going to infinity we have that Zn is distributed

according to N(0,1)

n Crude statement: random variables that result from the

addition of lots of small effects are well captured by a Gaussian.

slide-50
SLIDE 50

Multivariate Gaussians

slide-51
SLIDE 51

Multivariate Gaussians

(integral of vector = vector

  • f integrals of each entry)

(integral of matrix = matrix

  • f integrals of each entry)
slide-52
SLIDE 52

§ µ = [1; 0] § S = [1 0; 0 1] § µ = [-.5; 0] § S = [1 0; 0 1] § µ = [-1; -1.5] § S = [1 0; 0 1]

Multivariate Gaussians: Examples

slide-53
SLIDE 53

n

µ = [0; 0]

n

S = [1 0 ; 0 1]

§ µ = [0; 0] § S = [.6 0 ; 0 .6] § µ = [0; 0] § S = [2 0 ; 0 2]

Multivariate Gaussians: Examples

slide-54
SLIDE 54

§ µ = [0; 0] § S = [1 0; 0 1] § µ = [0; 0] § S = [1 0.5; 0.5 1] § µ = [0; 0] § S = [1 0.8; 0.8 1]

Multivariate Gaussians: Examples

slide-55
SLIDE 55

§ µ = [0; 0] § S = [1 0; 0 1] § µ = [0; 0] § S = [1 0.5; 0.5 1] § µ = [0; 0] § S = [1 0.8; 0.8 1]

Multivariate Gaussians: Examples

slide-56
SLIDE 56

§ µ = [0; 0] § S = [1 -0.5 ; -0.5 1] § µ = [0; 0] § S = [1 -0.8 ; -0.8 1] § µ = [0; 0] § S = [3 0.8 ; 0.8 1]

Multivariate Gaussians: Examples

slide-57
SLIDE 57

Partitioned Multivariate Gaussian

n

Consider a multi-variate Gaussian and partition random vector into (X, Y).

slide-58
SLIDE 58

Partitioned Multivariate Gaussian: Dual Representation

n

Precision matrix

n

Straightforward to verify from (1) that:

n

And swapping the roles of Sigma and Gamma: (1)

slide-59
SLIDE 59

Marginalization: p(x) = ?

We integrate out over y to find the marginal: Hence we have:

Note: if we had known beforehand that p(x) would be a Gaussian distribution, then we could have found the result more quickly. We would have just needed to find and , which we had available through

slide-60
SLIDE 60

If Then

Marginalization Recap

slide-61
SLIDE 61

Self-quiz

slide-62
SLIDE 62

Conditioning: p(x | Y = y0) = ?

We have Hence we have:

  • Conditional mean moved according to correlation and variance on measurement
  • Conditional covariance does not depend on y0
slide-63
SLIDE 63

If Then

Conditioning Recap