If you are given a list of X and Y values, that are the coordinates of points on a graph. How do you find a single straight line that fits the points such that the straight line is the best match for the points?

We will make use of two equations:

and

where

is the average of x values of all coordinates,

is the average of y values of all coordinates,

is the standard deviation of y values of all coordinates,

is the standard deviation of y values of all coordinates,

can be found using the second equation.

Rearranging the first equation, we get

This is the equation of the linear regression. f and x are variable, and we are finding the gradient, K and intercept, B which are and respectively.

Reference: https://en.wikipedia.org/wiki/Simple_linear_regression

### Like this:

Like Loading...

*Related*