This question is taken from GATE 2005 ICE subject paper.
Using the given data points given below, a straight line passing through the origin is fitted using least squares method.
$$(x, y)$$
$$(1, 1.5) \thinspace (2.0, 2.2) \thinspace (3.0, 2.7)$$The slope of the line is ?
a) 0.9
b) 1
c) 1.1
d) 1.5
My solution
$mX = Y$
m$ \begin{bmatrix}
x_1 \\
x_2 \\
x_3
\end{bmatrix} $ = $ \begin{bmatrix}
y_1 \\
y_2 \\
y_3
\end{bmatrix} $
Since the Moore–Penrose pseudoinverse can be used to compute a 'best fit' (least squares) solution.
$$m = (X^TX)^{-1}X^TY$$
$$ m = (x_1^2 + x_2^2 + x_3^3)^{-1}(x_1y_1 + x_2y_2 + x_3y_3) =
\frac{1.5+4.4+8.1}{1 + 4 + 9} = 1 $$
Thus the answer is (b)
While this is the answer given in this book (Arihant publications – Chapterwise previous year solved papers (2013-2000) GATE Instrumentation Engineering – Page 200) that I am following,
0.6 is touted as the answer in various other places too – gate overflow, While I found this book (Q 101) agreed with me.
So which is actually correct and why?
Best Answer
It depends on the question. Different questions imply different answers.
Answer: The value of the slope a is equal to $1$
Answer: The values of a is $0.6$ and the value of b is $\frac{14}{15}$
These questions can be solved without using matrix algebra, since we have 3 data point only. Just minimize
$\sum_{i=1}^{3} (y_i-ax)^2 =(1.5-a)^2+(2.2-2a)^2+(2.7-3a)^2$ respectively
$\sum_{i=1}^{3} (y_i-ax-b)^2 = (1.5-a-b)^2+(2.2-2a-b)^2+(2.7-3a-b)^2$
Here are the results of Q1 and Q2.