qis.covar_to_corr

qis.covar_to_corr(covar)[source]

convert a covariance matrix to the corresponding correlation matrix.

Computes D^-1 Σ D^-1 with D = diag(sqrt(diag(Σ))), so the diagonal becomes one and the off-diagonal entries become correlations.

Parameters:

covar (ndarray | DataFrame) – covariance matrix, square and with a positive diagonal

Returns:

the correlation matrix, in the same type as the input

Return type:

ndarray | DataFrame