Skip to content
Quantoros

Does an empty residual array returned by lstsq always mean a perfect fit?

MathematicsLevel: IntermediateStable linear systems

Does an empty residual array returned by lstsq always mean a perfect fit?

Hints
  • Read the return-shape conditions.
  • Empty is not necessarily zero.

Answer

No. It is also empty for rank-deficient or underdetermined configurations. Compute ||Ax−b|| directly and inspect rank and dimensions.

Source and licence: NumPy — numerical linear algebra · BSD-3-Clause · answer: Quantoros editorial

Related questions