Is there a method that I can call to create a random orthonormal matrix in python? Possibly using numpy? Or is there a way to create a orthonormal matrix using multiple nump
An easy way to create any shape (n x m) orthogonal matrix:
n x m
import numpy as np n, m = 3, 5 H = np.random.rand(n, m) u, s, vh = np.linalg.svd(H, full_matrices=False) mat = u @ vh print(mat @ mat.T) # -> eye(n)
Note that if n > m, it would obtain mat.T @ mat = eye(m).
n > m
mat.T @ mat = eye(m)