| DoubleNonnegativeLeastSquares(DoubleMatrix, DoubleVector, Boolean, Double, Int32, DoubleVector) Constructor |
Constructs a nonnegative least squares solution for the given linear system
Ax = y, optionally adding an intercept parameter to the
model.
Namespace: CenterSpace.NMath.CoreAssembly: NMath (in NMath.dll) Version: 7.4
Syntax public DoubleNonnegativeLeastSquares(
DoubleMatrix A,
DoubleVector y,
bool addIntercept,
double tolerance,
int maxIterations,
DoubleVector weights = null
)
Public Sub New (
A As DoubleMatrix,
y As DoubleVector,
addIntercept As Boolean,
tolerance As Double,
maxIterations As Integer,
Optional weights As DoubleVector = Nothing
)
public:
DoubleNonnegativeLeastSquares(
DoubleMatrix^ A,
DoubleVector^ y,
bool addIntercept,
double tolerance,
int maxIterations,
DoubleVector^ weights = nullptr
)
new :
A : DoubleMatrix *
y : DoubleVector *
addIntercept : bool *
tolerance : float *
maxIterations : int *
?weights : DoubleVector
(* Defaults:
let _weights = defaultArg weights null
*)
-> DoubleNonnegativeLeastSquares
Parameters
- A DoubleMatrix
- The matrix.
- y DoubleVector
- The right hand side.
- addIntercept Boolean
- If true, a column of ones is prepended to
a deep copy of matrix A before solving for the nonnegative least squares solution.
This corresponds to adding an intercept parameter to the model. Note: the
input matrix A is not changed.
- tolerance Double
- Specifies a tolerance for detecting rank deficiency while
solving the nonnegative least squares problem.
- maxIterations Int32
- Maximum number of iterations to perform.
- weights DoubleVector (Optional)
- Weights. Null if unweighted.
Exceptions Exception | Condition |
---|
MismatchedSizeException | Thrown if the number of rows
in A is not equal to the length of y. |
NMathException | Thrown if the specified maximum number of
iterations performed by the algorithm was exceeded. |
Remarks The nonnegative least squares
algorithm is an iterative algorithm which may solve an unconstrained least
least squares problem, Bx = y, during an iteration. If the matrix
B is rank deficient (has less than full rank) the solution is not
unique and is somewhat suspect. If such a rank deficiency is detetected
while performing the nonnegative least squares algorithm the
RankDeficiencyDetected property will return true.
See Also