23
Final Exam 10 August 2016 Recursive Estimation (151-0566-00) R. D’Andrea Solutions Exam duration: 150 minutes Number of problems: 7 Permitted aids: Two one-sided A4 pages. Use only the provided solution sheets for your solutions. Do not write on the problem descriptions.

Solutions - ETH Z

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Solutions - ETH Z

Final Exam 10 August 2016

Recursive Estimation (151-0566-00) R. D’Andrea

Solutions

Exam duration: 150 minutes

Number of problems: 7

Permitted aids: Two one-sided A4 pages.

Use only the provided solution sheets for your solutions.

Do not write on the problem descriptions.

Page 2: Solutions - ETH Z

Page 2 Final Exam – Recursive Estimation

Problem 1 10 Points

Consider the discrete random variable x that takes values in {−1, 0, 1, 2}. It is known that itsprobability density function is an affine function, i.e.

fx(x) = ax+ b, x ∈ {−1, 0, 1, 2},

where a and b are constant.

a) What is the minimum value that b can take for fx to be a valid probability density function?

(2 points)

We set a = −1/6, b = 1/3 and define

g(x) =

{x x ≥ 0

−x x < 0.

b) Calculate the probability density function of z, where z := g(x). (2 points)

A discrete random variable v has the property that E[v4] = 0.

c) Find a possible probability distribution for v. Is your choice unique? Justify your answer.

(2 points)

Consider the joint probability density function of the continuous random variables m ∈ [0, 1]and n ∈ [1,∞):

fmn(m, n) :=2m

n2.

d) Calculate the probability density functions fm and fn. Are m and n independent?

(2 points)

The exercise continues on the next page.

Page 3: Solutions - ETH Z

Final Exam – Recursive Estimation Page 3

We know that discrete random variable q has zero mean and takes values in {−1, 0, 1}. Weknow further that q has the largest possible variance.

e) Calculate the probability density function of q. (2 points)

Page 4: Solutions - ETH Z

Page 4 Final Exam – Recursive Estimation

Solution 1

a) For fx(x) to be a valid probability density function it must be greater than 0, and sum up to1, that is,

2∑x=−1

ax+ b = 2a+ 4b = 1, fx(x) = ax+ b ≥ 0, ∀x ∈ {−1, 0, 1, 2}.

We can thus eliminate a, as a = 1/2− 2b. As fx is affine, it is enough to check for positivity atthe points −1 and 2, which yields

fx(−1) = −a+ b ≥ 0, fx(2) = 2a+ b ≥ 0.

Combined with the expression for a it follows that

−1/2 + 3b ≥ 0, 1− 3b ≥ 0,

from which we infer 1/3 ≥ b ≥ 1/6. Hence, the smallest possible value for b is 1/6.(1 point for the conditions on fx)(1 point for the correct answer)

b) The change of variables formula is given by

fz(z) =∑

g(x)=z

fx(x).

This yields

fz(0) = fx(0) = 1/3

fz(1) = fx(1) + fx(−1) = 2/3

fz(2) = fx(2) = 0,

and fz(z) = 0 for all other values of z.(1 point for the correct change of variables formula)(1 point for the correct answer)

c) The condition E[v4] yields

E[v4] =∑v∈V

v4fv(v) = 0,

where V is the support of fv. The expression v4 is stricly greater zero, except for v = 0. Moreover,the probability density function is required to sum up to one and to be positive. Hence, the onlypossibility is

fv(v) = 0,∀v 6∈ {0}, fv(0) = 1.

(1 point for the correct expected value formula)(1 point for consistent argumentation)

d) From the total probability theorem we obtain

fm(m) =

∫ ∞1

fmn(m, n) dn =

[−2m

n

]∞1

= 2m, m ∈ [0, 1]

fn(n) =

∫ 1

0fmn(m, n) dm =

[m2

n2

]1

0

=1

n2, n ∈ [1,∞].

Page 5: Solutions - ETH Z

Final Exam – Recursive Estimation Page 5

The random variables m and n are independent because fmn = fmfn.(1 point for total probability theorem)(1 point for correct answer)

e) Let fq be the probability density function of q. The fact that q has zero mean implies thatfq(−1) = fq(1). The variance of q simplifies therefore to

E[q2] = fq(−1) + fq(1) = 2 fq(1).

In addition, the probability density function fq is required to sum up to 1, resulting in

fq(−1) + fq(0) + fq(1) = 2fq(1) + fq(0) = 1.

In order for q to have the largest possible variance we set fq(0) = 0 (in order for fq to be a validprobability density function fq(0) has to be non-negative), which yields

fq(−1) = 1/2, fq(0) = 0, fq(1) = 1/2.

(1 point for the correct variance)(1 point for consistent argumentation)

Page 6: Solutions - ETH Z

Page 6 Final Exam – Recursive Estimation

Problem 2 9 Points

We consider a simplified model of a vending machine that sells chocolate bars for 4Fr. Themachine takes 1Fr or 2Fr coins. If a total of 4Fr or more are inserted, the machine will releasea chocolate bar, return the change and go to idle mode.Provided that the machine is in idle mode, every T seconds there is a 10% chance that a persondecides to buy a chocolate bar. Given that a person decides to buy a chocolate bar, he will enterevery T seconds a 2Fr coin with probability 0.4, and a 1Fr coin with probability 0.6. He willcontinue to do so until he gets the chocolate bar; the machine will then return to idle mode.We denote the credits inserted in the vending machine by x(k), which takes values in {0, 1, 2, 3}.The idle mode is represented by 0 and the non-negative integer k denotes the time index.

a) Complete the diagram of the discrete-time dynamics of the state x(k) as shown in thesolution booklet, by indicating the possible state transitions with arrows. Include also thetransition probabilities.

Example:

1 2

0.50.5

1

In the example, the state can transition from 1 to itself, from 1 to 2 and from 2 to1. Given that x(k − 1) = 1, the probability of staying at 1, i.e. that x(k) = 1 occurs,is 0.5, as indicated by the label of the corresponding arrow; the other transitions areanalogous.

(2 points)

b) At time zero, the state x(0) has the following probability density function:

fx(0)(0) = 0.1, fx(0)(1) = 0.5, fx(0)(2) = 0.2, fx(0)(3) = 0.2.

What is the probability density function of x(1)? (2 points)

The exercise continues on the next page.

Page 7: Solutions - ETH Z

Final Exam – Recursive Estimation Page 7

The machine has a display showing the inserted credit. Unfortunately, the display is broken.For k = 3, we can infer from the display that the inserted credit is either 2 or 3, but certainlynot 0 or 1.Without taking into account the additional information provided by the display, the state x(3)has the probability distribution

fx(3)(0) = 0.1, fx(3)(1) = 0.2, fx(3)(2) = 0.2, fx(3)(3) = 0.5.

c) What is the probability distribution of x(3) given the information from the display?

(3 points)

d) What is the maximum a posteriori estimate of x(3) given the information from the display?(1 point)

In steady-state, it can be calculated that the probability distribution of x(k) is approximatelygiven by

fx(k)(0) = 0.85, fx(k)(1) = 0.05, fx(k)(2) = 0.05, fx(k)(3) = 0.05.

e) Calculate the steady-state probability that a chocolate bar is sold within the next T sec-onds.

(1 point)

Page 8: Solutions - ETH Z

Page 8 Final Exam – Recursive Estimation

Solution 2

a)

0 1

3 2

0.06

0.04

0.9

0.60.40.4

0.6

1

(1 point for correct interconnection)(1 point for correct probabilities)

b) We apply the marginalization rule,

fx(1)(x) =

3∑x=0

fx(1)|x(0)(x|x)fx(0)(x),

which leads to

