TITLE: Haar measure on $O(n)$ reduced to simpler probability space
QUESTION [5 upvotes]: The background of this question is how a random variable $X$ on the orthogonal group $O(n)$ whose distribution is the normalized Haar measure $\mu$, i.e., $\mu( O(n) ) = 1$, can be realized on a computer that has access to a number of "simpler" random variables, like:

a perfect coin
the uniform probability measure on $[0,1]$ or $S^1$
Gaussian variables on $\mathbb R$ with arbitrary standard deviation.

An algorithm needs to use the random variable $X$, but I am not aware of an explicit formula that would allow for such a reduction.

REPLY [10 votes]: Starting from a real $N\times N$ matrix and essentially performing a $QR$ decomposition, then if the initial real matrix elements are independent identically distributed Gaussian, then the matrices $Q$ will be Haar-distributed on $O(N)$. Please see the full construction in the following article by: Francesco Mezzadri