A data challenge a day helps you master machine learning
Hiiii, a little bit different, here is my solution:
# DDC-54: Eigenvalues and squared singular values
import numpy as np
rng = np.random.default_rng(seed=42)
M = rng.integers(low=0, high=101, size=(4, 10))
S = M@M.T
U,Sing, Vh = np.linalg.svd(S)
Sing_s = np.sort (Sing)
eigen_S, V = np.linalg.eig (S)
eigen_S_sorted = np.sort(eigen_S)
are_equal_approximately = np.allclose(Sing_s, eigen_S_sorted)
print("Sing_s :", Sing_s)
print("eigen_S_sorted:", eigen_S_sorted)
print(f"\nAre they approximately equal? {are_equal_approximately}")
Great :D
Hiiii, a little bit different, here is my solution:
# DDC-54: Eigenvalues and squared singular values
import numpy as np
rng = np.random.default_rng(seed=42)
M = rng.integers(low=0, high=101, size=(4, 10))
S = M@M.T
U,Sing, Vh = np.linalg.svd(S)
Sing_s = np.sort (Sing)
eigen_S, V = np.linalg.eig (S)
eigen_S_sorted = np.sort(eigen_S)
are_equal_approximately = np.allclose(Sing_s, eigen_S_sorted)
print("Sing_s :", Sing_s)
print("eigen_S_sorted:", eigen_S_sorted)
print(f"\nAre they approximately equal? {are_equal_approximately}")
Great :D