fx(1)(0) = 0.9 · fx(0)(0) + 1 · fx(0)(3) + 0.4 · fx(0)(2) = 0.09 + 0.2 + 0.08 = 0.37

fx(1)(1) = 0.06 · fx(0)(0) = 0.006

fx(1)(2) = 0.04 · fx(0)(0) + 0.6 · fx(0)(1) = 0.004 + 0.3 = 0.304

fx(1)(3) = 0.4 · fx(0)(1) + 0.6 · fx(0)(2) = 0.2 + 0.12 = 0.32.

(1 point for total marginalization rule)(1 point for correct answer)

c) We define the random variable z(3) to be the value of the inserted credit as shown by thedisplay for k = 3. From the problem description we can infer that

fz(3)|x(3)(2|x) =

0 x = 0

0 x = 1

α x = 2

α x = 3,

where α is a constant fulfilling 0 ≤ α ≤ 1. We use Bayes theorem for obtaining the posteriorstate distribution, that is,

fx(3)|z(3)(x|2) =fz(3)|x(3)(2|x)fx(3)(x)∑3x=0 fz(3)|x(3)(2|x)fx(3)(x)

.

Page 9: Solutions - ETH Z

Final Exam – Recursive Estimation Page 9

Evaluating the above expression yields

fx(3)|z(3)(0|2) = 0

fx(3)|z(3)(1|2) = 0

fx(3)|z(3)(2|2) = 2/7

fx(3)|z(3)(3|2) = 5/7.

(1 point for correct fz(3)|x(3))(1 point for Bayes theorem)(1 point for correct answer)

d) The maximum a posterior estimate is given by

arg maxxfx(3)|z(3)(x|z) = 3.

(1 point for correct answer)

e) A chocolate bar is sold whenever the idle state is reached from state 2 or 3. We introduce therandom variable b that takes the value 1 if a chocolate bar is sold at time k (that is, within thenext T seconds), and 0 otherwise. From the problem description we infer that

fb|x(k−1)(1|x) =

0 x = 0

0 x = 1

0.4 x = 2

1 x = 3

.

Applying the marginalization rule yields

fb(1) =4∑

x=0

fb|x(k−1)(1|x)fx(k−1)(x).

Due to the stationarity of the distribution of x(k) we obtain

fb(1) =

4∑x=0

fb|x(k−1)(1|x)fx(k)(x) = 0.05 · 0.4 + 0.05 = 0.07.

(1 point for correct answer)

Page 10: Solutions - ETH Z

Page 10 Final Exam – Recursive Estimation

Problem 3 10 Points

You subscribe to two mailing lists A and B. Mailing list A has a trustworthy subscriber basesuch that none of the mails are spam, whereas on mailing list B some subscribers spam the listsuch that 1 out of 10 mails are spam. In your regular mail, which arrives separately from theselists, 7 out of 10 mails are spam. On average out of 10 mails that you receive, 2 mails arrivethrough mailing list A, 1 mail through mailing list B, and 7 mails through regular mail.

a) Formalize the above description with random variables and state the corresponding prob-abilities and/or conditional probabilities as given in the description. (2 points)

b) When you receive a new mail, what is the probability of it being spam? (2 points)

You want to design a spam filter based on keywords. You observe that 5 out of 10 spam mailscontain the word ’free’, and 2 out of 10 spam mails contain the words ’win’. Also, 1 out of 10mails that are not spam contain the word ’free’, and 1 out of 100 mails that are not spam containsthe word ’win’. The appearance of these words is conditionally independent when conditionedon incoming mail being spam or not.

c) What is the probability of a mail being spam provided that it contains the words ’free’and ’win’? (4 points)

You design your filter such that an incoming mail is classified as spam if it contains either ofthese words.

d) What is the probability of a spam mail being correctly classified by your filter? (2 points)

Page 11: Solutions - ETH Z

Final Exam – Recursive Estimation Page 11

Solution 3

