About Line of Best Fit Calculator
This line of best fit calculator draws the straight line that follows your points most closely and gives its equation in the y = mx + b form. It opens on daily temperature against ice cream sales and predicts sales at 25 degrees. It is free, needs no sign-up and runs in your browser, so nothing you enter is uploaded.
The line of best fit is the least squares regression line. Use it to describe a trend, to estimate a y for an x that is not in your table, and to see how steeply y changes per unit of x.
A prediction band is drawn around the line so you can see how far a single new point may fall from it. The band is narrowest near the middle of your data and widens at the ends.
How to use Line of Best Fit Calculator
- Paste two columns from a spreadsheet or type one x, y pair per line. A text first line is used as the axis names.
- Choose the model: linear, polynomial, exponential or logarithmic. For a polynomial, pick the degree.
- Read the equation and the statistics table. For the line, the slope p-value tests whether x helps predict y at all.
- Type an x value in the prediction box to get the predicted y and, for the linear model, its intervals.
- Check the residual plot. Residuals should scatter randomly around zero. A curve or a funnel means the model is wrong or the spread changes.
- Open the comparison table to see which model has the highest R², and look at adjusted R² before trusting a high degree.
Features
- Least squares line with slope, intercept, r, r², standard error of the estimate and of the slope.
- t test and p-value for the slope, with confidence intervals for slope and intercept.
- Prediction interval for one new point and confidence interval for the mean response.
- Polynomial regression of degree 2 to 6, exponential y = a·e^(bx) and logarithmic y = a + b·ln x.
- Model comparison table with R² and adjusted R².
- Equation in KaTeX, scatter plot with fitted curve and prediction band, and PNG download.
- Residual plot and a residuals table with fitted values.
- Step by step working for the least squares line, copyable as LaTeX.
Worked examples
Temperature 14 to 30 against ice cream sales (9 days) gives ŷ = -112.8 + 25.56x
At 25 degrees the line predicts 526.1 sales, with r² = 0.872.
Privacy: how it works
- Everything is calculated by code running in your browser tab. Your data is not sent to Ulkaa or to any other server, and there is nothing to sign in to.
Tips
- A high R² does not prove a good model. Look at the residual plot as well.
- Prefer the lowest degree that fits. Adjusted R² drops when an extra term adds nothing.
- For the exponential model, R² is measured on the original y, so it can be compared fairly with the line.
- If the points form a curve that rises and levels off, try the logarithmic model.
Frequently asked questions
Is it really free?
Yes. There is no price, no trial and no credit card. Ulkaa Tool does the work with your own device, so there is no server bill to pass on to you.
Do I need an account?
No. There is no sign-up and no login. Open the page and use it. An Ulkaa account is not needed for anything on this tool.
Does it run in my browser?
Yes. Your data are processed by code running in your browser tab, on your own device.
Is my data uploaded?
No. Your data are never sent to Ulkaa or to anyone else. You can check this yourself by watching the Network tab in your browser developer tools while you use the tool.
How do I draw a line of best fit by hand?
Plot the points, then draw a line with about as many points above as below that passes near the point of means. The calculator finds the exact least squares line.
Is the line of best fit the same as the trend line in Excel?
A linear trend line in Excel is the same least squares line, so the equation should match this calculator.
What if my points do not follow a straight line?
Switch the model to polynomial, exponential or logarithmic and compare R² in the table.
More Linear Regression Calculator pages
- Linear Regression CalculatorPaste x, y data to fit a least squares line and compare it with polynomial, exponential and logarithmic models.
- Least Squares Regression Line CalculatorPaste x, y data to get the line y = b + mx that minimises the squared errors.
- Polynomial Regression CalculatorPaste x, y data to fit a quadratic, cubic or higher degree curve, up to degree 6.
- Exponential Regression CalculatorPaste x, y data to fit y = a·e^(bx) and see the growth factor per step.