0

Can someone explain me how to start this problem: method of least squares fit,

$y=Bx$ to the following $n=6$ points $(3,4),(1,2),(5,4),(6,8),(3,6),(4,5)$

I have calculated $x$ mean and $y$ mean, and calculated $\large \frac{(x-xm)(y-ym)}{(x-xm)^{2}}$ but it doesn't give me a right answer

Amzoti
  • 56,629
Jack F
  • 349

1 Answers1

2

Presumably you are trying to find the $B$ that minimizes $f(B) = \sum_{k=1}^6 (y_k-Bx_k)^2$. This is a strictly convex quadratic, so it has a unique minimizer, and we can find the solution by differentiating and setting the derivative to zero.

We have $\frac{df(B)}{dB} = -2 \sum_{k=1}^6 x_k(y_k-Bx_k) = -2 ((\sum_{k=1}^6 x_ky_k)-B (\sum_{k=1}^6 x_k^2))$. Setting $\frac{df(B)}{dB} =0$ gives the equation $$\frac{df(B)}{dB} = -2 ((\sum_{k=1}^6 x_ky_k)-B (\sum_{k=1}^6 x_k^2)) = 0$$

and hence the minimizing $B$ is given by $B = \frac{\sum_{k=1}^6 x_ky_k}{\sum_{k=1}^6 x_k^2}$. In this particular case, the computation gives $B = \frac{5}{4}$.

copper.hat
  • 178,207