






















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!























where ǫi is an unknown measurement noise. As a result, what we can construct from measured data are not y and Φ but their noisy counterparts:
y˜ =
y ˜ 1 y ˜ 2
... y ˜N − 1
˜y 0 u 0 ˜y 1 u 1
...... y ˜N − 1 uN − 1
Because of noise, there may not be a θ that will satisfy
˜y = Φ˜ˆθ.
Instead, it is more likely that for every θˆ we try, there will be a discrepancy between the right hand and left sides of the equation above, which we denote by e:
e := ˜y − Φ˜ˆθ.
In this case, we try to find the so-called least squares solution θˆLS that minimizes the squared error
‖e‖^2 =
i=
The “norm of an n-vector” (˜y − Φθˆ)^2 i = ‖˜y − Φ˜θˆ‖^2 x = [x 1 , x 2 ,... , xn]T^ usu- ally means its 2-norm, which is defined asq ‖x‖ 2 = PN i=1 x (^2) i.
1.2 Least squares solution
The problem above can be thought of as finding the best-fit straight line to a set of data points. Suppose two scalar variables x and y are related by a linear equation of the form
y = ax + b (1.2)
Suppose we conduct N experiments and get N pairs of data points (xi, yi), for i = 1, 2 ,... , N. Due to measurement noise etc., it is unlikely that yi = axi + b is exactly satisfied by the i-th data point. Define
ei := (axi + b) − yi (1.3)
as the error between the data yi and the “prediction” ˆaxi + ˆb, for every set of values (ˆa, ˆb) we try. Least squares identification attempts to find values of a and b so that the the sum of squares errors,
i e
2 i , is as small as possible.
Problem 1. Find the values for a and b that minimizes the Sum-of-Squares Error (SSE):
i=
(axi + b − yi)^2.
Solution to 1. Let us use calculus and solve
∂ ∂a
i=
2 xi(axi + b − yi) = 0
∂b
i=
2(axi + b − yi) = 0
for the unknown parameters a and b. This amounts to solving a system of two linear equations for a and b: ( (^) N ∑
i=
x^2 i
a +
i=
xi
b =
i=
xiyi ( (^) N ∑
i=
xi
i=
yi
N i=1 x
2 i
∑N i=1^ xi i=1 xi^ N
R
a b
N ∑i=1N^ xiyi i=1 yi
From which we compute the least squares solutions of a and b as
aˆLS =
i xiyi)^ −^ (
i xi)(
i yi) N (
i x 2 i )^ −^ (
i xi)^2 ˆbLS = (
i x
2 i )(
i yi)^ −^ (
i xiyi)(
i xi) N (
i x 2 i )^ −^ (
i xi) 2
Caution: The solution for ˆaLS , ˆbLS described above is valid only if the denominator N (
i x 2 i )^ −^ (
i xi) (^2) is not zero. This equivalent to asking det(R) 6 = 0.
The method described above can be extended to the case when there are more than two parameters to be estimated.
Problem 2. Given an n × m matrix A and an n-vector y, find the m-vector ˆxLS so that it minimizes the SSE among all n-vectors x:
SSE := ‖y − Ax‖^2 =
∑^ n
i=
(yi − (Ax)i)^2
where (Ax)i denotes the i-th entry of the vector Ax.
The vector ˆxLS is called the the solution to the problem Ax = y in the least squares sense, or simply the least squares solution to the problem Ax = y. This might be confusing; remember that the “the solution to the problem Ax = y” means “the vector x so that, given A and y, x satisfies Ax = y”. When no such x exists, we settle for a vector that minimizes the sum of squared error between Ax and y, which is the least squares solution.
Solution to 2. We will solve this problem in a manner similar to Problem 1, by determining
When x is a vector and f (x) is a scalar function of x, the Taylor series expan- sion of f around x is
f (xo + δx) = f (xo) + df dx |xo δx
1 2 δxT^ d^2 f dx^2 |x 0 δx +..
Since each term must be a scalar, the derivative df /dx is a row vector and the second derivative d^2 f /dx^2 is a matrix. The second derivative d^2 f /dx^2 is called a Hessian of f.
the scalars xi that satisfies
∂ ∂ xˆ 1
∂ xˆ 2
∂ xˆm
This equation can be re-written as
d dx
∂ ∂x 1 SSE^
∂ ∂x 2 SSE^
. (^) ∂x∂m SSE
Rm Rn A (n × m matrix)
x =
[ (^) x 1 .. . xm
] Ax^ =
[ (^) y 1 .. . yn
Figure 1.1: A m × n matrix A is a linear transformation from Rm^ to Rn.
You can easily verify that the statement above is true for an arbitrary matrix A and vector x, as long as their dimensions are compatible so that the product Ax is well-defined.
mely important er that a matrix transformation. z = x + y, then
R(A) = {y ∈ Rm|∃x ∈ Rn^ such that y = Ax} (1.10)
It is the set of all vectors that A can produce as “output” when you try all possible input vectors. Now going back to our example (1.7): given the vector y and the matrix A, we want to find a vector x such that “output” Ax for the “input” x is equal to y. To answer the first question of whether such a vector x exists (before we spend time trying to find it), use what you learned about possible outputs of a matrix. Clearly, the given vector y must lie in the range space of the given matrix A for any Ax to equal y. In other words, such an x exists if and only if y is a linear combination of the columns of A. Now let’s check if that is the case:
α
= 5α
= (5α + 2β)
So all linear combinations of the columns of A lie on one vector: [1, 2]T^. Since [3, 7]T^ does not lie along this vector, we now know that there is no solution to (1.7). To summarize: Given A ∈ Rm×n^ and y ∈ Rn, there is a vector x that satisfies Ax = y if and only if y ∈ R(A). When a solution does not exist, we have a situation that is depicted in Figure 1.2. The least squares solution ˆxLS is the vector in the input space of the matrix A so that the corresponding output ˆy∗^ := AxˆLS is closest to y. Therefore, y∗^ is the vector in R(A) that is closest to y, and can be determined by dropping a perpendicular to R(A) from y. Note that the idea of “dropping a perpendicular” works not only in R^2 and R^3 , but can be extended to Rm^ for arbitrary m.
Rm Rn
A (n × m matrix)
xˆLS
y (^) R(A)
Figure 1.2: No solution to A(·) = y. The least squares solution ˆxLS is characterized by the fact that the perpendicular from y onto R(A) is precisely the point AxˆLS.
1.3 ARX model identification by least squares
Consider a system whose outputs and inputs are described by a difference equation:
y[k + n] + βn− 1 y[k + n − 1] + βn− 2 y[k + n − 2] + · · · + β 1 y[k + 1] + β 0 y[k] = αmu[k + m] + αm− 1 u[k + m − 1] + · · · + α 1 u[k + 1] + α 0 u[k]. (1.11)
We re-write (1.11) to see that the output y[·] can be computed recursively from the inputs and past outputs:
y[k + n] = −βn− 1 y[k + n − 1] − βn− 2 y[k + n − 2] − · · · − β 1 y[k + 1] − β 0 y[k]
or, equivalently,
y[k] = −βn− 1 y[k − 1] − βn− 2 y[k − 2] − · · · − β 1 y[k − (n − 1)] − β 0 y[n − k]
Note that the output y[k] at time k depends only on the past outputs y[k − 1], y[k − 2],... , y[k − n + 1], y[k − n] and inputs u[k − n + m], u[k − n + m − 1],... , u[k − n + 1], u[k − n].
In physical systems where the present output does not depend on future inputs, m ≤ n. Such systems are called causal systems. If m < n, the present output y[k] is affected only by the past inputs, whereas if m = n, the present output is affected also by the present input. Eq. (1.11) is said to be of order n.
The equation (1.11) can be compactly written as
y[k] = ϕ[k]T^ θ (1.13)
where θ is a vector containing the parameters αi, i = 0,... , m and βj , j = 0,... , n − 1, and
Example: (pendulum): Consider the inverted pendulum shown in Figure 2.1. It consists of a mass-less link of length ℓ, with a point mass m at the end. There is an actuator which can apply a torque of T to the link at the base around the z axis (the z axis is normal to the plane of the paper). The drag on the tip mass due to its motion through air is given by −b θ˙. The angle of the link from the horizontal is denoted by θ (positive in the CCW direction). The dynamics of the angle θ is determined by the following Ordinary Differential Equation (ODE): Derive this ODE from Newton’s laws.
mℓ^2 θ¨(t) = −mgℓ cos θ(t) − b θ˙(t) + T (t), (2.1)
where T is the CCW torque applied to the base, and g is the acceleration due to gravity. Dividing throughout by mℓ^2 , we get
¨θ(t) = − b mℓ^2
θ˙(t) − g ℓ
cos θ(t) + u(t), (2.2)
where u(t) := T mℓ^ (t 2 ).
Define
x 1 := θ x 2 := θ.˙ (2.3)
The ODE (2.2) can now be re-written as
x˙ 1 = x 2 =: f 1 (x, u, t)
x˙ 2 = −
b mℓ^2
x 2 −
g ℓ
cos x 1 + u(t) =: f 2 (x, u, t)
Which is equivalent to the vector form [ x˙ 1 x ˙ 2
f 1 (x, u, t) f 2 (x, u, t)
m
θ
˜θ
g
Figure 2.1: Inverted pendulum.
We will deal with dynamical systems that are modeled by a number of coupled first-order differential equations:
x˙ 1 = f 1 (x 1 , x 2 ,... , xn, u 1 ,... , up, t) x˙ 2 = f 2 (x 1 , x 2 ,... , xn, u 1 ,... , up, t) .. . x˙n = fn(x 1 , x 2 ,... , xn, u 1 ,... , up, t)
Vector notation can be used to represent these equations in compact form. Define
x :=
x 1 x 2 .. . xn
u :=
u 1 u 2 .. . up
f (x, u, t) :=
f 1 (x, u, t) .. . fn(x, u, t)
and rewrite (2.6) as
x˙ = f (x, u, t), x ∈ Rn. (2.7)
The eq. (2.7) is called the state equation and x is referred to as the state of the dynamic system. Sometimes, another equation
y = h(x, u, t), y ∈ Rq^ (2.8)
is associated with (2.7), thereby defining a q-dimensional output vector y. The output y frequently consists of signals that are physically measured.
The behavior of dynamic systems without external inputs is governed by the so-called unforced state equation:
x˙ = f (x, t) (2.9)
which is obtained by setting u ≡ 0 in (2.7). If an external input u is specified as an explicit function of time γ(t), or as a feedback function of the state γ(x), or both γ(x, t), then substituting this function in (2.7) also leads to (2.9).
F