Anda di halaman 1dari 45

Filtering and Identification

Lecture 3: Stochastic least squares


Square Root Estimation

Michel Verhaegen and Jan-Willem van Wingerden


1/30

Delft Center for Systems and Control


Delft University of Technology

The 3-key steps of the course: Formulated


Estimate linear static models from data:

min ky F xk2W
x

Relevant and to introduce the numerical fundaments of this course!

2/30

Delft Center for Systems and Control

The 3-key steps of the course: Formulated


Estimate linear static models from data:

min ky F xk2W
x

Relevant and to introduce the numerical fundaments of this course!


Estimate the state of an LTI state space model:

x(k + 1) = Ax(k) + Bu(k) + Ke(k)

e(k) (0, Re )

y(k) = Cx(k) + Du(k) + e(k)


given the model (A, B, C, D) and K and input-output data.

2/30

Delft Center for Systems and Control

The 3-key steps of the course: Formulated


Estimate linear static models from data:

min ky F xk2W
x

Relevant and to introduce the numerical fundaments of this course!


Estimate the state of an LTI state space model:

x(k + 1) = Ax(k) + Bu(k) + Ke(k)

e(k) (0, Re )

y(k) = Cx(k) + Du(k) + e(k)


given the model (A, B, C, D) and K and input-output data.
Identify state space model matrices (A, B, C, D, K) from

input-output data {u(k), y(k)}N


k=1 .
2/30

Delft Center for Systems and Control

Overview

Main Point Lecture 2

The Stochastic Least Squares Problem

Updating least squares estimates: The RLS


scheme

A reliable square root solution

3/30

Delft Center for Systems and Control

Main Point Day Lecture 2


The Gauss-Markov Theorem
Given F RN n , L RN N , y RN , in the WLS
problem:
T

min
x

subject to:

y = F x + L

(0, I)

with x deterministic and L invertible,


W = (LLT )1 , then,
T

argminxe=M y E[(x x
e)(x x
e)

] = (F T W F )1 F T W y
= argminx T
4/30

Delft Center for Systems and Control

Overview

Main Point Day 1

The Stochastic Least Squares Problem

Updating least squares estimates: The RLS


scheme

A reliable square root solution

5/30

Delft Center for Systems and Control

Extension: x RV
Distribution

Room

Temp

(T ) at 2 time instances:
x
x

Legend:
x | current unknown T
x | mean value
| 1 uncertainty
| ellipsoid
6/30

Delft Center for Systems and Control

Extension: x RV
Distribution

Room

Temp

Statistical Prior information on x:

(T ) at 2 time instances:
x (x, P )

x
x

Legend:

P 0

