Skip to content
ToolUlkaa Tool
All tools

Statistics

Statistics CalculatorRandom Number GeneratorStandard Deviation CalculatorZ-Score CalculatorProbability CalculatorPermutation and Combination CalculatorP-Value CalculatorT-Test CalculatorConfidence Interval CalculatorSample Size CalculatorChi-Square CalculatorCorrelation Coefficient CalculatorLinear Regression CalculatorANOVA CalculatorProbability Distribution Calculator

Categories

AcademicTextMathematicsStatisticsMachine LearningAIData ScienceFile
All tools
Statistics

Line of Best Fit Calculator

Paste your points to see the best fit line on a scatter plot, with its equation and predictions.

Try:
One pair per line, separated by a comma, tab or space. Two columns copied from Excel work. A text first line is used as the axis names.
Model
Confidence level

Linear regression

y^=−112.84+25.558x\hat{y}=-112.84 + 25.558xy^​=−112.84+25.558x

p = 0.0002 < α = 0.05, so reject H0: the slope is 0. There is evidence that x helps predict y. The line is y = -112.8 + 25.56x and explains 87.2% of the variation in y (r² = 0.8725).

Slope (m)25.5583
Intercept (b)-112.839
Correlation r0.93406
R squared0.87246
Std. error of slope3.6934
Std. error of estimate57.218
p for slope0.0002272 (t = 6.92, df 7)
95% CI, slope16.825 to 34.292
95% CI, intercept-310.2 to 84.521
Points9

At temp = 25, the predicted sales is 526.12. The 95% prediction interval for a single new point is 381.11 to 671.12, and the 95% interval for the mean response is 473.96 to 578.28.

Compare models by R squared

ModelEquationR²Adjusted R²
Lineary^=−112.84+25.558x\hat{y}=-112.84 + 25.558xy^​=−112.84+25.558x0.872460.85424
Polynomial (degree 2) (highest)y^=−225.56+36.404x−0.24648x2\hat{y}=-225.56 + 36.404x - 0.24648x^{2}y^​=−225.56+36.404x−0.24648x20.874130.83217
Exponentialy=110.24 e0.061384xy=110.24\,e^{0.061384x}y=110.24e0.061384x0.84240.81988
Logarithmicy=−1204.9+540.27ln⁡xy=-1204.9 + 540.27\ln xy=−1204.9+540.27lnx0.872810.85464

A higher-degree polynomial always raises R², even when it only follows noise, so look at adjusted R² too. The exponential R² is measured on the original y values.

Residual plot

tempsalesFittedResidual
14215244.978-29.978
16325296.09428.906
18332347.211-15.211
20406398.3287.6722
22522449.44472.556
24412500.561-88.561
26614551.67862.322
28544602.794-58.794
30675653.91121.089

Least squares, step by step

  1. 1Means and sums
    xˉ=∑xn, yˉ=∑yn, Sxx=∑(x−xˉ)2, Sxy=∑(x−xˉ)(y−yˉ)\bar{x}=\frac{\sum x}{n},\ \bar{y}=\frac{\sum y}{n},\ S_{xx}=\sum(x-\bar{x})^2,\ S_{xy}=\sum(x-\bar{x})(y-\bar{y})xˉ=n∑x​, yˉ​=n∑y​, Sxx​=∑(x−xˉ)2, Sxy​=∑(x−xˉ)(y−yˉ​)
    ↓
    xˉ=22, yˉ=449.44, Sxx=240, Sxy=6134\bar{x}=22,\ \bar{y}=449.44,\ S_{xx}=240,\ S_{xy}=6134xˉ=22, yˉ​=449.44, Sxx​=240, Sxy​=6134
  2. 2Slope
    m=SxySxxm=\frac{S_{xy}}{S_{xx}}m=Sxx​Sxy​​
    ↓
    m=6134240=25.558m=\frac{6134}{240}=25.558m=2406134​=25.558
  3. 3Intercept
    b=yˉ−mxˉb=\bar{y}-m\bar{x}b=yˉ​−mxˉ
    ↓
    b=449.44−25.558⋅22=−112.84b=449.44-25.558\cdot 22=-112.84b=449.44−25.558⋅22=−112.84
  4. 4Fit quality
    r2=1−SSresSStot, s=SSresn−2r^2=1-\frac{SS_{res}}{SS_{tot}},\ s=\sqrt{\frac{SS_{res}}{n-2}}r2=1−SStot​SSres​​, s=n−2SSres​​​
    ↓
    r2=0.8725, s=57.22r^2=0.8725,\ s=57.22r2=0.8725, s=57.22

    Slope test: t = 6.92 with 7 degrees of freedom, p = 0.000227.

  1. Tools
  2. Statistics
  3. Linear Regression Calculator
  4. Line of Best Fit Calculator

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

  1. 1Paste two columns from a spreadsheet or type one x, y pair per line. A text first line is used as the axis names.
  2. 2Choose the model: linear, polynomial, exponential or logarithmic. For a polynomial, pick the degree.
  3. 3Read the equation and the statistics table. For the line, the slope p-value tests whether x helps predict y at all.
  4. 4Type an x value in the prediction box to get the predicted y and, for the linear model, its intervals.
  5. 5Check the residual plot. Residuals should scatter randomly around zero. A curve or a funnel means the model is wrong or the spread changes.
  6. 6Open 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.

