Professional Documents
Culture Documents
The Method of Least Squares: Lectures INF2320 - P. 1/80
The Method of Least Squares: Lectures INF2320 - P. 1/80
The Method of Least Squares: Lectures INF2320 - P. 1/80
415
410
p(t)
405
400
395
390
1 2 3 4 5 6 7 8 9 10
t
415
410
p(t)
405
400
395
390
1 2 3 4 5 6 7 8 9 10
t
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
t
25
20
15
10
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
t
0.6
0.5
0.4
0.3
0.2
0.1
0
1991 1992 1993 1994 1995 1996 1997 1998 1999 2000
p(t) = α?
1 10
α = ∑
10 i=1
yi = 0.312 (2)
or
1 10
α∗ = ∑
10 i=1
yi , (6)
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0.1 0.2 0.3 0.4 0.5 0.6
α*=0.312
0.1
0.05
0
0.1 0.2 0.3 0.4 0.5 0.6
α*=0.345
0.6
0.5
0.4
0.3
0.2
0.1
0
1991 1992 1993 1994 1995 1996 1997 1998 1999 2000
p(t) = α + βt (10)
∂F 10
= 2 ∑(α + βti − yi ), (13)
∂α i=1
∂F
and therefore the condition ∂α = 0 leads to
!
10 10
10α + ∑ ti β = ∑ yi . (14)
i=1 i=1
and
10
∑ yi = 0.29 + 0.14 + 0.19 + · · · + 0.29 = 3.12,
i=1
so we have
∂F 10
= 2 ∑(α + βti − yi )ti ,
∂β i=1
∂F
and therefore the condition ∂β = 0 gives
! !
10 10 10
∑ ti α + ∑i β =
t 2
∑ yiti.
i=1 i=1 i=1
and
10
∑ tiyi = 1 · 0.29 + 2 · 0.14 + 3 · 0.19 + · · · + 10 · 0.29 = 20,
i=1
α
! ! !
10 55 3.12
= .
55 385 β 20
0.6
0.5
0.4
0.3
0.2
0.1
0
1991 1992 1993 1994 1995 1996 1997 1998 1999 2000
p(t) = α + βt + γt 2 (18)
requires
∂F ∂F ∂F
= = = 0 (20)
∂α ∂β ∂γ
Lectures INF2320 – p. 28/80
Approx. by a quadratic function
• ∂F 2 ∑10 α + βti + γti2 − yi
∂α = i=1 = 0 leads to
! !
10 10 10
10α + ∑ ti β + ∑i γ =
t 2
∑ yi
i=1 i=1 i=1
α ≈ −0.4078,
β ≈ 0.2997, (22)
γ ≈ −0.0241.
0.6
0.5
0.4
0.3
0.2
0.1
0
1991 1992 1993 1994 1995 1996 1997 1998 1999 2000
(ti , yi ) i = 1, . . . , n,
p0 (t) = α.
1 n
α = ∑
n i=1
yi , (23)
p1 (t) = α + βt
p2 (t) = α + βt + γt 2
0.4
0.2
−0.2
−0.4
−0.6
1850 1900 1950 2000
Consequently,
0.4
0.2
−0.2
−0.4
−0.6
1850 1900 1950 2000
p(n + 1) − p(n)
αn = (32)
p(n)
• Let bn be the relative annual growth in percentage, i.e.
p(n + 1) − p(n)
bn = 100 (33)
p(n)
p(n + 1) − p(n)
Year n p(n) bn = 100
p(n)
1950 0 2.555 1.49
1951 1 2.593 1.62
1952 2 2.635 1.71
1953 3 2.680 1.79
1954 4 2.728 1.91
1955 5 2.780
p0 (t)
Table 3: Estimated values of using (33) based on the numbers
p(t)
of the world’s population from 1950 to 1955.
1 4 1
b = ∑ bn = (1.49 + 1.62 + 1.71 + 1.79 + 1.91) = 1.704
5 n=0 5
5.5
4.5
3.5
2.5
1950 1955 1960 1965 1970 1975 1980 1985 1990 1995 2000
1 9
b = ∑
10 n=0
bn = 1.42
• Therefore α = b
100 = 0.0142
• Starting from t=0 in the year 2000, the model reads
p0 (t)
= α + γ p(t) (41)
p(t)
• Hence, we can determine constants α and γ by fitting a
linear function to the observations of
p0 (t)
(42)
p(t)
bn ≈ A + Bp(n), (44)
• We have
9 9
∑ p(n) = 56.5, ∑ (p(n))2
= 319.5,
n=0 n=0
9 9
∑ bn ≈ 14.1, ∑ p(n)bn ≈ 79.6
n=0 n=0
Lectures INF2320 – p. 54/80
Logistic growth
• By solving the (2 × 2) system
! ! !
10 56.5 A 14.1
=
56.5 319.5 B 79.6
we get
p(0) ≈ 6.08
• The analytical solution to the differential equation is
69.5
p(t) ≈ (47)
6.08 + 5.36 e−0.027t
• This model predicts that there will be
p(100) ≈ 10.79
2.4
2.2
1.8
1.6
1.4
1.2
0.8
0.6
2000 2010 2020 2030 2040 2050 2060 2070 2080 2090 2100
0.8
0.6
0.4
0.2
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Figure 15: 1 t
The function y(t) = ln 10 sin(t) +
(solid curve) and
e
a linear approximation (dashed line) on the interval t ∈ [0, 1].
0
0 1 2 3 4 5 6 7 8 9 10
Figure 16: 1 t
The function y(t) = ln 10 sin(t) + e(solid curve) and
a linear approximation (dashed line) on the interval t ∈ [0, 10].
p(t) = α (49)
1
Z b
α = y(t)dt (51)
b−a a
1 n
α = ∑
n i=1
yi , (52)
y(t) = sin(t)
2 π/2 −2
Z
(51) π/2
p(t) = α sin(t) dt = [cos(t)]0
= π 0 π
−2 2
= (0 − 1) = .
π π
p(t) = α + βt (53)
1 2 b
Z
(b − a)α + (b − a2 )β = y(t) dt
2 Za b (55)
1 2 1 3
(b − a )α + (b − a3 )β =
2
t y(t) dt
2 3 a
y(t) = sin(t)
defined on 0 ≤ t ≤ π/2.
We have
Z π/2
sin(t) dt = 1
0
and
Z π/2
t sin(t) dt = 1.
0
The solution is
! !
α 1 8π − 24 0.115
= 2 96 ≈ .
β π − 24 0.664
π
Therefore the linear approximation is given by
p(t) = α + βt + γt 2 (56)
∂F ∂F ∂F
= = = 0
∂α ∂β ∂γ
Lectures INF2320 – p. 72/80
Approx. by Quadratic Functions
• By taking the derivatives, we have
•
∂F b
Z
= 2 (α + βt + γt 2 − y(t)) dt
∂α a
∂F b
Z
= 2 (α + βt + γt 2 − y(t))t dt
∂β a
∂F b
Z
= 2 (α + βt + γt 2 − y(t))t 2 dt
∂γ a
1 2 1 3 b Z
2 3
(b − a)α + (b − a )β + (b − a )γ = y(t) dt
2 3 Za b
1 2 1 3 1 4
(b − a )α + (b − a )β + (b − a4 )γ =
2 3
t y(t) dt
2 3 4 Za b
1 3 1 4 1 5
(b − a )α + (b − a )β + (b − a5 )γ =
3 4
t 2 y(t) dt
3 4 5 a
0.8
0.6
0.4
0.2
0
0 0.5 1 1.5
Figure 17: The function y(t) = sin(t) (solid curve) and its least
squares approximations: constant (dashed line), linear (dotted line)
and quadratic (dashed-dotted curve).
Lectures INF2320 – p. 77/80
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
Figure 18: The function y(t) = t 2 + 101 cos(t) (solid curve) and its
least squares approximations: constant (dashed line), linear (dotted
line) and quadratic (dashed-dotted curve).
Lectures INF2320 – p. 78/80
Lectures INF2320 – p. 79/80
Lectures INF2320 – p. 80/80