Enter the observed and predicted values into the calculator to determine the least square error. This calculator helps in assessing the accuracy of a model by comparing the predicted values to the actual observed values.

Least Square Error Calculator

Enter any 2 values to calculate the missing variable

Least Square Error Formula

Least square error measures the average squared difference between observed values and predicted values. It is a standard way to evaluate how closely a model, forecast, or estimate matches actual data. Lower values indicate a better fit, while a value of 0 means the predictions match the observations exactly.

LSE = \frac{1}{n}\sum_{i=1}^{n}(O_i - P_i)^2
Term Meaning
LSE Least square error, or the average squared prediction error
n Total number of paired data points
Observed values The actual measured values
Predicted values The values produced by a model, formula, or forecast

This calculator compares each observed value with its matching predicted value, squares each difference, adds those squared differences together, and divides by the number of data points.

How to Calculate Least Square Error

  1. Enter the observed values as a comma-separated list.
  2. Enter the predicted values in the same order and with the same number of items.
  3. Find the residual for each pair by subtracting predicted from observed.
  4. Square each residual so negative and positive misses are treated equally.
  5. Add the squared residuals.
  6. Divide by the total number of paired values.

Example

Suppose the observed values are 2, 4, 6, and 8, while the predicted values are 3, 5, 7, and 9.

O = [2,4,6,8], \quad P = [3,5,7,9]
(O_i - P_i) = [-1,-1,-1,-1]
(O_i - P_i)^2 = [1,1,1,1]
LSE = \frac{1+1+1+1}{4} = 1

The least square error is 1, which means the average squared prediction error across the dataset is 1.

How to Interpret the Result

  • 0 means a perfect fit between predicted and observed values.
  • Smaller values mean the predictions are closer to the actual data.
  • Larger values indicate more prediction error.
  • The unit is squared, so if the original data are in meters, the LSE is in square meters.
  • Large misses matter more because squaring gives extra weight to outliers and large residuals.

Why Squared Error Is Used

  • It prevents positive and negative errors from canceling each other out.
  • It penalizes large mistakes more heavily than small mistakes.
  • It is widely used in regression, forecasting, curve fitting, and machine learning.
  • It creates a smooth objective for optimization methods such as least squares fitting.

Least Square Error vs. Related Metrics

The calculator returns the average squared error. Closely related measures are shown below.

SSE = \sum_{i=1}^{n}(O_i - P_i)^2
RMSE = \sqrt{\frac{1}{n}\sum_{i=1}^{n}(O_i - P_i)^2}
  • SSE is the total squared error across all points.
  • LSE is the average squared error, which makes results easier to compare when datasets have different sizes.
  • RMSE converts the error back to the original unit scale by taking the square root.

Common Input Tips

  • Observed and predicted lists must contain the same number of values.
  • Each predicted value should correspond to the observed value in the same position.
  • Decimals and negative values can be used as long as the formatting is consistent.
  • Separate values with commas only.
  • If one list is shifted or misordered, the calculated error can be misleading even if the numbers are correct.

When This Calculator Is Useful

  • Checking the accuracy of a regression model
  • Comparing forecasted values to actual results
  • Measuring sensor, instrument, or estimation error
  • Evaluating simulation output against real-world observations
  • Comparing multiple models on the same target variable

Frequently Asked Questions

Can least square error be negative?
No. Because each error term is squared, the result is always zero or positive.

Is a lower least square error always better?
Yes, for the same dataset and target variable, a lower value indicates predictions are closer to the observed values.

What happens if one prediction is far off?
The LSE increases quickly because large residuals are squared, which magnifies their effect.

Does this calculator require paired data?
Yes. Every observed value must have one matching predicted value.

Is least square error the same as mean squared error?
For this calculator, the formula is the average of squared residuals, which is the same numerical calculation commonly called mean squared error.