View source: R/quadratic_forms.R
is_psd_matrix | R Documentation |
Check whether a matrix is positive semidefinite, based on checking for symmetric and negative eigenvalues.
is_psd_matrix(X, tolerance = sqrt(.Machine$double.eps))
X |
A matrix with no missing or infinite values. |
tolerance |
Tolerance for controlling whether
a tiny computed eigenvalue will actually be considered negative.
Computed negative eigenvalues will be considered
negative if they are less than which are less than
|
A logical value. TRUE
if the matrix is deemed positive semidefinite.
Negative otherwise (including if X
is not symmetric).
The function get_nearest_psd_matrix()
can be used to approximate a symmetric matrix which is not positive semidefinite,
by a similar positive semidefinite matrix.
X <- matrix(
c(2, 5, 5,
5, 2, 5,
5, 5, 2),
nrow = 3, byrow = TRUE
)
is_psd_matrix(X)
eigen(X)$values
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.