Skip to content

Instantly share code, notes, and snippets.

@crhea93
Created November 1, 2020 19:32
Show Gist options
  • Save crhea93/546508a384e01e1e5b8a75434dfb6900 to your computer and use it in GitHub Desktop.
Save crhea93/546508a384e01e1e5b8a75434dfb6900 to your computer and use it in GitHub Desktop.
# Calculate means and normalize
x_mean = np.mean(X)
X_adj = [x-x_mean for x in X]
y_mean = np.mean(Y)
Y_adj = [y - y_mean for y in Y]
# Caculate Covariance Matrix
cov = np.cov(X_adj, Y_adj)
print(cov)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment