Statistics

Linear Regression Simulator with Noise

Create or manipulate points and watch the fitted line, R², and errors update live.

Points: 0R²: 0.00Mode: Interactive

Data plane

Drag points or the manual line to compare fits.

Auto-scale
Export chart

Residuals are colored from blue to red based on magnitude.

Point generation

Click to add points, double click or right click to remove. Drag to move them.

Live metrics

Model equation ŷ = 0.00x + 0.00
R² 0.00
Poor fit
RMSE 0.00
MAE 0.00
n0
Slope 0.00
Intercept 0.00

Outlier mode

Insert an extreme point and see how the line gets pulled.

Model comparison

Turn on the manual line and try to beat least squares by eye.

Least squares
RSS 0.0
Manual line
RSS 0.0

About this tool

Linear regression seeks the relationship y=β0+β1x1+⋯+βpxp+εy = \beta_0 + \beta_1 x_1 + \cdots + \beta_p x_p + \varepsilon that best fits the observed data. The ordinary least squares (OLS) method estimates the coefficients as β^=(XTX)−1XTy,\hat{\boldsymbol{\beta}} = (X^TX)^{-1}X^Ty, minimizing the sum of squared residuals ∑i=1n(yi−y^i)2.\sum_{i=1}^{n}(y_i - \hat{y}_i)^2. Despite its conceptual simplicity, it remains a reference model: interpretable, efficient, and surprisingly competitive when the underlying relationship is approximately linear.

The coefficient of determination R2=1−SSresSStotR^2 = 1 - \frac{SS_{\text{res}}}{SS_{\text{tot}}} measures what proportion of the variance in the response variable the model explains. A high R2R^2 does not guarantee that the model is valid: residuals must be analyzed to verify that the assumptions of homoscedasticity, independence, and normality hold. A systematic pattern in the residuals indicates that the linear model is not capturing all the structure in the data.

This tool lets you fit a linear regression visually and interactively. Add or move points and observe in real time how the regression line, coefficients, R2R^2, and residual distribution change. Especially useful for building intuition about the effect of outliers and data dispersion.