a) We introduce a random variable M to describe an incoming mail. The random variable takesthe value S if it is spam and H if it is not. A second random variable X describes the origin ofan incoming mail; it takes the values {A,B,R} depending on whether the mail arrived throughlist A, B, or regular mail, respectively.From the problem description we can derive the following probabilities:

Pr (X = A) =2

10, Pr (X = B) =

1

10, Pr (X = R) =

7

10,

together with

Pr (M = S|X = A) = 0, Pr (M = S|X = B) =1

10, Pr (M = S|X = R) =

7

10.

(2 points for parsing the problem setting)

b) Invoking the total probability theorem yields

Pr (M = S) =∑

X∈{A,B,R}

Pr (M = S|X) Pr (X)

= 01

10+

1

10

1

10+

7

10

7

10

=1 + 49

100=

1

2.

(1 point total probability theorem, 1 point correct answer)

c) We introduce another random variable W1, which takes the value 1 if a mail contains theword ’free’ and 0 if it does not. Likewise, we introduce the random variable W2, which takesthe value 1 if a mail contains the word ’win’ and 0 if it does not. We seek the probabilityPr (M = S|W1 = 1,W2 = 1), which we obtain through Bayes Theorem:

Pr (M = S|W1 = 1,W2 = 1) =Pr (W1 = 1,W2 = 1|M = S) Pr (M = S)

Pr (W1 = 1,W2 = 1)

=Pr (W1 = 1,W2 = 1|S) Pr (S)

Pr (W1 = 1,W2 = 1|S) Pr (S) + Pr (W1 = 1,W2 = 1|H) Pr (H),

where we simplified notation for brevity.The appearance of the words is conditionally independent when conditioned on a mail beingspam or not and therefore

Pr (W1,W2|M) = Pr (W1|M) Pr (W2|M) ,

such that

Pr (S|W1 = 1,W2 = 1) =Pr (W1 = 1|M = S) Pr (W2 = 1|M = S) Pr (M = S)

Pr (W1 = 1|S) Pr (W2 = 1|S) Pr (S) + Pr (W1 = 1|H) Pr (W2 = 1|H) Pr (H).

Substituting the values for each probability, we obtain

Pr (S|W1 = 1,W2 = 1) =510

210

12

510

210

12 + 1

101

10012

=100

101.

Page 12: Solutions - ETH Z

Page 12 Final Exam – Recursive Estimation

(1 point for parsing the problem, 1 point for Bayes theorem, 1 point for conditionalindependence, 1 point for correct answer)d) We seek the probability (1− Pr (W1 = 0,W2 = 0|M = S)); because of conditional indepen-dence we can reformulate this expression as

(1− Pr (W1 = 0,W2 = 0|M = S)) = (1− Pr (W1 = 0|M = S) Pr (W2 = 0|M = S))

= (1− 5

10

8

10)

=3

5.

(1 point for parsing the problem, 1 point for correct answer)

Page 13: Solutions - ETH Z

Final Exam – Recursive Estimation Page 13

Problem 4 5 Points

Consider the following dynamic system. The state x(k) ∈ R2 is driven by the scalar processnoise v(k) ∼ N (1, 1), where N (µ,Σ) denotes a Gaussian distribution with mean µ and vari-ance Σ. The noise values {v(·)} are mutually independent. The non-negative integer k denotesthe time index.

The system dynamics are

x(k) =

[1 10 1

]x(k − 1) +

[21

]v(k − 1).

The initial value of the state’s first component is known to be exactly x1(0) = 0, i.e. with zerovariance. The initial value of the state’s second component, x2(0), is known to be random andindependent of {v(·)}.

a) Assume a Gaussian distribution for the initial value of the state’s second component withthe following parameters: x2(0) ∼ N (1, 2). Compute the probability density function(PDF) of the state at time k = 1. (3 points)

For part b): at time k = 10, the a priori state is randomly distributed as x(10) ∼ N (µ,Σ),where

