Compute Pearson's correlation coefficient with an exact r squared, and the warnings a correlation needs.
Linear Regression Calculator
Fit a least-squares line with an exact slope and intercept, with the residuals and the assumptions the fit rests on.
- Free
- No sign-up
- Runs in your browser
Input
13 characters
At least three values.
13 characters
The same number of values as x, in matching order.
How many digits to show when the answer is irrational. An exact answer ignores this.
Ready
Everything happens on this device. No upload, no account, no network request.
How to use this tool
- 1
Paste matching lists of x and y values.
- 2
The slope and intercept are exact. Check the residual table before trusting the fit.
Questions about Linear Regression Calculator
Why is the slope exact?
Because it is a ratio of exact sums of the data, with no square root anywhere - so this is the true least-squares line, not a close approximation of it. NumPy’s polyfit gives an intercept of 2.199999999999999 for a case where the exact value is 11/5.
What should I look for in the residuals?
A pattern. Residuals should look like noise with no structure; if they curve, or fan out as x grows, a straight line is the wrong model whatever r squared says. Least squares assumes the errors are independent, have constant variance and are roughly normal, and the residuals are where you check all three.
Can I predict outside the range of my data?
Not safely. The fit says nothing about behaviour outside the x values it saw, and extrapolation is where regression most often misleads. A line fitted to childhood heights predicts a twenty-foot adult.
Why divide by n - 2 for the standard error?
Because two parameters - the slope and the intercept - were estimated from the data, so two degrees of freedom are used up. Dividing by n - 1, as for a plain variance, would understate the uncertainty.
Is my data sent anywhere?
No. This runs as JavaScript in your browser tab: there is no network request carrying your numbers, nothing reaches a server log, and it keeps working with your connection off. You can confirm it in the browser’s network panel.
Related tools
Other tools you might reach for next.
Compute a z-score exactly, with the normal percentile rank and two-tailed p-value, stating the normality assumption those rest on.
Compute simple, weighted and cumulative moving averages exactly, without padding the start with data that is not there.
Find the arithmetic mean of a list of numbers exactly, with no floating-point drift in the sum.
Evaluate an expression with exact fraction arithmetic, trigonometry, logarithms and factorials, reporting whether the result is exact.
Reduce a fraction to lowest terms, with its mixed number and exact decimal form including any repeating block.
Add two fractions exactly, showing the common denominator step and reducing the result.
Subtract one fraction from another exactly, showing the common denominator step.