Code golf a random orthogonal matrix
Haskell, 169 150 148 141 132 131 bytes

import Numeric.LinearAlgebra
z=(unitary.flatten&lt;$&gt;).randn 1
r 1=asRow&lt;$&gt;z 1
r n=do;m&lt;-r$n-1;(&lt;&gt;diagBlock[m,1]).haussholder 2&lt;$&gt;z n


Recursively extend an orthogonal matrix of size n-1 by adding 1 to lower right corner and apply a random Householder reflection. randn gives a matrix with random values from a gaussian distribution and z d gives a uniformly distributed unit vector in d dimensions.

haussholder tau v returns the matrix I - tau*v*vᵀ which isn't orthogonal when v isn't a unit vector.

Usage:

*Main&gt; m &lt;- r 5
*Main&gt; disp 5 m
5x5
-0.24045  -0.17761   0.01603  -0.83299  -0.46531
-0.94274   0.12031   0.00566   0.29741  -0.09098
-0.02069   0.30417  -0.93612  -0.13759   0.10865
 0.02155  -0.83065  -0.35109   0.32365  -0.28556
-0.22919  -0.41411   0.01141  -0.30659   0.82575
*Main&gt; (&lt;1e-14) . maxElement . abs $ tr m &lt;&gt; m - ident 5
True