µ =

[01

]Σ =

[1 11 2

].

A measurement z(k) then becomes available, related to the state as below:

z(k) =[1 0

]x(k) + w(k),

where w(k) ∼ N (0, 1) is a measurement noise, and is independent of both {v(·)} and x(0). Themeasurement at k = 10 is z(10) = 1.

b) Compute the a posteriori mean of the state at time k = 10, using this measurement.(2 points)

Page 14: Solutions - ETH Z

Page 14 Final Exam – Recursive Estimation

Solution 4

a) First, we notice that all random variables in the problem are Gaussian, and that the dynamicsare linear. This means that the state x(1) is also Gaussian, so we only need to compute its meanand variance to fully determine the PDF.We can compute these directly using the usual Kalman filter equations. We define the usualvariables xp(k), xm(k), Pp(k) and Pp(k). The filter is initialized with

xm(0) =

[01

]Pm(0) =

[0 00 2

].

The system matrices follow directly from the description, and the process noise variance Q is

Q =

[4 22 1

].

The prior update yields

xp(1) = Axm(0) +

[21

]=

[1 10 1

] [01

]=

[32

],

(1 point)

Pp(1) = APm(0)AT +Q

=

[1 10 1

] [0 00 2

] [1 01 1

]+

[4 22 1

]=

[6 44 3

].

(1 point)The distribution is then x(1) ∼ N (xp(1), Pp(1)). (1 point)b) Again all random variables in the problem are Gaussian, and the measurement equation islinear: this means we can use the tools of the Kalman filter to compute this. We will neglect thetime index k = (10) throughout this solution, as all variables used share the same time index.First, we compute the Kalman filter gain K:

K = PpHT(HPpH

T +R)−1

=

[1 11 2

] [10

]([1 0

] [1 11 2

] [10

]+ 1

)−1

=

[1/21/2

](1 point)

Page 15: Solutions - ETH Z

Final Exam – Recursive Estimation Page 15

The mean estimate then follows as

xm = xp +K (z −Hxp)

=

[1/23/2

].

(1 point)

Page 16: Solutions - ETH Z

Page 16 Final Exam – Recursive Estimation

Problem 5 9 Points

You are to design a steady-state Kalman filter for a scalar system with state x(k). You are giventhe following dynamics,

x(k) = x(k − 1) + u(k − 1) + v(k − 1) with v(k) ∼ N (0, 4) ,

x(0) ∼ N (0, 1) ,

where N (0,Σ) denotes a zero-mean Gaussian distribution with variance Σ. The non-negativeinteger k denotes the time index. The measurement equation is

z(k) = x(k) + w(k) with w(k) ∼ N (0, 3) .

The random variables x(0), {v(·)}, and {w(·)} are mutually independent.

a) Show that the steady-state Kalman filter gain is K∞ = 2/3. (3 points)

b) Calculate the probability density function of the estimation error e(1) given that u(0) = 1and z(1) = 1.

(2 points)

c) Find the feedback controller that minimizes

limN→∞

E

[1

N

N−1∑k=0

4x(k)2 + 3u(k)2

].

The feedback controller is only allowed to depend on present and past measurements, thatis, u(k) is solely dependent on z(1), z(2), . . . , z(k).

(2 points)

We choose now u(k) = −x(k), where x(k) is the state estimate obtained by the steady-stateKalman filter.

d) What is the probability density function of the estimation error limk→∞ e(k), where e(k) :=x(k)− x(k)? (2 points)

Page 17: Solutions - ETH Z

Final Exam – Recursive Estimation Page 17

Solution 5

a) The discrete algebraic Riccati equation reads in the scalar case as

p = a2p+ σ2v −

a2p2h2

h2p+ σ2w

,

where a is the system matrix, σ2v the process noise variance, σ2

w the measurement noise variance,and h comes from the measurement equation. For the specific problem formulation we havea = 1, h = 1, σ2

