One-Dimensional Linear Regression

An interactive demonstration of simple linear regression, showing how the least-squares method finds the best-fitting line through a set of data points by minimizing vertical distances.

The simple linear regression algorithm is a closed-form solution to a least-squared distance minimization problem. Here is demonstrated the one-dimensional case of simple linear regression.

$$ \min_{\alpha,\beta} \sum_{i=1}^{n} (y_i - \alpha - \beta x_i)^2 $$

Click and drag the black points to affect the regression. Double click to add or remove points. The blue point in the center represents the geometric average, through which the fit always passes through.

In this problem, the least-squared distance considered includes only the vertical component. This is what makes the problem “one-dimensional”, even though the visualization of the problem is two-dimensional.