Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Compute covariance matrix
- C = np.dot(X.T, X) / (n-1)
- # Eigen decomposition
- eigen_vals, eigen_vecs = np.linalg.eig(C)
- # SVD
- U, Sigma, Vh = np.linalg.svd(X,
- full_matrices=False,
- compute_uv=True)
- # Relationship between singular values and eigen values:
- print(np.allclose(np.square(Sigma) / (n - 1), eigen_vals)) # True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement