Least Squares Regression Line Calculator
Enter paired x, y data to find the best-fit line, or predict y from a known regression equation.
📈 What is the Least Squares Regression Line?
The least squares regression line (also called the line of best fit) is the unique straight line ŷ = mx + b that minimises the sum of the squared vertical distances from each observed data point to the line. These vertical distances are called residuals, and squaring them ensures that positive and negative deviations both contribute positively to the total. By choosing the slope m and intercept b to make this sum as small as possible, least squares produces the line that best summarises the linear trend in the data.
The method was developed independently by Carl Friedrich Gauss and Adrien-Marie Legendre in the late 18th century. Gauss used it to predict the orbit of the dwarf planet Ceres from a limited number of astronomical observations, successfully locating it after it disappeared behind the sun. Since then, least squares regression has become one of the most widely used methods in data analysis, statistics, econometrics, engineering, and the natural sciences.
The regression line has two key properties. First, it always passes through the mean point (x̄, ȳ): substituting the mean x into the equation gives exactly the mean y. Second, the sum of all residuals is zero: the positive and negative deviations cancel out. These properties confirm that the line is centred on the data in a precise mathematical sense.
This calculator accepts x and y data in the Regression mode and computes the slope m, intercept b, Pearson correlation coefficient r, R² (coefficient of determination), mean values, and a full residuals table. Predict mode lets you enter a slope and intercept directly and forecast y for any x value.