How to find the nearest positive definite matix

42 vues (au cours des 30 derniers jours)
Fanqi Meng
Fanqi Meng le 10 Juil 2019
Modifié(e) : Bruno Luong le 28 Juil 2020
Hi, I have a quesiton, I want to use the chol function in matlab but the function requires a strict positive definite matrix as input. How can I find the nearest positive definite matrix?
Thanks

Réponses (2)

Bruno Luong
Bruno Luong le 10 Juil 2019
Modifié(e) : Bruno Luong le 28 Juil 2020
First step of preparation is to "symmetrize" the matrix
A = 0.5*(A + A')
Why? Because MATLAB engine selects the algorithm depending on the matrix form, it can fail to detect the matrix is hermitian (symmetric) if there is numerical error and isequal(A, A') returns FALSE, even if A is very close to A'.
Next, if it's not enough find the smallest eigen value lbdmin of A (use for example EIGS function), then change A by adding
A + max(-lbdmin,0)*speye(size(A)) % for sparse matrix, to keep it sparse
for dense matrix you might prefer not bother of speye.
A + max(-lbdmin,0)*eye(size(A))
This is the theory, in practice you might add some margin to overcome floating point truncation by boosting with some factor.
boost = 2; % close to 1 is better
A + boost*max(-lbdmin,0)*speye(size(A));
NOTE: This is not the nearest matrix (the nearest is to project negative eigen space to 0 and untouch the positive one, see John's answer), but convenient to get SDP matrix. Nearest SPD of sparse matrix is likely a dense matrix, which might not be desirable for large-side sparse matrix.
  1 commentaire
Ron van de Sand
Ron van de Sand le 6 Mai 2020
Modifié(e) : Ron van de Sand le 6 Mai 2020
Hello,
I ran in into a similar problem. Can you suggest any referene (Paper, Book etc.) regarding this topic?

Connectez-vous pour commenter.


John D'Errico
John D'Errico le 6 Mai 2020
Modifié(e) : John D'Errico le 6 Mai 2020
You can always just download my nearestSPD function from the file exchange. (Note that it does come with a reference to how it works.)
From some work by N. Higham: "The nearest symmetric positive semidefinite matrix in the Frobenius norm to an arbitrary real matrix A is shown to be (B + H)/2, where H is the symmetric polar factor of B=(A + A')/2."
nearestSPD uses the above idea, then verifies the result is indeed SPD using chol to verify it has suceeded. If there is still an issue, it applies a further tweak as needed.
  2 commentaires
Ron van de Sand
Ron van de Sand le 6 Mai 2020
Thnak you for your quick response! I just needed some more information about the topic as I'm starting to dive into the topic. Thank you.
John D'Errico
John D'Errico le 7 Mai 2020
Then just read the Higham paper.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Arithmetic Operations dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by