What is the difference between numpy.linalg.lstsq and scipy.linalg.lstsq?

前端 未结 2 1978
深忆病人
深忆病人 2021-02-01 15:38

lstsq tries to solve Ax=b minimizing |b - Ax|. Both scipy and numpy provide a linalg.lstsq function with a very similar inter

2条回答
  •  心在旅途
    2021-02-01 16:10

    If I read the source code right (Numpy 1.8.2, Scipy 0.14.1 ), numpy.linalg.lstsq() uses the LAPACK routine xGELSD and scipy.linalg.lstsq() usesxGELSS.

    The LAPACK Manual Sec. 2.4 states

    The subroutine xGELSD is significantly faster than its older counterpart xGELSS, especially for large problems, but may require somewhat more workspace depending on the matrix dimensions.

    That means that Numpy is faster but uses more memory.

    Update August 2017:

    Scipy now uses xGELSD by default https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.lstsq.html

提交回复
热议问题