Linear regression is a curve-fitting strategy that approximates a function from given data. It plots a straight line through a curve without necessarily touching the data points. Since the approximated function is linear, it follows the formula: y = mx + b.Continue Reading
It is necessary to first find the averages, or means, of both sets of data points. In order to do this, add the value of all the data points under x together, then divide the result by the actual number of data points. The same is done for the y data points.
To find the slope, employ the following equation: m = ((n * sum(x, y)) - (sum(x) * sum(y))) / ((n * sum(x^2)) - (sum(x))^2). N is the actual number of plotted coordinates on the curve.
The following equation determines the y-intercept: b = y_bar - m * x_bar. M is the calculated slope, x_bar is the average of the x coordinates and y_bar is the average of the y coordinates.
Use the calculated values to determine the function obtained by linear regression: f(x) = mx + b.