Find the nearest covariance matrix that is positive (semi-) definite
This leaves the diagonal, i.e. the variance, unchanged
initial covariance matrix
if “clipped”, then the faster but less accurate
corr_clippedis used.if “nearest”, then
clipping threshold for smallest eigen value, see Notes
factor to determine the maximum number of iterations in
corr_nearest. See its doc string
if False (default), then only the covariance matrix is returned. If True, then correlation matrix and standard deviation are additionally returned.
This converts the covariance matrix to a correlation matrix. Then, finds the nearest correlation matrix that is positive semidefinite and converts it back to a covariance matrix using the initial standard deviation.
The smallest eigenvalue of the intermediate correlation matrix is approximately equal to the
threshold. If the threshold=0, then the smallest eigenvalue of the correlation matrix might be negative, but zero within a numerical error, for example in the range of -1e-16.
Assumes input covariance matrix is symmetric.