. 21 (xx)T P 1 (xx)
]
[In Gaussian setting: fx = e
Statistical Meaning:
E[x] = x E[(x x)(x x)T ] = P

x | current unknown T
x | mean value
| 1 uncertainty
| ellipsoid
6/30

Delft Center for Systems and Control

Extension: x RV
Distribution

Room

Temp

Statistical Prior information on x:

(T ) at 2 time instances:
x (x, P )

x
x

Legend:
x | current unknown T
x | mean value
| 1 uncertainty
| ellipsoid

P 0

. 21 (xx)T P 1 (xx)
]
[In Gaussian setting: fx = e
Statistical Meaning:
E[x] = x E[(x x)(x x)T ] = P
New measurement about x:
y = F x+L

(0, I) E[(xx)T ] = 0

How to combine these info?


6/30

Delft Center for Systems and Control

movie.avi

7/30

Delft Center for Systems and Control

Fusion of Wavefront sensor data


time k 2 time k 1 time k

Real-life scenario: From the Shack-Hartmann Wavefront (W)


sensor data (at times k), an estimate of the vectorized the
2D-W (call x) is given as:
x (x, P ) P > 0
At time instant k + 1 we record new sensor data:
y(k+1) = F x+L(k+1)

(k+1) (0, I) E[(xx)(k+1)T ] = 0

Fuse this information with the estimate of x that you already have!
Assumption?
8/30

Delft Center for Systems and Control

The Stochastic Least Squares (SLS) Problem


Given the prior on the RV x (x, P ) with P 0 and given
the observations:
y = F x + L (0, I)

E[(x x)T ] = 0

with F, L deterministic L full rank. Then seek among the


linear estimators:

9/30

Delft Center for Systems and Control

The Stochastic Least Squares (SLS) Problem


Given the prior on the RV x (x, P ) with P 0 and given
the observations:
y = F x + L (0, I)

E[(x x)T ] = 0

with F, L deterministic L full rank. Then seek among the


linear estimators:

h
i y
x
e= M N
x

The unbiased minimum variance estimate, i.e.:


E[(x x
e)(x x
e)T ]

is minimized E[e
x] = x

Delft Center for Systems and Control

9/30

Solution to the SLS Problem


Theorem SLS: Let the conditions of the SLS problem hold,
let W = (LLT )1 then the solution x to SLS is
x = Ky + (I KF )x
with K = P F T (F P F T + W 1 )1 and covariance matrix:
E[(x x)(x x)T ] = (P P F T (F P F T + W 1 )1 F P )

10/30

Delft Center for Systems and Control

Solution to the SLS Problem


Theorem SLS: Let the conditions of the SLS problem hold,
let W = (LLT )1 then the solution x to SLS is
x = Ky + (I KF )x
with K = P F T (F P F T + W 1 )1 and covariance matrix:
E[(x x)(x x)T ] = (P P F T (F P F T + W 1 )1 F P )
If P > 0, we can rewrite K as (P 1 + F T W F )1 F T W and
the covariance matrix as:
E[(x x)(x x)T ] = (P 1 + F T W F )1

10/30

Delft Center for Systems and Control

Sketch of the Proof SLS solution


Derivation of Numerical Procedure
1. The error of a linear estimator:
x = M F x+M L+N x x x = (I M F )xM LN x

11/30

Delft Center for Systems and Control

Sketch of the Proof SLS solution


Derivation of Numerical Procedure
1. The error of a linear estimator:
x = M F x+M L+N x x x = (I M F )xM LN x
2. Unbiased Estimator:
E[x x] = (I M F )x N x = 0 M F + N = I
x x = (I M F )(x x) M L

11/30

Delft Center for Systems and Control

Sketch of the Proof SLS solution


Derivation of Numerical Procedure
1. The error of a linear estimator:
x = M F x+M L+N x x x = (I M F )xM LN x
2. Unbiased Estimator:
E[x x] = (I M F )x N x = 0 M F + N = I
x x = (I M F )(x x) M L
)(x x
)T ]
3. Covariance matrix: (W 1 = LLT ) E[(x x
= (I M F )E[(x x)(x x)T ](I M F )T + M LE[T ]LT M
= (I M F )P (I M F )T + M W 1 M T
11/30

Delft Center for Systems and Control

Minimizing the Covariance Matrix


E[(x x
)(x x
)T ] = (I M F )P (I M F )T + M W 1 M T

h
i P
PFT
I

= I M
F P F P F T + W 1
M T
|
{z
}
Q

Using Lemma 2.3 p. 19, we can factorize Q as:

P F T (F P F T + W 1 )1
P P F T (F P F T + W 1 )1 F P

0
I

0
F P F T + W 1

[]T

Therefore,

E[(x x
)(x x
)T ] = (P P F T (F P F T + W 1 )1 F P )+
(P F T (F P F T + W 1 )1 M )(F P F T + W 1 )()T
12/30

Delft Center for Systems and Control

Solution SLS first part Theorem


The minimizing variance unbiased estimator is
given by:
x = M y + (I M F ) x
| {z }
N

with the optimal M given as


P F T (F P F T + W 1 )1 = K
The minimal covariance matrix is:

E[(x
x)(x
x)T ] = (P P F T (F P F T +W 1 )1 F P )

13/30

Delft Center for Systems and Control

Solution SLS second part Theorem


Using the matrix inversion lemma:
(A + BCD)1 = A1 A1 B(C 1 + DA1 B)1 DA1 , we
can write K as
:
K = P F T (W 1 + F P F T )1


= P F T W W F (P 1 + F T W F )1 F T W


= P In F T W F (P 1 + F T W F )1 F T W


= P (P 1 + F T W F ) F T W F (P 1 + F T W F )1 F T W
= (P 1 + F T W F )1 F T W = K

The two gains K are equivalent on paper. What about


inside the computer?
Provided P is invertible!
Delft Center for Systems and Control

14/30

Numerical Example
Consider the stochastic least squares problem with:
h
i
x = 0 P = 107 I3 L = 106 I3 xT = 1 1 0.1

The matrices P and L indicate that the prior information is


inaccurate and the relationship about x in y (the measurement)
is very accurate. The matrix F is generated by the Matlab
command:
F = gallery(randsvd,3);
Then the sample average of the relative error

k
xxk2
kxk2

for 100 trials with

1. K = P F T (F P F T + W 1 )1 is 0.0483
2. K = (P 1 + F T W F )1 F T W is 0.1163
15/30

Delft Center for Systems and Control

Recall the second part of the Theorem SLS


Theorem: Let the conditions of the SLS problem hold, let
W = (LLT )1 and P > 0 then the solution x to SLS is,
x = Ky + (I KF )x
with K = (P 1 + F T W F )1 F T W and covariance matrix:
E[(x x)(x x)T ] = (P 1 + F T W F )1

16/30

Delft Center for Systems and Control

Interpretation results of Theorem SLS

1.

E[(x x
)(x x
)T ] = (P 1 + F T W F )1 is the resulting
covariance matrix of fusing the two estimates:
x (x, P )

x ((F T W F )1 F T W y, (F T W F )1 )

17/30

Delft Center for Systems and Control

Interpretation results of Theorem SLS

1.

E[(x x
)(x x
)T ] = (P 1 + F T W F )1 is the resulting
covariance matrix of fusing the two estimates:
x (x, P )

2.

x ((F T W F )1 F T W y, (F T W F )1 )

x
= Ky + (I KF )x with K = (P 1 + F T W F )1 F T W
indicates that:

For

P 1 0

and

x
=x
WLS no

matter what x is.

17/30

Delft Center for Systems and Control

Interpretation results of Theorem SLS

1.

E[(x x
)(x x
)T ] = (P 1 + F T W F )1 is the resulting
covariance matrix of fusing the two estimates:
x (x, P )

2.

x ((F T W F )1 F T W y, (F T W F )1 )

x
= Ky + (I KF )x with K = (P 1 + F T W F )1 F T W
indicates that:

For

P 1 0

and

x
=x
WLS no

matter what x is.

3.

It lays the fundaments for Recursive Least Squares (RLS).


Prior x (
xk , Pk ) with x
k
UMVE
New Data:
yk = Fk x + Lk k

SLS

k (0, I)
Delft Center for Systems and Control

A Posteriori x (
xk+1 , Pk+1 )
17/30

Overview

Main Point Day 1

The Stochastic Least Squares Problem

Updating least squares estimates: The


RLS scheme

A reliable square root solution

18/30

Delft Center for Systems and Control

The RLS Algorithm


Given initial estimate of the unknown RV x:
x (
x1 , P1 )
For k = 1:end,
read data (yk , Fk , Wk )
Kk = (Pk1 + FkT Wk Fk )1 FkT Wk
xk + Kk yk
xk+1 = (I Kk Fk )
1
Pk+1
= (Pk1 + FkT Wk Fk )
end
Caution: This (information-matrix version) is not a tractable implementation from a numerical point of view.
19/30

Delft Center for Systems and Control

RLS_demo.m

20/30

Delft Center for Systems and Control

Overview

Main Point Day 1

The Stochastic Least Squares Problem

Updating least squares estimates: The RLS


scheme

A reliable square root solution

21/30

Delft Center for Systems and Control

A weighted least squares problem


Consider the prior in the SLS given as x (x, P ),
To define a WLS, we formulate this information
into the generalized covariance representation:
x = x+P 1/2

(0, I)

with P = P 1/2 P T /2 .

22/30

Delft Center for Systems and Control

A weighted least squares problem


Consider the prior in the SLS given as x (x, P ),
To define a WLS, we formulate this information
into the generalized covariance representation:
x = x+P 1/2

(0, I)

with P = P 1/2 P T /2 . Then we can combine this


with the data equation in the WLS:
" # " #
"
#
1/2
x
I
P
0
n
T
min subject to
=
x+

x
y
F
0
L
with (0, In )
22/30

Delft Center for Systems and Control

Instruments to find a square root solution to SLS


What is allowable to define an Equivalent WLS problem?

23/30

Delft Center for Systems and Control

Instruments to find a square root solution to SLS


What is allowable to define an Equivalent WLS problem?
The given WLS problem:

1/2 0
x
I
P
n

min T subject to = x +
x
y
F
0
L

with (0, In ), is equivalent to:



1/2
x
I
P
0
n
T

Tr (TrT )
min( ) ( ) subject to T = T x+T
x
|{z}
y
F
0
L

with T and Tr

23/30

Delft Center for Systems and Control

Instruments to find a square root solution to SLS


What is allowable to define an Equivalent WLS problem?
The given WLS problem:

1/2 0
x
I
P
n

min T subject to = x +
x
y
F
0
L

with (0, In ), is equivalent to:



1/2
x
I
P
0
n
T

Tr (TrT )
min( ) ( ) subject to T = T x+T
x
|{z}
y
F
0
L

with T and Tr resp. invertible and orthogonal. Furthermore,


(0, In )

23/30

Delft Center for Systems and Control

Square Root Solution to SLS (1)


To achieve (part of) our goal we have to take T as:

In
0

T ?
T
=
F
In

24/30

Delft Center for Systems and Control

Square Root Solution to SLS (1)


To achieve (part of) our goal we have to take T as:

In
0

T ?
T
=
F
In

A left (non-singular)
transformation that does the job is:

 
 


1/2
F I
x
In
P
0

= T
in T
T =
x + T
Tr TrT
y
F
0
L
I
0
It transforms
the constraint
set ofequations to,
0
Fx y
F P 1/2 L

= x+
Tr TrT
x
I
P 1/2
0

Important is the introduced zero!

24/30

Delft Center for Systems and Control

Square Root Solution to SLS (2)


With the zero introduced, we now aim at finding part of by
the orthogonal transformation Tr . This is achieved by the
following LQ factorization:

R 0
F P 1/2 L

Tr =
G S
P 1/2
0
It transforms the constraints into:



Fx y
0
R
0


= x +
1/2
G Pnew

x
I
1/2

with Pnew Rnn .


25/30

Delft Center for Systems and Control

Square Root Solution


Fx y
0
R
0

= x +

1/2
x
I
G Pnew

yields the following transformed WLS,



1/2
x G x k2
min kk22 + kk22 = min kR1 (F x y)k22 + kPnew
x

Therefore,

= R1 (F x y)

x
= x G(F x y)

26/30

Delft Center for Systems and Control

Square Root Solution the SLS Problem


Theorem SR-SLS: Let the conditions of the SLS problem
hold, let the following LQ factorization by given:

R 0
F P 1/2 L

Tr =
G S
P 1/2
0

with Tr orthogonal and the right hand side lower triangular,


then the estimate of the SLS equals,

 

x = GR1 y + I GR1 F x = argminx T T
and has covariance matrix,

1/2 T
1/2
)
(Pnew
E[(x x)(x x)T ] = Pnew
27/30

Delft Center for Systems and Control

Numerical Example (Ctd)


Consider the stochastic least squares problem with:
h
i
x = 0 P = 107 I3 L = 106 I3 xT = 1 1 0.1

The matrices P and L indicate that the prior information is


inaccurate and the relationship about x in y (the measurement)
is very accurate. The matrix F is generated by the Matlab
command:
F = gallery(randsvd,3);
Then the sample average of the relative error
1.
2.

k
xxk2
kxk2

for 100 trials with

K = GR1 (square root solution) is 0.0002


K = (P 1 + F T W F )1 F T W (worst normal equation variant) is 0.1163
28/30

Delft Center for Systems and Control

Summary of Lecture 1 - day 2

The Stochastic Least squares problem is at


the heart of many interesting filtering and
estimation schemes demonstrated for the
RLS scheme

29/30

Delft Center for Systems and Control

Summary of Lecture 1 - day 2

The Stochastic Least squares problem is at


the heart of many interesting filtering and
estimation schemes demonstrated for the
RLS scheme

Square Root Algorithms are the preferred


numerical solutions.

29/30

Delft Center for Systems and Control

Preparation and next lecture


Preparation:
Study Chapter 4 (4.5.3-4.5.5)
Download Homework 2
Next lecture:
Lecture 3: Kalman Filtering
Tuesday November 27, 2012, 10.30-12.30
Hand-in Homework 2 (at end of the lecture)!

30/30

Delft Center for Systems and Control

Anda mungkin juga menyukai