﻿DoubleNonnegativeLeastSquares Class

# DoubleNonnegativeLeastSquares Class

Class DoubleNonnegativeLeastSquares computes the minimum-norm solution to a linear system Ax = y subject to the constraint that all the elements, x[i], are nonnegative.
Inheritance Hierarchy
SystemObject
CenterSpace.NMath.CoreDoubleNonnegativeLeastSquares

Namespace: CenterSpace.NMath.Core
Assembly: NMath (in NMath.dll) Version: 7.4
Syntax
```[SerializableAttribute]
public class DoubleNonnegativeLeastSquares : ICloneable```

The DoubleNonnegativeLeastSquares type exposes the following members.

Constructors
NameDescription
DoubleNonnegativeLeastSquares(DoubleMatrix, DoubleVector, DoubleVector) Constructs a nonnegative least squares solution for the given linear system Ax = y.
DoubleNonnegativeLeastSquares(DoubleMatrix, DoubleVector, Boolean, DoubleVector) Constructs a nonnegative least squares solution for the given linear system Ax = y, optionally adding an intercept parameter to the model.
DoubleNonnegativeLeastSquares(DoubleMatrix, DoubleVector, Boolean, Double, DoubleVector) Constructs a nonnegative least squares solution for the given linear system Ax = y, optionally adding an intercept parameter to the model.
DoubleNonnegativeLeastSquares(DoubleMatrix, DoubleVector, Boolean, Double, Int32, DoubleVector) Constructs a nonnegative least squares solution for the given linear system Ax = y, optionally adding an intercept parameter to the model.
Top
Properties
NameDescription
Iterations Gets the number of iterations performed by the algorithm.
MaxIterations Gets the sets the maximum number of iterations performed by the algorithm. Default is FloatNonnegativeLeastSquares.DEFAULT_MAX_ITERATIONS = 100000.
RankDeficiencyDetected If a rank deficiency was detected while solving an unconstrained least squares problem during the nonnegative least squares iterative algorithm, true is returned.
Residuals Gets the vector of residuals. If y is the right-hand side of the least squares equation Ax = y, and we denote by yhat the vector Ax where x is the computed least squares solution, then the vector of residuals r is the vector whose ith component is r[i] = y[i] - yhat[i].
ResidualSumOfSquares Gets the residual sum of squares. If y is the right-hand side of the least squares equation Ax = y, and we denote by yhat the vector Ax where x is the computed least squares solution, then the residual sum of squares is defined to be (y[0] - yhat[0])^2 + (y[1] - yhat[1])^2 + ... + (y[m-1] - yhat[m-1])^2.
Result Gets the result of the nonnegative least squares fit.
Tolerance Gets and sets the tolerance for detecting rank deficiency while solving the nonnegative least squares problem. This number should be "small" relative to the input data and within the precision of a double precision number. Default value is DoubleNonnegativeLeastSquares.DEFAULT_TOLERANCE = 1e-12
X Gets the nonnegative least squares solution x for the least squares problem Ax = y.
Yhat Gets the predicted value of y by computing yHat = Ax, where x is the calculated solution to the least squares problem Ax = y.
Top
Methods
NameDescription
Clone Creates a deep copy of this least squares.
SolveUnconstrainedLeastSq
Top
Fields
NameDescription
DEFAULT_MAX_ITERATIONS Default maximum number of iterations to be performed by the algorithm.
DEFAULT_TOLERANCE The default tolerance for detecting rank deficiency while solving the nonnegative least squares problem.
Top
Remarks
In a least squares problem, we assume a linear model for a quantity y that depends on one or more independent variables a1, a2,...,an; that is, y = x0 + x1*a1 + ... + xn*an. x0 is called the intercept parameter.
The goal of a nonnegative least squares problem is to solve for the best values of x0, x1,...,xn subject to the constriant that xi >= 0 for i = 0, 1,..., n. Several observations of the independent values ai are recorded, along with the corresponding values of the dependent variable y. If m observations are performed, and for the ith observation we denote the values of the independent variables ai1, ai2,...ain and the corresponding dependent value of y as yi, then we form the linear system Ax = y, where A = (aij) and y = (yi). The nonnegative least squares solution is the value of x that minimizes ||Ax - y|| subject to the constraint that each element of the vector x is nonnegative.
Note that if the model contains a non-zero intercept parameter, then the first column of A is all ones.