Code covered by the BSD License  

Highlights from
Nearest positive semi-definite covariance matrix

1.0

1.0 | 1 rating Rate this file 38 Downloads (last 30 days) File Size: 5.08 KB File ID: #34182
image thumbnail

Nearest positive semi-definite covariance matrix

by

 

12 Dec 2011 (Updated )

Find nearest positive semi-definite matrix to a symmetric matrix that is not positive semi-definite

| Watch this File

File Information
Description

The function performs a nonlinear, constrained optimization to find a positive semi-definite matrix that is closest (2-norm) to a symmetric matrix that is not positive semi-definite which the user provides to the function. The optimization is subject to the constraint that the output matrix' diagonal elements as well as its eigenvalues are non-negative.

Acknowledgements

This file inspired Nearest Spd.

Required Products Optimization Toolbox
MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
16 Dec 2013 Martin

Regarding Shuo Han's alternative solution. For robustness I had to modify it to the below. My theory is that the division with V sometimes introduces numerical errors that are large enough to result in a new negative eigenvalue.

[V,D] = eig(A);
A_psd = V * diag(max(diag(D),eps)) / V;

20 Sep 2012 Shuo Han

This does not need fmincon() and can be done in two lines. Suppose the input matrix is A

[V,D] = eig(A);
A_psd = V * max(D,0) / V;

Updates
12 Dec 2011

Example input matrix added

Contact us