wholecell.utils.fast_nonnegative_least_squares

Faster implementation of nonnegative least squares.

wholecell.utils.fast_nonnegative_least_squares.fast_nnls(A, b)[source]

Faster implementation of the nonnegative least squares algorithm, which returns a nonnegative vector x that minimizes ||Ax - b||_2. This function utilizes the property that both matrix A and vector b can be divided into matrices and vectors that each form a smaller nonnegative least squares problem, which can each be solved independently and the solutions later concatenated to yield the full vector x. Argument A can given as either a full numpy array or a scipy sparse matrix.

Parameters:
  • A – np.ndarray or scipy.sparse.csr.csr_matrix of size (M, N)

  • b – numpy.ndarray of size (M, )

Returns:

numpy.ndarray of size (N, ), the solution to the NNLS problem. r: numpy.ndarray of size (M, ), the residual vector (Ax - b) of the NNLS

problem.

Return type:

x