statsmodels.stats.moment_helpers.cov2corr#

statsmodels.stats.moment_helpers.cov2corr(cov, return_std=False)[source]#

Convert covariance matrix to correlation matrix

Parameters:
covarray_like, 2d

Covariance matrix, see Notes.

return_stdbool

If this is true then the standard deviation is also returned. By default only the correlation matrix is returned.

Returns:
corrndarray (subclass)

Correlation matrix.

std_ndarray

Standard deviation from the diagonal of cov, returned only if return_std is True.

Notes

This function does not convert subclasses of ndarrays. This requires that division is defined elementwise. np.ma.array and np.matrix are allowed.