Document not found! Please try again

lecture2-small - Updated - School of Computer Science

7 downloads 54 Views 727KB Size Report
If position (i, j) is not occupied, then all pose (i, j, t) are possible to be located by a robot, then. ➢P(i,j, t) = 0 if isOccupied(i, j) = true. ➢P(i,j, t) =1/N, if isOccupied(i, ...
Some changes on Teaching in Part 1

COMP14112: Artificial Intelligence Fundamentals

• Due to the late start of each lecture, it is impossible to complete 4 lectures I prepared.

• So the following changes are needed:

Lecture 2 - Probabilistic Robot

• Formal lecture on Lecture 4 - Overview and brief history of AI is cancelled but the lecture note is used as the reading material • The example class of next week will do Example class 4: Reading and discuss the following papers:

Localization II Lecturer:

Xiao-Jun Zeng

Email:

[email protected]

• A.M. Turing, “Computing Machinery and Intelligence”, Mind 59(236): 433–460, 1950 • Rodney A. Brooks, “Elephants Don't Play Chess”, Robotics and Autonomous Systems, Vol. 6, No. 1-2, Pages 3-15, 1990 1

Location Probability Distribution - Initialisation

Robot Localisation Problem • How to determine the probability distribution of the • • •

• The simple answer is the even

initial location of the robot When a sensor reading is received, how to use it to update the probability distribution of the location of the robot When the robot takes a deterministic/accurate action (such as move 10 steps forward), how to update the probability distribution of the location When the robot takes a inaccurate action, how to update the probability distribution of the location

distribution probability • But how to calculate the even distribution probability • Two cases of scenarios: • Example 1. Lab 1 • Example 2. Example class question

These basically are the 4 tasks in Lab 1! 2

3

Location Probability Distribution - Initialisation

Location Probability Distribution - Initialisation

Scenario 1 - Lab 1: For each position (i, j), we know whether it is occupied • Method 1. If position (i, j) is occupied, then all pose (i, j, t) are impossible to be located by a robot, then  P(i,j, t) = 0 if isOccupied(i, j) = true  P(i,j, t) =1/N, if isOccupied(i, j) = false where N=Total pose – all occupied poses • Method 2. If position (i, j) is not occupied, then all pose (i, j, t) are possible to be located by a robot, then  P(i,j, t) = 0 if isOccupied(i, j) = true  P(i,j, t) =1/N, if isOccupied(i, j) = false where N=All not-occupied poses

Scenario 2 – Example class 1:

• • • • •

4

a square arena with 10×10 square grid, so 100 positions two obstacles in the arena, one occupies 3x3=9 positions and the other 4x4=16 positions so 100-9-16=75 positions are not occupied each unoccupied position has 10 possible orientations. Total unoccupied poses =75x10=750 then the probability of each unoccupied pose is 1/750 under the even distribution initialisation

5

Robot Localisation Problem

Properties of Conditional Probability

• When a sensor reading is received, how to use it to





• Similarly • Property 4 (Extended Total Probability Formula):

update the probability distribution of the location of the robot • Answer: Use Bayes Theorem When the robot takes a deterministic/accurate action (such as move 10 steps forward), how to update the probability distribution of the location • Answer: Use Extended Total Probability Formula When the robot takes a inaccurate action, how to update the probability distribution of the location • Answer: Use Extended Total Probability Formula

– Let p be a probability distribution and E , F , E1 ,..., E n be events. If E1 ,..., E n form a partition and

p( F ∧ E1 ),..., p ( F ∧ E n ) all positive. Then p( E | F ) = p( E | F ∧ E1 ) p( E1 | F ) + ... + p( E | F ∧ En ) p( En | F )

6

Bayes’ Theorem

Bayes’ Theorem

• Bayes’ Theorem has an alternative form, which is often

• Example: A patient presents at a clinic exhibiting a symptom s , for which three possible diseases come into question: d 1 , d 2 and d 3 . Suppose that we know these diseases cannot occur together, and suppose further that we have statistics telling us both how likely symptom s is given each disease, and also how widespread each disease is in the general population. Using s , d 1 , d 2 , d 3 to stand for the obvious events, we know:

more useful.

• Bayes’ Theorem - alternative form: – Let p be a probability distribution and E , E1 ,..., E n be events. If E1 ,..., E n form a partition and p( E1 ),..., p ( E n ) are all positive. Then

p( Ei | E) =

7

p( E | Ei ) p( Ei ) p( E | E1 ) p( E1 ) + ... + p( E | En ) p( En )

p( s | d1 ), p ( s | d 2 ), p ( s | d 3 ), p (d 1 ), p(d 2 ), p(d 3 ), Bayes’ theorem then allows us to compute what we want: p ( s | d i ) p (d i ) p(d i | s) = p(s | d1 ) p(d1 ) + p(s | d 2 ) p(d 2 ) + p(s | d 3 ) p(d 3 ) 8

Definition of Random Variables

9

Type of Random Variables

• Definition. A random variable (r.v) is a function X (⋅) which assigns to each element ω of sample space Ω

• Types of Random Variables: Discrete & Continuous – A discrete rv is one whose possible values constitute a finite set or a countable infinite set

a real value X (ω ) .

• Definition. For any random variable X , we define the

– A continuous rv is one whose possible values consists of an entire interval on the real line

cumulative distribution function (CDF) FX (x ) , as

FX ( x) ≡ p ( X ≤ x) ≡ p({ω ∈ Ω : X (ω ) ≤ x}) where x ∈ R (i.e., the space of all real numbers).

• Example – The student mark X is a discrete rv.

• Example. Let the sample space Ω be all students in the School of CS. For each student ω , define a

– Let X be the temperature of a given day at Manchester, then X is a continuous rv.

function X (⋅) whose value is the exam mark. Then

X is a random variable and CDF FX (x) is the percentage of students’ marks less than x 10

11

Discrete Random Variables

Continuous Random Variables

• Definition. The probability mass function (pmf) of a

• Definition. The probability density function (pdf) of a

discrete rv X is given by f X ( xi ) ≡ p ( X = xi )

continuous random variable X is given by

f X ( x) ≡

• The properties of discrete rv are fully determined by its probability mass function.

d FX ( x ) dx

• Basic properties of pdf:

• Example. Let X be a diecrete rv taking its values as

f X ( x ) ≥ 0, x ∈ R

1,2,…,n. If its pmf is given by f X (i ) = 1 / n, i = 1,2,..., n then it is rv with uniform distribution.





f X (x )dx = 1

-∞

• The properties of a continuous rv are fully determined by its probability density function. 12

Continuous Random Variables

Mean and Variance

• Example. Let X be a continuous rv taking its values

• The mean or expectation of rv X is defined as

as real numbers. It is called as a rv with normally distributed if its probability density function is given by

f X (x) =

1

σ 2π



e

13



 

µ = E(X ) = 

( x −µ )2



2σ 2

where µ is a real number and σ is a positive number.





−∞

x i f X ( x i ) , discrete .

i

x f X (x) d x , continuous

• The average spread of rv X around its expectation is called the standard deviation, and is computed via the so-called variance

 ∑ ( xi − µ) 2 f X ( xi ), discrete  Variance σ = V ( X ) =  ∞ i ∫ (x − µ) 2 f X (x)dx, continuous  −∞ 2

Standard deviation σ = σ 2 14

Continuous Random Variables

15

Robot Localization II

• Example (continue). When X is normally distributed

• Equipped with the knowledge of conditional probability,

then its mean will be µ and its variance σ 2 (hence: standard deviation σ ).

Bayes’ Theorem, and normal distributions, we now return to the robot localization problem.

• Random variables with normally distribution are most

• Suppose that our robot has three range-finding sensors:

important and widely used rv in applications

– LEFT SENSOR points directly left

• The normal distribution is also called Gaussian

– FORWARD SENSOR points directly ahead

distribution, named after Carl Friedrich Gauss.

– RIGHT SENSOR points directly right

• Each sensor delivers a reading representing the distance to the next target (obstacle or edge of arena) in the sensor’s direction.

• This reading is noisy: various readings are possible, clustered around the true value. 16

17

Robot Localization II

Robot Localization II • Suppose now the robot polls one of its sensors, and

• It is often convenient (and reasonable) to assume that

obtains a reading. Let o be the event that that particular observation has been made, e.g.

sensor readings will be normally distributed with mean equal to the true reading.

RIGHT SENSOR reports target at distance 13.

• In our simulation, we shall in fact assume that sensor

• According to Bayesian updating, the robot’s new beliefs

readings will be approximately normally distributed with mean equal to the true reading and standard deviation equal to 1/3 of the true reading (never negative)

should be obtained by conditionaliziation on this event.

• That is, for all i, j , t in the range [0, 99], we want to set the new degree of belief in event Li , j ,t to be

po (Li , j ,t ) = p (Li , j ,t | o )

• How can we calculate this quantity? 18

Robot Localization II

19

Robot Localization II

• Since the robot knows what the environment is like, and

• Now use Bayes’ theorem:

since it can be equipped with (probabilistic) models of how its sensors work, it can compute the probability of any observed event o given a particular pose:

p (L i , j , t | o ) =

p (o | Li , j ,t )



p (o | L i , j , t ) p (L i , j , t )

i '. j ', t '

p (o | L i ', j ',t ' ) p (L i ', j ', t ' )

• This will lead to revised degrees of belief about position and orientation, based on the revised probability distribution:

20

Robot Localization II • How to calculate: p (L i , j , t | o ) =

Robot Localization II • The robot also needs to update its belief in response to its

p (o | L i , j , t ) p (L i , j , t )



i '. j ', t '

actions.

p (o | L i ', j ',t ' ) p (L i ', j ', t ' )

• The robot can perform 3 actions: – TURN LEFT (through 10/100 of a circle)

• Solution: a for-loop for (i,j,t), –

– TURN RIGHT (through 10/100 of a circle)

p (o | L i , j , t ) p (L i , j , t ) can be calculated by method

– GO FORWARD (by 10 units)

getObservationProbability(p,o)

• We assume that turning actions are always faithfully executed. • We assume that forward movements are also faithfully executed,

and p (L i , j , t ) is known

except that the robot simply stops when it encounters an obstacle or the edge of the arena.

– At the same time, add the above item to the sum of Sum += p (o | L i , j , t ) p (L i , j , t ) which calculates



i . j ,t

21

• In either case, we assume that the effects of actions are

p (o | L i , j , t ) p (L i , j , t )

completely deterministic. 22

23

Robot Localization II •

Robot Localization II • By the Extended Total Probability Formula:

Let a be the event that a certain action has

p (L'i , j ,t | a ) =

been attempted (e.g. “Go forward 10 units”).



∑ p(L'

i , j ,t

| Li ', j ',t ' ∧ a )p (Li ', j ',t ' | a )

i ', j ',t '

Let L'i , j ,t

be the event that the robot’s new pose (subsequent to the action) is (i, j , t ) .

• Moreover, it is reasonable to assume:

p (L i ', j ',t '| a ) = p (L i ', j ', y ' )

• The robot can again use its knowledge of itself

After all: the probability that you are in a given location should not be affected by the action you subsequently perform*?

and its environment to obtain the conditional probabilities

• Therefore:

p(L' i , j ,t | Li ', j ',t ' ∧ a )

p (L'i , j ,t | a ) =

∑ p(L'

i , j ,t

| Li ', j ',t ' ∧ a )p (Li ', j ',t ' )

i ', j ', t '

• Thus, following an action a, the robot’s probability of having pose

for i, j , t , i ' , j ' , t ' , in the range [0, 99].

(i, j , t ) should be revised to p ( L 'i , j ,t | a )

as just calculated.

• To think about: Do you really believe the statement *? 24

Robot Localization II • How to calculate

p (L'i , j ,t | a ) =

• Note that

∑ p(L'

i , j ,t

25

Robot Localization II • How to calculate

| Li ', j ',t ' ∧ a )p (Li ', j ',t ' )

p (L'i , j ,t | a ) =

i ', j ', t '

∑ p(L'

i , j ,t

| Li ', j ',t ' ∧ a )p (Li ', j ',t ' )

i ', j ', t '

• Two methods:

p (L'i , j ,t | Li ', j ',t ' ∧ a )

– Method One: Let the pose after action a is (i,j,t), then use a forloop for all (i’, j’, t’) to get the result. But complicated as it needs two for-loops;

takes value either 1 if such move is possible or 0 if such a move is impossible, as we assume that action a is completely deterministic/accurate

– Method Two: For each pose (i, j, t), decide what pose it ends at after action a. Suppose that it ends at (i’, j’, t’), then add the current probability p(i,j,t) to the probability p(i’, j’, t’|a). So one for-loop is enough.

• How to know the end pose: use method fillPoseOnAction(tempPose,i,j,t,intendedAction) 26

Robot Localization II

27

Robot Localization II

• Thus, the robot’s basic control loop is: Update probability on observation

p o (L i , j , t ) =

• This process works very well (for static

using

p (o | L i , j , t ) p (L i , j , t )



a

∑ p (L' o

environments)

p (o | L i ', j ', t ' ) p (L i ', j ', t ' )

i '. j ', t '

Update probability on action

poa (L'i , j ,t | a ) =

o

• The problem of robot localization is, for such environments, effectively solved.

using

i , j ,t

| Li ', j ',t ' ∧ a )po (Li ', j ',t ' )

i ', j ',t '

Set

p

to be

poa

.

28

29