Professional Documents
Culture Documents
Lall
1
Least-squares data fitting
we are given:
x1 f1 (si ) + · · · + xn fn (si ) ≈ gi , i = 1, . . . , m
2
Least-squares data fitting
x = (AT A)−1 AT g
I corresponding function is
I applications:
3
Least-squares polynomial fitting
to data (ti , yi ), i = 1, . . . , m
j−1
I matrix A has form Aij = ti
4
Vandermonde matrices
I suppose Aa = 0
5
Example
I fits for degrees 1, 2, 3, 4 have RMS errors .135, .076, .025, .005, respectively
0.75 0.75
0.50 0.50
0.25 0.25
degree 1 degree 2
0.00 0.00
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
0.75 0.75
0.50 0.50
0.25 0.25
degree 3 degree 4
0.00 0.00
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
6
Growing sets of regressors
p
X
minimize xi ai − y
i=1
for p = 1, . . . , n
I regress y on a1 , . . . , ap
7
Growing sets of regressors
where
I Ap = Qp Rp is the QR factorization of Ap
8
Norm of optimal residual versus p
plot of optimal residual versus p shows how well y can be matched by linear com-
bination of a1 , . . . , ap , as function of p
kresidualk
kyk
min kx1 a1 − yk
x1
X
7
min k xi ai − yk
x1 ,...,x7
i=1
p
0 1 2 3 4 5 6 7
9
Least-squares system identification
system identification problem: find reasonable model for system based on mea-
sured I/O data u, y
example with scalar u, y (vector u, y readily handled): fit I/O data with moving-
average (MA) model with n delays
where h0 , . . . , hn ∈ R
10
System identification
u(n − 1) ···
ŷ(n) u(n) u(0) h0
ŷ(n + 1) u(n + 1) u(n) ··· u(1) h1
=
.. .. .. .. .
..
. . . .
ŷ(N ) u(N ) u(N − 1) ··· u(N − n) hn
11
Example
4 3.5
3 3.0
2.5
2
2.0
1
1.5
12
Example
for n = 7 we obtain MA model with
I obviously the larger n, the smaller the prediction error on the data used to
form the model
I suggests using largest possible model order for smallest prediction error
14
Model order selection
1.0
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0 5 10 15 20 25 30 35 40 45 50 55
n
difficulty: for n too large the predictive ability of the model on other I/O data
(from the same system) becomes worse
15
Out of sample validation
I evaluate model predictive performance on another I/O data set not used to
develop model model validation data set
I check prediction error of models (developed using modeling data) on valida-
tion data
I plot suggests n = 10 is a good choice
1.0
relative prediction error kek/kyk
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0 5 10 15 20 25 30 35 40 45 50 55
n 16
Validation
for n = 50 the actual and predicted outputs on system identification and model
validation data are:
3.5 2.5
3.0 2.0
2.5 1.5
2.0 1.0
1.5 0.5
1.0 0.0
0.5 -0.5
0.0 -1.0
-0.5 -1.5
-1.0 -2.0
-1.5 -2.5
-2.0 -3.0
0 10 20 30 40 50 60 70 0 10 20 30 40 50 60 70
t t
I loss of predictive ability when n too large called model overfit or overmodeling
17