Straight

Storyboard

>Model

ID:(614, 0)



Straight line

Equation

>Top, >Model


To adjust data (x_i, y_i) to a line of the type

y = ax + b

you must calculate the values a and b such that the difference of the squares

$\sum_i (y_i-ax_i-b)^2 = min$

be a minimum.

ID:(6890, 0)



Slope

Equation

>Top, >Model


If it is derived

$\sum_i (y_i-ax_i-b)^2 = min$



with respect to a and the result is equal to zero the equation is obtained:

S_{xy}+aS_{x2}+bS_x=0

where

S_x=\sum_ix_i, S_{x2}=\sum_ix_i^2 and S_{xy}=\sum_ix_iy_i

If the operation is repeated for b the equation is obtained:

bN-S_y+aS_x=0

with S_y=\sum_iy_i.

The solution of the equations leads to the slope being

$a=\displaystyle\frac{NS_{xy}-S_xS_y}{NS_{xx}-S_x^2}$

ID:(6891, 0)



Constant

Equation

>Top, >Model


If it is derived

$\sum_i (y_i-ax_i-b)^2 = min$



with respect to a and the result is equal to zero the equation is obtained:

S_{xy}+aS_{x2}+bS_x=0

where

S_{x,n,y,m}=\sum_ix_i^ny_i^m

that in the case that n or m are zero the factor x or y is not written and in the case of the unit the number is not included.

If the operation is repeated for b the equation is obtained:

bN-S_y+aS_x=0

with S_y=\sum_iy_i.

The solution of the equations leads to the constant being

$ b =\displaystyle\frac{ S_{x2} S_y - S_x S_{xy}}{ N S_{x2} - S_x ^2}$

ID:(6892, 0)



Deviation

Equation

>Top, >Model


The regression is calculated based on which

$\sum_i (y_i-ax_i-b)^2 = min$



be a minimum. If the square is developed and the root of this value is divided by the mean value, a measure of the mean deviation of the regression is obtained:

$ \epsilon =\displaystyle\frac{(( N S_{x2} - S_x ^2) S_{y2} - S_{x2} S_y ^2+2 S_x S_{xy} S_y - N S_{xy} ^2}{ N ( N S_{x2} - S_x ^2)}$

ID:(9441, 0)



Simulator

Html

>Top


The attached demo allows you to make a least-squares adjustment of a line.

ID:(8081, 0)