Skip to content

Instantly share code, notes, and snippets.

View crhea93's full-sized avatar
💭
Astrophysics!

Carter Lee Rhea crhea93

💭
Astrophysics!
  • Montreal, QC, CANADA
View GitHub Profile
lam, v = np.linalg.eig(cov)
print("Eigenvalues:")
print(lam)
print("Eigenvectors:")
print(v)
# Sort
eigvals, eigvects = (list(t) for t in zip(*sorted(zip(lam, v))))
# And now we can see what this looks like!
x_s = np.linspace(np.min(X_adj), np.max(X_adj), 10)
# 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)
@crhea93
crhea93 / PCA-step0
Last active November 1, 2020 19:40
# Define datasets
X = [1, 1.25, 1.8, 1.9, 2.21, 2.85]
Y = [1.1, 1.14, 1.8, 1.85, 2.25, 2.9]
print(X,Y)
# Let's see what this looks like
with plt.xkcd():
plt.scatter(X, Y)
plt.show()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.