Created
March 20, 2020 09:55
-
-
Save ostwalprasad/f4f3de7d9bdae087b3b5cefb74110e23 to your computer and use it in GitHub Desktop.
Covariance matrix only using NumPy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
df = YOUR_DATAFRAME | |
ones = np.ones([df_shape[0],df_shape[0]]) | |
dev_mat = df - (ones @ df)/df_shape[0] | |
cov_mat = (dev_mat.T @ dev_mat) / df_shape[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment