How to use this calculator
Type or paste your data with x in the first column and y in the second, one point per line. The best-fit line, its statistics and the plot update as you type. Enter an x value to predict y there.
Formulas
Worked example
Spring test: force 0 to 5 N, extension in mm (the default)
- x̄ = 2.5 N and ȳ = 5.1 mm.
- Sxx = 17.5, Sxy = 34.5 and Syy = 68.1.
- Slope b1 = 34.5/17.5 = 1.971 mm/N, so the spring rate is 1/1.971 = 0.507 N/mm.
- Intercept b0 = 5.1 − 1.971 × 2.5 = 0.171 mm, and r² = 0.9987.
Reading the results
r² is the fraction of the scatter in y that the line accounts for; lab calibrations usually reach 0.99 or better, while field data may sit at 0.7. The standard error of the slope tells you how precisely the slope is known: roughly, the true slope lies within about two standard errors of b1. Always look at the plot as well. A curved pattern or a single stray point can give a high r² and a misleading line.
Assumptions and limits
- The relationship is a straight line, and the scatter is in y only, with similar size across the range.
- Points are independent. Predictions outside the range of your x data are extrapolation.
- For curves such as exponential decay, fit a straight line to the logarithm of y instead.
Frequently asked questions
What is the difference between r and r²?
r is the correlation coefficient, from −1 to 1, and its sign matches the slope. r² is its square, the share of the variation explained by the line.
Should I force the line through zero?
Only if physics guarantees y = 0 at x = 0 and your instrument has no offset. Otherwise the fitted intercept captures real zero errors, which is usually what you want.
How many points do I need?
At least 3 for any statistics, and preferably 6 or more spread evenly over the range you care about.