v = 4, and σ2w = 3. We therefore obtain the quadratic equation

4(p+ 3) = p2,

which has the unique positive solution p = 6. The steady-state Kalman filter gain is then givenby

K∞ =ph

h2p+ σ2w

=2

3.

(1 point for the discrete algebraic Riccati equation)(1 point for the equation of the Kalman-filter gain)(1 point for correct calculation)

b) From the system dynamics we infer that

x(1) = x(0) + 1 + v(0).

The steady state Kalman filter yields

x(1) = (1−K∞h)ax(0) + (1−K∞h)u(0) +K∞z(1),

where a and h are as above. The estimate x(0) is chosen to be zero and therefore

x(1) = 1.

The estimation error e(1) is thus given by

e(1) = x(0) + v(0).

It is the sum of two Gaussian random variables and is therefore Gaussian as well. It has zeromean and variance

E[(x(0) + v(0))2] = E[x(0)2] + E[v(0)2] = 5,

which follows by independence of v(0) and x(0). As result we have that

fe(1)(e) =1√10π

exp− e2

10.

(1 point for steady-state Kalman filter equations)(1 point for the correct distribution)

c) From the separation principle we can infer that the optimal controller has the form u(k) =−KLQRx(k), where x(k) is the state estimate from the steady-state Kalman filter. The gainKLQR is obtained from a LQR design. The corresponding algebraic Riccati equation is the sameas in part a), thus we have that KLQR = K∞.(1 point for the separation principle)(1 point for the correct answer)

Page 18: Solutions - ETH Z

Page 18 Final Exam – Recursive Estimation

d) As k →∞ the prior variance of the Kalman filter approaches the steady-state variance p (ascalculated in part a)). Consequently, the posterior variance is given by

pm = (1−K∞h)2p+K2∞σ

2w = 1/9p+ 4/9 · 3 = 2.

Moreover, according to the separation principle the observer dynamics are independent of thestate dynamics. Because the matrix (1−K∞h)a = 1/3 is stable (it has magnitude smaller thanone), it follows that E[limk→∞ e(k)] = 0. As a result, e∞ = limk→∞ e(k) is distributed accordingto

pe∞(e) =1

2√π

exp− e2

4.

(1 point for the correct mean)(1 point for the correct answer)

Page 19: Solutions - ETH Z

Final Exam – Recursive Estimation Page 19

Problem 6 6 Points

Consider the system

x(k) = Ax(k − 1) +HTv(k − 1)

z(k) = Hx(k) + w(k),

with v(k) ∼ N (0, 1), w(k) ∼ N (0, 1),

A =

(3/4 1/41/4 3/4

), H = (1,−1) ,

and x(0) ∼ N (0, P0), where P0 is positive semi-definite and N (0,Σ) denotes a zero-mean Gaus-sian distribution with variance Σ. The non-negative integer k denotes the time index. Therandom variables x(0), {v(·)}, and {w(·)} are mutually independent.

a) You design a Kalman filter for observing the state x. Is the variance of the state estimateguaranteed to converge to a unique value, independent of P0? Justify your answer.

(3 points)

Consider the modified system

x(k) = Ax(k − 1) + HTv(k − 1)

z(k) = Hx(k) + w(k),

with v(k) ∼ N (0, 1), w(k) ∼ N (0, 1),

A =

(1 00 1/4

), H = (0, 1) ,

and x(0) ∼ N (0,Σ0), where Σ0 is positive semi-definite. The random variables x(0), {v(·)}, and{w(·)} are mutually independent.

b) You design a Kalman filter for observing the state x. Does the mean of your estimateconverge? If it converges, state the value it converges to. Does the variance of the stateestimate converge? If the variance converges, does it depend on Σ0? Justify your answer.

(3 points)

Page 20: Solutions - ETH Z

Page 20 Final Exam – Recursive Estimation

Solution 6

