me 233 review...batch least squares solution the least squares parameter estimate which solves...

49
1 ME 233 Advanced Control II Lecture 19 Least Squares Parameter Estimation

Upload: others

Post on 18-Mar-2020

15 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

1

ME 233 Advanced Control II

Lecture 19

Least Squares

Parameter Estimation

Page 2: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

2

Least Squares Estimation

Model

Where

• observed output

• known and measurable function

• unknown but constant parameter

Page 3: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

3

Least Squares Estimation

Model

Where

measured output

Page 4: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

4

Batch Least Squares Estimation

Assume that we have collected k data sets:

We want to find the parameter estimate at instant k:

that best fits all collected data in the least squares sense:

collected data

kept constant in the summation

Page 5: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

5

Batch Least Squares Estimation

Defining the cost functional

is obtained by solving

Page 6: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

6

Batch Least Squares Solution

The least squares parameter estimate

which solves

Satisfies the normal equation:

Page 7: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

7

Normal Equation Derivation

Page 8: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

8

Normal Equation Derivation

Taking the partial derivative with respect to

For optimality, we therefore need

Page 9: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

9

Normal Equation Derivation

For optimality, we need

Therefore, we need

Page 10: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

10

Batch Least Squares Estimation

The solution of the normal equation

Is given by:

Pseudoinverse

Page 11: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

Moore-Penrose pseudoinverse

• Let A have the singular value decomposition

• Then the Moore-Penrose pseudoinverse of A is

11

orthogonal matrices

In MATLAB: pinv(A)

Page 12: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

12

Moore-Penrose pseudoinverse

Let and be its Moore-

Penrose pseudoinverse

Then has the dimension of and satisfies:

In this case, since

and are Hermitian

Page 13: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

13

Batch Least Squares Estimation

Assume that we have collected sufficient data

and the data has sufficient richness so that

has full rank.

Then,

Page 14: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

14

Recursive Least Squares (RLS)

Assume that we have collected k-1 sets of data and have

computed using

Then, given a new set of data:

We want to find in a recursive fashion:

Page 15: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

15

Recursive Least Squares Algorithm

Define the a-priori output estimate:

and the a-priori output estimation error:

The RLS algorithm is given by:

where F(k) has the recursive relationship on the next slide

Page 16: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

16

Recursive Least Squares Gain

The RLS gain is defined by

Therefore,

Using the matrix inversion lemma, we obtain

Page 17: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

17

Recursive Least Squares Derivation

Define the least squares gain matrix

Therefore,

Page 18: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

18

Recursive Least Squares Derivation

Notice that

Page 19: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

19

Recursive Least Squares Derivation

Therefore plugging the previous two results,

And rearranging terms, we obtain

Page 20: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

20

Recursive Least Squares Estimation

Define the a-priori output estimate:

and the a-priori output estimation error:

The RLS algorithm is given by:

Page 21: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

21

Recursive Least Squares Estimation

Recursive computation of

Therefore,

Using the matrix inversion lemma, we obtain

Page 22: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

22

Recursive Least Squares Estimation

Matrix inversion lemma:

• Multiply by on the right and on the left:

• Multiply by on the right:

Page 23: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

23

Recursive Least Squares Estimation

Matrix inversion lemma:

• Rearranging terms,

• Solving for

Page 24: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

24

Recursive Least Squares Estimation

Matrix inversion lemma:

• Plug

into

to obtain

Page 25: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

25

RLS Estimation Algorithm

Initial conditions:

A-priori version:

Page 26: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

26

RLS Estimation Algorithm

A-posteriori version (used to prove that ):

Page 27: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

27

RLS Estimation Algorithm

Notice that, since

And the a-priori error is

We obtain,

Define the parameter estimation error:

Page 28: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

28

RLS Estimation Algorithm

Thus, the a-priori output estimation error can be written as

then,

Similarly, define the a-posteriori output and estimation error :

Page 29: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

29

RLS Estimation Algorithm

Derivation of the RLS A-posteriori version:

Remember that,

Thus,

Page 30: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

30

RLS Estimation Algorithm

Multiplying by to the left of

to obtain,

Thus,

Page 31: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

31

RLS Estimation Algorithm

Therefore, from

We obtain,

Page 32: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

32

RLS with forgetting factorThe inverse of the gain matrix in the RLS algorithm is given by:

Its trace is given by:

which always increases when

Page 33: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

33

RLS with forgetting factor

Similarly, the trace of the gain matrix is given by

always decreases when

Problem: RLS eventually stops updating

Page 34: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

34

RLS with forgetting factor

Key idea: Discount old data, e.g. the term

is small when k is large since

We can modify cost function to “forget” old data

Page 35: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

35

RLS with forgetting factor

A-priori version:

Same as RLS

without

forgetting

factor

Page 36: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

36

RLS with forgetting factor

A-posteriori version (used to prove that ):

Page 37: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

37

RLS with forgetting factor

The gain of the RLS with FF may blow up

if is not persistently exciting

(more on this later)

Page 38: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

38

General PAA gain formula

• Constant adaptation gain:

• RLS:

• RLS with forgetting factor:

(We talked about this case in the previous lecture)

Page 39: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

39

General PAA gain formula

Page 40: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

40

General PAA

A-priori version:

When , the parameter estimate equation simplifies to

Page 41: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

41

General PAA

A-posteriori version (used to prove that ):

Page 42: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

Additional Material

(you are not responsible for this)

• The Matrix Inversion Lemma

• Relationships for the General PAA

42

(these will be included in the next version…)

Page 43: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

Matrix Inversion Lemma

(simplified version)

• Since , we

know that

• The matrix inversion lemma (simplified

version) states that

43

Page 44: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

Matrix Inversion Lemma

(simplified version)

44

Proof:

Define

We want to show that

Page 45: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

Matrix Inversion Lemma 45

Proof:

If A, C, and (A+UCV) are invertible, then

Page 46: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

Relationships for General PAA46

Proof: We know that

By the Matrix Inversion Lemma

This simplifies to the stated expression for F(k+1)

Page 47: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

Relationships for General PAA47

Proof:

Page 48: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

Relationships for General PAA48

Proof:

Page 49: ME 233 Review...Batch Least Squares Solution The least squares parameter estimate which solves Satisfies the normal equation: 7 Normal Equation Derivation. 8 Normal Equation Derivation

Relationships for General PAA49

Proof (continued):

From the previous slide,