Calculate linear regression using the least squares method. Fit a line to your data with detailed statistics and visualization.
Import data from CSV file
Click here or drag and drop a CSV file
| # | x-value | y-value | Actions |
|---|
Least squares regression is a statistical method used to find the line of best fit for a set of data points by minimizing the sum of the squares of the vertical distances (residuals) between the observed values and the values predicted by the line.
Mathematical Formulation:
For linear regression y = a + bx, we minimize:
S = Σ(yᵢ - (a + bxᵢ))²
The solution for the coefficients a and b is:
b = Σ[(xᵢ - x̄)(yᵢ - ȳ)] / Σ[(xᵢ - x̄)²]
a = ȳ - b·x̄
where x̄ and ȳ are the means of x and y values respectively.
Residuals: The vertical distances between observed data points and the regression line. Least squares minimizes the sum of squared residuals.
R-squared (R²): Measures how well the regression line approximates the real data points. R² = 1 indicates perfect fit, R² = 0 indicates no linear relationship.
Correlation Coefficient (r): Measures the strength and direction of the linear relationship between x and y. Ranges from -1 to +1.
| Type | Equation | When to Use |
|---|---|---|
| Linear | y = a + bx | When relationship appears straight-line |
| Exponential | y = a·e^(bx) | When y changes at a rate proportional to its current value |
| Logarithmic | y = a + b·ln(x) | When y increases/decreases quickly then levels off |
| Power | y = a·x^b | When both variables show proportional relative change |
| Polynomial | y = a + bx + cx² + ... | When relationship shows curvature |
Calculator Features:
Import data from CSV file with format:
x,y 1,2.1 2,3.9 3,6.2 4,8.1 5,9.8
Or simply two columns without headers.