Ulkaa Apps

  • Ulkaa
  • Calendar
  • Task
  • Note
  • Disk
  • Call
  • Contact
  • Mail
  • Finance
  • Health
  • Office
  • Work
  • Workspace
  • Halum
  • Jaal
  • Islam
  • Game
  • Weather
  • Campus
  • News
  • Developer
  • Help
  • Account
About·Privacy·Terms·© 2026 Ulkaa

What is Ulkaa Tool?

Ulkaa Tool is a free collection of fast, privacy-friendly online tools from Ulkaa Network. Calculate your GPA and CGPA, edit rich text, count words and characters, replace text and more — all in your browser.

Every tool runs entirely in your browser — no sign-up, and your data never leaves your device.

Academic

  • GPA Calculator
  • CGPA Calculator
  • Citation Generator
  • Quiz Maker

Text

  • Rich Text Editor
  • Word Counter
  • Character Counter
  • Text Replacement

Ulkaa

  • Ulkaa
  • Ulkaa News
  • Ulkaa Campus
  • Ulkaa Tool
  • Ulkaa Game
  • Ulkaa Weather
  • Ulkaa Islam

Company

  • About Ulkaa
  • Careers
  • Support
  • Help
  • Privacy Policy
  • Terms of Service
  • Disclaimer
  • Sitemap

