Random Orthogonal Matrices

An easy way to draw from the Haar measure is to take the QR of a matrix of iid random normals, with R constrained to have a positive diagonal:

Q,R = qr(randn(m,n))
O = Q*Diagonal(sign.(diag(R)))

There are even faster ways to do this: see Orthogonal matrix - Wikipedia

10 Likes