Parameters that minimize sum of the distance from point to line

65 Views Asked by At

I'm having a difficulty in finding parameters that minimize this: $$f(a,b,c)=\sum_{i=1}^{n} \frac{(ax_i+by_i+c)^2}{a^2+b^2}$$

So far, I've found that $$c=-a\bar{x}-b\bar{y}$$ where $\bar{x}=\frac{1}{n}\sum_{i=1}^{n} x_i$ and $\bar{y}=\frac{1}{n}\sum_{i=1}^{n} y_i$.

Please give me some hints to find $a$ and $b$. Also, please tell me if $c$ I've found is wrong.

1

There are 1 best solutions below

0
On BEST ANSWER

We wish to find the line of best fit $y=mx+c$ for a data set $(x_i,y_i)$ $i=1, \cdots,n$. We need to minimise the following quantity \begin{eqnarray*} L &=& \sum_{i=1}^{n} (y_i-mx_i+c)^2 \\ &=& \sum_{i=1}^{n} (y_i^2-2mx_iy_i+2cy_i+m^2x_i^2+2mcx_i+c^2) \\ \end{eqnarray*} Differentiating wrt to $c$ gives \begin{eqnarray*} \frac{ \partial L}{\partial c} &=& 2 \sum_{i=1}^{n} (y_i-mx_i+c) \\ \bar{y} = m \bar{x} +c \tag{1} \end{eqnarray*} Essentially the equation you state in your question.

Differentiating wrt to $m$ gives \begin{eqnarray*} \frac{ \partial L}{\partial c} &=& 2 \sum_{i=1}^{n} (x_iy_i-mx_i^2+cx_i) \\ \sum_{i=1}^{n} x_iy_i &=& m \sum_{i=1}^{n}x_i^2+c\sum_{i=1}^{n}x_i. \tag{2} \end{eqnarray*} You need to calculate $\sum_{i=1}^{n} x_iy_i$ & $\sum_{i=1}^{n}x_i^2$ , then use equations $(1)$ and $(2)$ to calculate $m$ & $c$.