[Numpy-discussion] np.linalg.lstsq with several columns all 0 => huge x ?

denis denis-bz-gg at t-online.de
Wed Oct 24 13:33:18 EDT 2012


Folks,
   np.linalg.lstsq of a random-uniform A 50 x 32 with 3 columns all 0
returns x[:3] 0 as expected,
but 4 columns all 0 => huge x:
lstsq (50, 32) with 4 columns all 0:
     [ -3.7e+09  -3.6e+13  -1.9e+13  -2.9e+12  7.3e-01 ...

This may be a roundoff problem, or even a Mac Altivec lapack bug,
not worth looking into. linalg.svd is ok though, odd.

Summary: if you run linalg.lstsq on big arrays,
either check max |x|
or regularize, do lstsq( vstack( A, weight * eye(dim) ),
                          hstack( b, zeros(dim) ))

cheers
   -- denis




More information about the NumPy-Discussion mailing list