scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
nnls(A, b, maxiter=None)

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.

Parameters

A : ndarray

Matrix A as shown above.

b : ndarray

Right-hand side vector.

maxiter: int, optional :

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

Returns

x : ndarray

Solution vector.

rnorm : float

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

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

See Also

lsq_linear

Linear least squares with bounds on the variables

Examples

>>> from scipy.optimize import nnls
...
>>> A = np.array([[1, 0], [1, 0], [0, 1]])
... b = np.array([2, 1, 1])
... nnls(A, b) (array([1.5, 1. ]), 0.7071067811865475)
>>> b = np.array([-1, -1, -1])
... nnls(A, b) (array([0., 0.]), 1.7320508075688772)
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.optimize._nnls.nnls

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/optimize/_nnls.py#7
type: <class 'function'>
Commit: