Skip to content

Instantly share code, notes, and snippets.

@wiso
Created March 20, 2018 08:33
Show Gist options
  • Save wiso/ce2a9919ded228838703c1c7c7dad13b to your computer and use it in GitHub Desktop.
Save wiso/ce2a9919ded228838703c1c7c7dad13b to your computer and use it in GitHub Desktop.
Compute correlation matrix from covariance matrix using numpy
import numpy as np
def correlation_from_covariance(covariance):
v = np.sqrt(np.diag(covariance))
outer_v = np.outer(v, v)
correlation = covariance / outer_v
correlation[covariance == 0] = 0
return correlation
@ostwalprasad
Copy link

Thanks man🙌

@jaronowitz
Copy link

Thank you!

@KaiKevinLiao
Copy link

Thanks!

@SINGAM5153
Copy link

Thanks

@JulianDPastrana
Copy link

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment