Use the free Linear Regression Calculator below: your data never leaves your browser — all work happens on your device, and nothing is uploaded to any server.
What a linear regression line actually tells you
Linear regression answers a simple question: if x goes up, what usually happens to y? You collect pairs of numbers, for example hours studied and test scores, or advertising spend and sales. The regression line is the straight line that sits closest to all of your points at once. It does not pass through every point. Instead, it balances the gaps above and below it, so the total squared error is as small as possible. That is why it is called the least-squares line.
The line has two parts. The slope tells you how much y changes when x rises by one unit. A slope of 2.5 means each extra unit of x is linked to 2.5 extra units of y, on average. The intercept tells you the predicted value of y when x equals zero. Sometimes the intercept makes real sense, for example a base price before any extra features. Sometimes it does not, because x equal to zero may never happen in real life. Always check whether the intercept describes a situation that could exist.
How the slope and intercept are worked out
Behind the tool, the maths uses sums, not guesswork. First it adds up all the x values, all the y values, all the x times y products, and all the squared x values. From those four sums it builds the slope: the number of points times the sum of xy, minus the sum of x times the sum of y, all divided by the number of points times the sum of squared x, minus the square of the sum of x. Once the slope is known, the intercept follows from the two averages: intercept equals the average of y minus slope times the average of x.
One useful fact follows from that formula. The regression line always passes through the point made of the two averages. If you plot your data and the fitted line, the line will cross exactly at the average x and the average y. That is a quick visual check that a hand-drawn or software line is in the right place. If your line misses that centre point, something is wrong.
Reading the correlation number
Alongside the line, the tool shows the correlation coefficient r. This number runs from minus 1 to plus 1. A value near 1 means the points hug a rising line. A value near minus 1 means they hug a falling line. A value near 0 means there is no straight-line pattern, even though some other curved pattern might exist. The square of r, called R squared, tells you what share of the variation in y the line explains. An R squared of 0.64 means the line accounts for about 64 percent of the ups and downs in y.
A strong correlation still does not prove that x causes y. Ice cream sales and sunburn cases rise together, but both are driven by hot weather. Regression describes a pattern in your data; it cannot by itself tell you what causes what. Before acting on a regression result, ask what else could move with both variables, and whether the link makes sense in the real world.
Using predictions without fooling yourself
Predictions are safest inside the range of x values you actually measured. If your data covers study times from one to five hours, predicting for six hours is a small stretch, but predicting for twenty hours is a leap of faith. Real relationships often flatten, bend, or hit limits outside the observed range. The tool will still give you a number for any x, because the maths does not know where your data stops. You have to apply that judgement yourself.
Outliers deserve a second look too. One extreme point can drag the whole line toward itself, especially when its x value sits far from the rest. Before trusting a fit, plot the points, spot any odd ones, and check whether they are real data or mistakes. Removing a genuine point just because it is inconvenient is dishonest, but correcting a typo or a faulty sensor reading is good practice.
When a straight line is the wrong tool
Not every relationship is straight. If your points form a curve, a U shape, or a pattern that levels off, a straight line will mislead you even if the maths runs fine. Look at the scatter of points first, not just the numbers. A line through a curve will over-predict in the middle and under-predict at the ends, or the other way round. In those cases a curved model, or a transformation such as taking logarithms, fits better.
Regression also assumes your data points are separate observations. If the same person or machine appears many times, or the data comes in a time sequence, the simple version can overstate how sure you should be. For schoolwork, small business checks, and everyday analysis, though, the least-squares line is a strong starting point. Paste your pairs, read the slope and intercept, check r, and let the line describe the pattern, not invent it.
Related tools
- Calculadora de Regresión Lineal (Spanish version)
- Normal Distribution Calculator
- Probability Calculator
