pd_check | R Documentation |
We desire that Hessian matrices of objective functions for optimization are symmetric and positive definite. Symmetry is easy to check, but we caution that evaluation or approximation of a Hessian often gives a slightly asymmetric, and we commonly average the elements that are supposed to be equal, thereby symmetrizing the proposed Hessian.
The Cholesky decomposition will fail for a symmetric matrix which is NOT positive definite.
pd_check(A, pivot=TRUE, tol=1.e-07)
A |
A symmetric matrix |
pivot |
Use pivoting in the Cholesky decomposition attempt |
tol |
A tolerance for zero |
The function returns a logical TRUE if the decomposition can be carried out, FALSE otherwise.
n <- 10
A <- pracma::moler(n)
system.time(print(pd_check(A))) # returns FALSE
system.time(print(eigen(A)$value))
n <- 100
A <- pracma::moler(n)
system.time(print(pd_check(A))) # returns FALSE
system.time(print(eigen(A)$value))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.