MATH042 - Lesson 8
MATH042 - Lesson 8
Engineering
Method of Least Squares
• When performing experiments, we often tabulate data in the form
of ordered pairs (x1, y1), (x2, y2),...,(xn,yn) with each xi distinct. We
want to find a function f(x) such that
f ( x1 ) y1 , f ( x2 ) y2 ,..., f ( xn ) yn
E yi axi b
i 1
• The expression E is called the sum of the square errors. The line y =
ax+b that minimizes the sum of the square errors is defined to be the
line of best fit and is called the least sqaures line for the data (x1, y1),
(x2, y2),...,(xn,yn).
cont.
• The unique solution X = (ATA)-1ATY
• We say that X is the least squares solution of the overdetermined
system.
Example. Least Squares Line
• Find the least square line for the • Now by identifying
data (1,1), (2,3), (3,4), (4,6), (5,5).
Calculate the sum of square 1
1 1
errors E for this line and the line 3
2 1
y = x + 1.
T 55 15
Y 4
A 3 1
A A
Solution 4 1 15 5
6 5 1
a+b=1 5
2a + b = 3
3a + b = 4
4a + b = 6
5a + b = 5
Solution
1
1
• Thus the least squares solution is
1 2
55 15
X 3
1
1
a = 1.1 and b = 0.5, and the least
15 5
4 1
squares line is y = 1.1x +0.5.
5 1
• For this line the sum of the
1 5
1
3
15 1 2 3 4 5
square errors is:
4
50 15 55 1 1 1 1 1
6
5
• E = [1-f(1)]2 + [3-f(2)]2+ [4-f(3)]2 +
[6-f(4)]2+ [5-f(5)]2
1 5 15 68 1.1
50 15 55 19 0.5 • = [1-1.6]2+ [3-2.7]2+ [4-3.8]2+
[6-4.9]2+[5-6]2 = 2.7
Example: Least squares parabola
• Find the least squares parabola
for the data (1,1),(2,4),
(3,7),(4,5) 1
1
1 1
354 100 30
4
4 2 1
a b+ c = 1 Y , A
7 9 3 1
andAT
A 100 30 10
30 10 4
5 16
4a + 2b + c = 4 4 1
9a + 3b + c = 7
16a + 4b + c = 5
Solution
T
1 1 1 1 1
354 100 30 5 25 25 160 1.25
4 2 1 4 1
X 100 30 10 9
25 129 135 50 7.75
30 10 4 3 1 7 20
25 135 155 17 5.75
16 4 1 5