a) In order to guarantee convergence of the variance of the Kalman filter to a steady-state valueindependent of P0 we require (A,HT) to be stabilizable and (A,H) to be detectable. We usethe PBH-rank test to check detectability and stabilizability. The eigenvalues of the A matrixare obtained by solving∣∣∣∣ λ− 3/4 −1/4

−1/4 λ− 3/4

∣∣∣∣ = (λ− 3/4)2 − 1/16 = λ2 − 3/2λ+ 1/2 = 0.

This yields

λ1,2 =3/2±

√9/4− 8/4

2= 3/4± 1/4,

which implies that λ1 = 1.1 As a result, the PBH-rank test for determining whether (A,H) isdetectable reduces to checking the rank of 1/4 −1/4

−1/4 1/41 −1

,

which has not full rank. Thus the system is not detectable. (The check for stabilizability isanalogous.) Consequently, the variance of the state estimate is not guaranteed to converge to aunique value that is independent of P0.(1 point for stating the conditions guaranteeing convergence)(1 point for determining the eigenvalues of A)(1 point for checking dectability and stabilizability)

b) The dynamics of x1 and x2 are decoupled (where x = (x1, x2)T). The dynamics of x1 aremarginally stable (eigenvalue at 1), are not affected by the process noise and are not enteringthe measurement z(k). As a result, the variance of x1(k) remains constant for all k, and isdependent on Σ0. The mean of x1(k) will remain zero for all k, since x(0) has zero mean.In contrast, the dynamics of x2 are asymptotically stable, observable, and affected by the processnoise. The mean of x2(k) will therefore decay to zero (asymptotic stability) and the variance ofx2 will reach a steady-state (independent of the initial variance).The Kalman filter is guaranteed to track the probability density function of x(k) perfectly.Hence, both the mean and the variance estimate will converge. However, the value to which thevariance estimate converges depends on the initial variance Σ0.(1 point for the decomposition of the dynamics)(1 point for arguing that the mean will converge)(1 point for the arguments related to the convergence of the variance)

1We can also infer by inspection that A has the eigenvector (1, 1). Because A is symmetric the eigenvectorsare orthogonal, which yields the second eigenvector, (1,−1). From that, the corresponding eigenvalues are easilycalculated.

Page 21: Solutions - ETH Z

Final Exam – Recursive Estimation Page 21

Problem 7 10 Points

Recall the basic particle filtering algorithm we derived in class:

Initialization: Initialize the algorithm by randomly drawing N samples from the proba-bility density function of the initial state, fx(0).

Obtain xnm(0), n = 1, 2, . . . , N . Set k = 1.

Step 1: Simulate the N particles via the process model.

Obtain the a priori particles xnp(k).

Step 2: After a new measurement z(k) at time k, scale each a priori particle by themeasurement likelihood, and obtain a corresponding normalized weight βn for each particle.

Resample to get the a posteriori particles xnm(k) that have equal weights.

Increment the time k and proceed with Step 1.

Consider the discrete-time process and measurement model

x(k) = x(k−1) + v(k−1)

z1(k) = x(k) + 5w1(k)

z2(k) = x(k) + x(k)w2(k),

where x(k) is the scalar system state and v(k−1) is process noise with the probability densityfunction

fv(k)(v) =

{2v v ∈ [0, 1]

0 otherwise,for all k.

The measurements zi(k) are corrupted by measurement noise wi(k) with the PDF

fwi(k)(w) =

1 + w w ∈ [−1, 0)

1− w w ∈ [0, 1]

0 otherwise,

for all k,

i = 1, 2 and the initial state x(0) is uniformly distributed in the range [1, 2]. The randomvariables {v(·)}, {w1(·)}, {w2(·)}, and x(0) are mutually independent. The non-negative integerk denotes the time index.

a) Initialize a particle filter with N = 2 particles. For this calculation, you have access to arandom number generator that generates independent random samples r from a uniformdistribution on the interval [0, 1]. For the calculation of x1

