Line Of Best Fit Calculator
Calculate the line of best fit (linear regression) for a set of data points. Enter x and y values to get the slope, intercept, and R-squared value.
Was this calculator helpful?
How to use this tool?
How to Use the Line of Best Fit Calculator
- Enter X values in the first field as comma-separated numbers (e.g.,
1,2,3,4,5). - Enter Y values in the second field with the same format and same number of values as X (e.g.,
2,4,5,4,5). - Click Calculate. The calculator will display:
- Equation: The line of best fit in the form
y = mx + b(slope and intercept rounded to 4 decimals). - R²: The coefficient of determination (0 to 1), indicating how well the line fits the data.
- Equation: The line of best fit in the form
- If you see an error, check that:
- Both fields contain numbers separated by commas.
- X and Y have the same count of values.
- You have at least two data points.
- X values are not all identical.
Tip: Use decimal points (e.g., 1.5, 2.3) for non-integer values. No units are required—just raw numbers.
Previous Results
| Result | Inputs | Date |
|---|
Frequently Asked Questions
The line of best fit is a straight line that best represents the data on a scatter plot. It is calculated using linear regression to minimize the sum of squared errors.
Enter your x and y values as comma-separated numbers (e.g., 1,2,3 for x and 2,4,5 for y). Then click Calculate to get the slope, intercept, and R-squared value.
R-squared (R²) is a statistical measure that represents the proportion of the variance for the dependent variable that's explained by the independent variable. Values range from 0 to 1, with higher values indicating a better fit.