Play with slope-intercept to match the line with data.
Press 'Another Data' to generate new data
How to use this app
This app shows why the "best fit" line is the one that minimizes the sum of squared errors (SSE) — the "valley" you're searching for.
1. Set up your data
N — how many data points to plot.
Noise — how scattered the points are around the true line.
Another — generates a new true line and dataset.
2. Try Guess mode (Hide)
Tap 🎯 Guess Line to drop a line and see how close it is.
3. Explore with Play mode
Drag the slope and intercept sliders to move the line by hand, or hit ▶ to animate one automatically.
Turn on Best Fit Line to compare your line to the true least-squares fit, or Show Centroid to see the point (x̄, ȳ) the best-fit line always passes through.
4. Read the second chart
Differences — the residual (error) for each point.
SSE — total squared error for your current line, tracked as you adjust it.
R² — how much of the variation in y your line explains (closer to 1 is better).
Variance — how total variance splits into explained vs. unexplained parts.
Check Freeze Y-axis to keep the scale fixed so you can compare changes more easily.
Goal: find the slope and intercept that make SSE as small as possible — that's the least squares line.