m(0), you obtained the sampler1 = 1/4. For the calculation of x2

m(0), you obtained the sample r2 = 1/3. (2 points)

b) At time k = 3, the posterior particles are x1m(3) = −1/3 and x2

m(3) = 3/5. Calculate theprior particles x1

p(4) and x2p(4). You have access to the same random number generator

as in part a). For the calculation of x1p(4), you obtained the sample r1 = 1/9. For the

calculation of x2p(4), you obtained the sample r2 = 1/4. (2 points)

c) At time k = 5, the prior particles are x1p(5) = 1/3 and x2

p(5) = 1. The measurements are

z1(5) = 2 and z2(5) = 12 . Calculate the expected value of the posterior particles xm(5).

(6 points)

Page 22: Solutions - ETH Z

Page 22 Final Exam – Recursive Estimation

Solution 7

a) We sample the given state distribution fx(0)(x) using the algorithm discussed in class andthe given random numbers. The cumulative distribution function (CDF) of x(0) is

Fx(0)(x) =

0 x < 0

x− 1 x ∈ [1, 2]

1 x > 2.

(1 point)Solving

ri = Fx(0)(x) ⇔ ri = x− 1,

yields

x1m(0) = 5/4 x2

m(0) = 4/3.

(1 point for correct answer)

b) We use the process model to simulate the two particles with random samples from theprocess noise distribution fv(k)(v). The CDF of v(k) is

Fv(k)(v) =

0 v < 0

v2 v ∈ [0, 1]

1 v > 1.

(1 point)Solving

r1 = Fv(k)(v1(3))

we find v1(3) = 1/3. Analogously, we obtain v2(3) = 1/2 from r2 = 1/4. Then, we applythe process model and find

x1p(4) = x1

m(3) + v1(3) = −1

3+

1

3= 0

x2p(4) = x2

m(3) + v2(3) =3

5+

1

2=

11

10.

(1 point correct answer)

c) The expected value of the posterior particles can be computed as

E[xm(5)] = β1x1p(5) + β2x

2p(5),

where βi are the normalized particle weights. The particle weights can be obtained fromthe measurement likelihood of z1 and z2 conditioned on xp, which through conditionalindependence can be written as

fz1,z2|xp(z1, z2|x) = fz1|xp

(z1|x)fz2|xp(z2|x).

We adapt the change of variables formula to conditional PDFs and obtain

fz1|xp(z|x) =

fw1 (h(z, x)|x)∣∣∣ dgdw (h(z, x), x)∣∣∣ ,

Page 23: Solutions - ETH Z

Final Exam – Recursive Estimation Page 23

where

z = g(w, x) := x+ 5w

w = h(z, x) :=1

5(z − x)

dg

dw(h(z, x), x) = 5.

Therefore,

fz1|xp(z1|x) =

fw1(h(z1, x)|x)∣∣∣ dgdw (h(z1, x), x)∣∣∣ =

1

5fw1

(1

5(z1 − x)

),

and by a similar approach

fz2|xp(z2|x) =

1

xfw2

(z2 − xx

),

such that

fz1,z2|xp(z1, z2|x) =

1

5fw1

(1

5(z1 − x)

)1

xfw2

(z2 − xx

).

Finally, we obtain the following measurement likelihood for the first particle

fz1,z2|xp

(2,

1

2|13

)=

1

5fw1

(1

3

)3fw2

(1

2

)=

1

5,

and

fz1,z2|xp

(2,

1

2|1)

=1

5fw1

(1

5

)fw2

(−1

2

)=

4

50.

The sum of the measurement likelihoods is 10/50 + 4/50 = 7/25 =: α−1, such that thenormalized particle weights are

β1 =5

7

β2 =2

7.

The expected value of the posterior particles is therefore

E[xm(5)] =11

21.

(1 point for parsing the problem, 1 point conditional independence, 1 pointfor CoV, 1 point for each β, 1 point for correct answer)