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 .
The QR-decomposition is not unique. If
is a QR-decomposition, then also
is a QR-decomposition when is a diagonal orthogonal matrix (diagonal consists of ). To make the QR-decomposition unique, the signs of the diagonal of must be fixed. For example, to make the diagonal of positive, is chosen as
If is generated from i.i.d. standard-normal real random variables, then is distributed with the Haar measure in .
How to Generate Random Matrices from the Classical Compact Groups, Francesco Mezzadri, Notices of the AMS, Volume 54, Number 5, 2007.