Find the line of best fit for any set of data. Type or paste your x and y values, or tap the graph to add points. The calculator draws the scatter graph and the least squares line, gives its equation and slope, measures the correlation, and lets you make predictions, with every step of the working shown.
Tap an empty part of the graph to add a point. Drag a point to move it, or drag it off the graph to remove it.
Paste two columns from a spreadsheet, or type pairs like 3, 55. An optional first line such as Hours, Score labels the axes.
Line of best fit
Make a prediction
predicted y ≈
x ≈
Predictions inside the range of your data (interpolation) are more reliable than ones outside it (extrapolation).
Working: least squares method
How to use the Line of Best Fit calculator
Entering data
- Type one pair per line, such as
3, 55. Commas, spaces and tabs all work, so you can copy two columns straight from a spreadsheet and paste them in. - Start with a heading line such as
Hours, Scoreand the graph and sentences use those names. - Or tap the graph to add points, drag them to move them, and drag a point off the edge to delete it.
- The example buttons load realistic sample data sets. They are made-up examples, not real survey results.
Reading the results
- The equation y = mx + c is the least squares line: the line that makes the squared vertical distances from the points as small as possible.
- The slope tells you how much y changes, on average, for each 1 increase in x.
- r measures the correlation, from −1 to 1. Close to 1 or −1 means the points lie close to a straight line; close to 0 means no linear pattern.
- The orange marker is the mean point (x̄, ȳ). The line of best fit always passes through it.
Making predictions
- Type an x value to predict y, or a y value to work backwards to x. The prediction is drawn on the graph with dashed lines.
- A prediction inside the range of your data is interpolation and is usually reliable. Outside the range it is extrapolation: the pattern may not continue, so treat it with caution.
- A line of best fit shows a pattern, not a cause. Two things can rise together without one causing the other.
Learn more
- Scatter graphs and correlation: positive, negative and no correlation, and why correlation isn’t causation
- Drawing and using a line of best fit: by eye, finding its equation, and making predictions
- The least squares regression line: the formula worked by hand, and what the slope and intercept mean