# scipy.optimize.nnls¶

scipy.optimize.nnls(A, b, maxiter=None)[source]

Solve argmin_x || Ax - b ||_2 for x>=0. This is a wrapper for a FORTRAN non-negative least squares solver.

Parameters
Andarray

Matrix A as shown above.

bndarray

Right-hand side vector.

maxiter: int, optional

Maximum number of iterations, optional. Default is 3 * A.shape[1].

Returns
xndarray

Solution vector.

rnormfloat

The residual, || Ax-b ||_2.

Notes

The FORTRAN code was published in the book below. The algorithm is an active set method. It solves the KKT (Karush-Kuhn-Tucker) conditions for the non-negative least squares problem.

References

Lawson C., Hanson R.J., (1987) Solving Least Squares Problems, SIAM

#### Previous topic

scipy.optimize.least_squares

#### Next topic

scipy.optimize.lsq_linear