﻿# Robust least squares reports a cost that differs from raw squared residuals

Robust least squares reports a cost that differs from raw squared residuals. A focused scientific-computing guide with the documented mechanism, a reproducible validation scenario, evidence and operational limits.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/science-least-squares-robust-cost-raw-residuals/
Language: en

A robust least-squares result can report a small optimized cost while some raw residuals remain large. That is not necessarily a reporting defect: the selected loss changes how residuals contribute. A scientific AI calibration pipeline must distinguish the optimized objective from ordinary squared-error metrics before comparing fitted physical parameters or generating confidence-like labels.

## The scientific interface

SciPy least_squares defines cost through the selected loss applied to squared residuals, with f_scale controlling the robust transition scale. Its result also contains the raw residual vector. Under robust loss, these quantities cannot be collapsed into one ordinary residual-sum interpretation. The returned Jacobian is documented as modified for the cost's local approximation, so it should not automatically be treated as an untouched physical derivative matrix. Objective choice and reporting choice are separate parts of the experiment.

## Implementation details

Preserve loss, f_scale, bounds and residual definition with the fitted parameters. Report raw residual diagnostics and the optimized robust cost under distinct names. If comparing methods by a common scientific error, calculate that metric independently on the same declared observations rather than directly comparing unlike objective values. Treat any covariance or sensitivity estimate according to the actual derivative and loss contract. Do not label downweighted observations as removed unless the pipeline really excluded them; the robust objective changes their influence without necessarily changing dataset membership.

## A constructed validation case

Fit a controlled model to observations containing a known outlying value. Compare linear and a supported robust loss while retaining the raw residual vector, selected scale and independently computed common error. Verify that reported cost follows its own objective rather than being mislabeled as ordinary squared error. Add a deliberately mismatched residual-scale case. Acceptance requires correct objective provenance and interpretable comparisons; it does not require robust fitting to outperform every alternative or establish that all outliers were scientifically irrelevant.

## Numerical and data limits

A converged robust fit is not a validation of the physical model or a calibrated probability statement. Keep optimization, residual analysis and scientific interpretation separate. This prevents a convenient cost field from becoming unsupported evidence about predictive uncertainty or the usefulness of a learned surrogate.

## Primary references

[SciPy optimize.least_squares API](https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.least_squares.html); [SciPy optimization guide](https://docs.scipy.org/doc/scipy/tutorial/optimize.html).

This is a proposed scientific-interface validation, not an executed Retrivium benchmark. Preserve the implementation version and unresolved outcomes; interface documentation does not establish the accuracy or performance of a scientific model.

## Related reading

[Calibration compares reported confidence with observed correctness](/journal/neural-confidence-calibration-bins/); [A GPU inference benchmark you can trust](/journal/inference-benchmark-method/).
