Fit a straight line through a cloud of points by eye, lock it in, and see how close you came to the least-squares line.
Was this fun?
How to play
You get a scatter of points and a line y = m·x + b, starting flat at y = 0. Set the slope m and the intercept b with the sliders or by dragging the line. A red residual line runs from each point to your line, showing how far it misses. In Exact and Best Fit your error stays hidden while you play: judge the fit by eye, then press Lock in. The result shows your error, the target, your accuracy and the line you were aiming for, drawn dashed.
Exact: 4 to 8 points lie exactly on a hidden line, so a perfect lock-in has an error of 0.
Best Fit: 8 to 16 points are scattered around a line, so no line passes through them all. Par is the error of the least-squares line, the line with the smallest possible sum of squared residuals.
Drift: the points move for 30 seconds and you keep the line on them with the sliders; the live error is shown.
The error is the sum of the squared residuals: square each point's vertical distance from your line and add them up.
Score (Exact and Best Fit): accuracy × (900 + a speed bonus), where accuracy is 1 / (1 + the error above par per point) and the speed bonus starts at 100 and falls to 0 after 120 seconds. Drift scores the share of the 30 seconds you held a good fit, out of 1,000.
Give up shows the best line and scores 0.
A worked example
In Exact, read two points off the grid. If they are (0, 3) and (2, 4), the line rises 1 for every 2 across, so m = 0.5, and it crosses the y-axis at 3, so b = 3. Set those, lock in, and the error is 0: accuracy 100%.
In Best Fit, suppose there are 8 points and par is 15.3. Lock in a line with an error of 23.3 and you are 8 over par, 1 per point, so your accuracy is 1 / (1 + 1) = 50%. Lock it in after 30 seconds, when the speed bonus is 75, and you score 0.5 × 975 = 488.
Game modes
Daily: the same points for everyone each day, for each challenge and level (the day changes at midnight UTC). Only your first Daily of each challenge and level counts on the leaderboard; it counts as played from your first move.
Practice: new random points each round; press New for another.
Levels 1 to 5 add points and, in Best Fit and Drift, more scatter. Daily and Practice have separate leaderboards for each challenge and level.
Controls
Desktop: drag the slope and intercept sliders, or drag the line itself: the middle shifts the intercept, the ends tilt the slope. Press Lock in when you're happy.
Phone & tablet: drag the sliders or the line with your finger, then tap Lock in; tap the buttons above the graph to change challenge, Daily or Practice, and level.
Tips & strategy
Set the intercept first so the line runs through the middle of the cloud, then tilt the slope until about as many points sit above the line as below.
The least-squares line always passes through the average point, the mean x and mean y (simple linear regression: numerical properties), so find the centre of the cloud and pivot around it.
Squaring makes big misses count much more than small ones: one residual twice as long adds four times as much error, so don't let a far-off point hang way out.
In Exact, read two points that sit on grid lines and work out the slope as rise over run.
In Drift, keep the slope steady and follow the cloud with the intercept.
What you'll learn
Line of Fit makes linear regression something you can see and feel: what slope and intercept do, what a residual is, and why the best line balances the points rather than passing through them.
Skills: linear functions, slope and intercept, scatter plots, residuals, least squares
Best for: roughly grades 8–12 (ages 13+)
For parents & teachers: fitting by eye first and then comparing with the least-squares line is a good way into the formulas, and the Exact rounds practise reading slope and intercept off a graph.
Origins
The line the game measures you against is the least-squares line. The first clear account of the method of least squares was published by Adrien-Marie Legendre in 1805, in a work on finding the orbits of comets; in 1809 Carl Friedrich Gauss published his own method and claimed to have had it since 1795 (least squares: history). Gauss's least-squares calculations were the only predictions that let the astronomer Franz Xaver von Zach find the asteroid Ceres again after Giuseppe Piazzi had discovered it in 1801 and followed it for 40 days (least squares: the method).
The word regression comes from Francis Galton, who used it in the 19th century for the way the heights of descendants of tall ancestors tend to move back towards the average (regression analysis: history). Fitting one straight line y = m·x + b to points with one input and one output is simple linear regression (simple linear regression).
About Line of Fit
Line of Fit is an original PlayPendium game. Its points are generated from a seed, so the Daily is the same for everyone, and the least-squares line it compares you with is calculated exactly for each set of points. It runs in the browser with no install or account.
A free, original browser game on PlayPendium. No download, no install.