PhysicsScore

Least squares fitting

  • CSIR NET
  • UP Assistant Professor

4 minute read · Updated 2026-11-15

Picking up from

In Precision and accuracy, error analysis, propagation of errors, we saw that measurement uncertainty combines finite resolution, repeatability and systematic effects, with correlations controlling how derived uncertainties combine. How can many measurements constrain a shared set of model parameters?

In one line

Least squares chooses parameters that minimize a stated residual measure, with weights reflecting the measurement-noise model.

The idea, explained

A fitted model predicts an observation from known inputs and unknown parameters. A residual is the difference between an observed value and that prediction. Least squares minimizes a sum of squared residuals; weighted least squares scales them according to declared uncertainties or covariance. The result is not simply a curve drawn through as many data points as possible.

For a model linear in its parameters, minimization produces linear normal equations or an equivalent numerically stable matrix solution. Linear in parameters can include polynomial or other fixed basis functions, not only a straight line. Parameter uncertainty depends on measurement uncertainties, design and assumptions about the residuals. A small residual sum does not prove the model is physically correct: overfitting, correlated noise, biased inputs or inappropriate weights can produce misleading apparent agreement. Residual patterns are therefore part of the inference rather than optional decoration after obtaining coefficients.

Core ideas

  • State whether input coordinates are treated as exact. Ordinary output-only least squares does not automatically handle uncertainty in both axes.
  • Weights are often inverse variances when errors are independent with known scale. An arbitrary visual preference is not a statistical uncertainty weight.
  • A linear parameter system can be ill conditioned when predictors are nearly redundant. More printed coefficient digits do not repair insufficient information.
  • Parameter covariance includes correlations between fitted coefficients. Reporting separate errors alone can hide uncertainty in a derived combination.
  • A fitted line’s uncertainty near observed inputs differs from prediction uncertainty for a new noisy observation or extrapolation outside the data range.

Key formulas

Weighted residual objective

χ2(θ)=∑i[yi−f(xi;θ)]2σi2\chi^2(\boldsymbol\theta)=\sum_i\frac{[y_i-f(x_i;\boldsymbol\theta)]^2}{\sigma_i^2}

The displayed form assumes independent output errors with known standard deviations σi\sigma_i.

Linear-model normal equations

XTWX θ^=XTWyX^TWX\,\hat{\boldsymbol\theta}=X^TW\mathbf y

The design matrix is XX and weight matrix is WW; practical solution methods should account for conditioning rather than blindly invert a matrix.

Choose a physically motivated model and write which variables are uncertain. Inspect units and rank of the design matrix, then use a stable solution appropriate to conditioning. After fitting, plot or inspect residuals against input and acquisition order to detect missed structure or drift. Calculate parameter covariance under the same noise assumptions used for weights. Distinguish interpolation from extrapolation and avoid claiming that a minimized sum validates a mechanism that was never tested against alternatives.

Quick worked example

For a constant model with equal independent uncertainties, least squares returns the ordinary arithmetic mean. With unequal known variances, it returns an inverse-variance weighted mean. The change follows the noise model, not a different definition of a physical average.

Where this leads

Continue to Linear and nonlinear curve fitting, chi-square test, because nonlinear models and goodness-of-fit tests require additional approximation and distribution checks.

Related: Roots of functions, interpolation, extrapolation — interpolation and model-based extrapolation have different error risks.

Practice this topic

Practice this topic

13 questions in Assistant Professor · Physics · Physics. Sign in and practice access may be required.