© 2015-26, Ulkaa. All rights reserved.
Facebook PageLinkedIn CompanyX (Twitter) ProfileInstagram ProfileGitHub Account
Table of values
sales against temp with the linear fit
PointDataLinear fit95% prediction band (upper)95% prediction band (lower)
1(14, 215)(13.36, 228.6204444444444)(14, 403.79055203356575)(14, 86.16500352198975)
2(16, 325)(13.575999999999999, 234.1410444444444)(14.4, 412.50827307614816)(14.4, 97.89394914607405)
3(18, 332)(13.792, 239.66164444444445)(14.8, 421.2897614484198)(14.8, 109.55912744046913)
4(20, 406)(14.008, 245.1822444444444)(15.2, 430.13680258079035)(15.2, 121.15875297476512)
5(22, 522)(14.224, 250.70284444444445)(15.6, 439.05116341885366)(15.6, 132.6910588033685)
6(24, 412)(14.44, 256.2234444444444)(16, 448.03458386125703)(16, 144.15430502763184)
7(26, 614)(14.655999999999999, 261.7440444444444)(16.4, 457.0887677180807)(16.4, 155.54678783747474)
8(28, 544)(14.872, 267.2646444444444)(16.8, 466.2153732597459)(16.8, 166.8668489624764)
9(30, 675)(15.088, 272.7852444444444)(17.2, 475.4160034422508)(17.2, 178.112885446638)
10(15.304, 278.30584444444446)(17.6, 484.6921959100706)(17.6, 189.28335964548498)
11(15.52, 283.8264444444444)(18, 494.0454128927482)(18, 200.37680932947404)
12(15.736, 289.34704444444446)(18.4, 503.47703112443764)(18.4, 211.3918577644512)
13(15.952, 294.8676444444444)(18.8, 512.9883319267474)(18.8, 222.32722362880824)
14(16.168, 300.3882444444444)(19.2, 522.5804916035328)(19.2, 233.18173061868936)
15(16.384, 305.90884444444447)(19.6, 532.2545723011879)(19.6, 243.95431658770104)
16(16.6, 311.42944444444447)(20, 542.0115134889609)(20, 254.6440420665947)
17(16.816, 316.9500444444444)(20.4, 551.8521242104871)(20.4, 265.25009801173496)
18(17.032, 322.4706444444444)(20.8, 561.7770762498584)(20.8, 275.7718126390306)
19(17.248, 327.9912444444445)(21.2, 571.7868983431163)(21.2, 286.2086572124392)
20(17.464, 333.5118444444444)(21.6, 581.8819715492551)(21.6, 296.5602506729673)
21(17.68, 339.0324444444444)(22, 592.0625258740486)(22, 306.82636301484035)
22(17.896, 344.5530444444445)(22.4, 602.3286382159216)(22.4, 317.0069173396338)
23(18.112000000000002, 350.0736444444445)(22.8, 612.6802316764497)(22.8, 327.10199054577265)
24(18.328, 355.5942444444444)(23.2, 623.1170762498583)(23.2, 337.1118126390305)
25(18.544, 361.11484444444443)(23.6, 633.638790877154)(23.6, 347.0367646784018)
26(18.759999999999998, 366.6354444444444)(24, 644.2448468222942)(24, 356.87737539992804)
27(18.976, 372.15604444444443)(24.4, 654.9345723011878)(24.4, 366.63431658770094)
28(19.192, 377.67664444444443)(24.8, 665.7071582701996)(24.8, 376.30839728535614)
29(19.408, 383.1972444444445)(25.2, 676.5616652600806)(25.2, 385.90055696214154)
30(19.624, 388.71784444444444)(25.6, 687.4970311244377)(25.6, 395.4118577644514)
31(19.84, 394.23844444444444)(26, 698.5120795594148)(26, 404.84347599614074)
32(20.056, 399.7590444444445)(26.4, 709.6055292434039)(26.4, 414.1966929788182)
33(20.272, 405.27964444444444)(26.8, 720.776003442251)(26.8, 423.4728854466381)
34(20.488, 410.8002444444444)(27.2, 732.0220399264125)(27.2, 432.673515629143)
35(20.704, 416.32084444444445)(27.6, 743.3421010514143)(27.6, 441.8001211708082)
36(20.92, 421.8414444444445)(28, 754.7345838612571)(28, 450.8543050276319)
37(21.136, 427.36204444444445)(28.4, 766.1978300855203)(28.4, 459.83772547003514)
38(21.352, 432.8826444444445)(28.8, 777.7301359141238)(28.8, 468.75208630809857)
39(21.568, 438.40324444444445)(29.2, 789.3297614484197)(29.2, 477.5991274404691)
40(21.784, 443.9238444444444)(29.6, 800.994939742815)(29.6, 486.38061581274087)
41(22, 449.44444444444446)(30, 812.7238853668991)(30, 495.09833685532317)
42(22.216, 454.9650444444445)
43(22.432, 460.48564444444446)
44(22.648, 466.0062444444444)
45(22.864, 471.52684444444446)
46(23.08, 477.0474444444444)
47(23.296, 482.56804444444447)
48(23.512, 488.0886444444445)
49(23.728, 493.60924444444447)
50(23.944, 499.1298444444444)
51(24.16, 504.6504444444445)
52(24.376, 510.17104444444453)
53(24.592, 515.6916444444445)
54(24.808, 521.2122444444444)
55(25.024, 526.7328444444445)
56(25.240000000000002, 532.2534444444445)
57(25.456, 537.7740444444445)
58(25.672, 543.2946444444444)
59(25.887999999999998, 548.8152444444444)
60(26.104, 554.3358444444444)
61(26.32, 559.8564444444445)
62(26.536, 565.3770444444446)
63(26.752000000000002, 570.8976444444445)
64(26.968, 576.4182444444444)
65(27.184, 581.9388444444445)
66(27.4, 587.4594444444444)
67(27.616, 592.9800444444445)
68(27.832, 598.5006444444444)
69(28.048, 604.0212444444444)
70(28.264000000000003, 609.5418444444446)
71(28.48, 615.0624444444445)
72(28.696, 620.5830444444446)
73(28.912, 626.1036444444445)
74(29.128, 631.6242444444445)
75(29.344, 637.1448444444445)
76(29.56, 642.6654444444445)
77(29.776000000000003, 648.1860444444445)
78(29.992, 653.7066444444445)
79(30.208000000000002, 659.2272444444445)
80(30.424, 664.7478444444445)
81(30.64, 670.2684444444445)
Table of values
Residuals against x. Random scatter around zero means the model fits well.
PointResidualsZero
1(14, -29.97777777777776)(14, 0)
2(16, 28.905555555555566)(30, 0)
3(18, -15.211111111111109)
4(20, 7.672222222222217)
5(22, 72.55555555555554)
6(24, -88.56111111111113)
7(26, 62.322222222222194)
8(28, -58.79444444444448)
9(30, 21.088888888888846)