This section considers the generation of uniform random matrices such that and . In other words, we would like to generate a random matrix such that the distribution of is given by the Haar measure :
for all measurable .
Let be a uniform random orthogonal matrix. Since is uniformly distributed in , it will have with probability 0.5. Thus, one way to generate rotation matrices with uniform distribution is to reject random orthogonal matrices until .
Let be uniform random orthogonal matrix. If , one can get a with by negating the first column of . This seems to produce the same result as rejection sampling (when plotting the density of eigenvalues). However, I am lacking a proof for this. This is the current implementation.