The line and its residuals
The visualizer draws each vertical residual. Set Hypothesis Line manually and watch Live Loss (MSE) change; Snap to Best Fit displays the OLS solution. Change Data Points or use Generate New Data to compare another sample.
How the coefficients are found
For a simple line, the slope is the covariance between x and y divided by the variance of x; the intercept makes the line pass through the sample means:
m = sum((xᵢ - x̄)(yᵢ - ȳ)) / sum((xᵢ - x̄)²)
c = ȳ - m x̄
For points (1, 2), (2, 4), and (3, 5), the means are x̄=2 and ȳ=11/3. The slope is 3/2, and the intercept is 2/3, giving ŷ=1.5x+0.67. The line passes through the mean point (2, 11/3), though it does not need to pass through every observation.
For multiple predictors, OLS chooses a coefficient for each feature while minimizing the same squared-error objective. A coefficient describes the fitted change associated with one feature while the others are held fixed; that association is not automatically causal.
Why square the residuals?
Squaring prevents positive and negative errors from cancelling and gives larger residuals more weight. A residual twice as large contributes four times as much squared error. This is useful when large misses should be penalized, but it makes the fit sensitive to outliers; inspect the data and residuals when a point pulls the line strongly.
Check the fit, not just the line
Residuals should not show a clear pattern if a linear model is adequate for the task. A curve can suggest nonlinearity; a funnel can suggest changing error variance; a time pattern can indicate dependent errors. These diagnostics matter for interpretation and uncertainty estimates. OLS can still calculate coefficients when assumptions fail, but the fit or standard inferential claims may be unreliable.
OLS does not require normally distributed errors to compute its least-squares coefficients. Normality is sometimes assumed for particular small-sample confidence intervals and tests, under other model assumptions. Avoid interpreting a straight line outside the observed predictor range without additional evidence: extrapolation can be far less reliable than interpolation.