dear julia experts—has anyone already written a random orthogonal matrix generator for square matrices?
Is the right way to do this generating a random normal matrix first and then running a Gram-Schmidt orthogonalization? (is this somewhere in Julia already, so that I won’t rewrite the wheel)?
the RandomMatrices installs in 0.6.2, but the brews for macOS abort somewhere, and there are deprecation warnings in the RandomMatrices code (e.g., use exp.() instead of exp() ). so the install and the code could use some tender care.
I am looking at the documentation. I am way over my head on the underlying math.
What I really want is K random directions with maximum distances in N dimensions (N<=K). So, if I have 2 directions and I want 4 directions, it would be a rotate of (1,0),(0,1),(1,1),(-1,1). If by any chance this is already in this package, please let me know. Otherwise, please ignore.
I am definitely ok with what I know and what I have. I can draw two matrices, and hope that they will not happen to be highly correlated. It’s a little less efficient, but it will do.
Note that this answer, which is currently marked as the accepted solution, does not produce uniform (Haar) distributed answers. For instance, it will always produce Q matrices with elements of the same sign in the first column. Simonbyrne’s answer is the correct one.
Another remark is that (Julia’s Householder-based) QR is more stable than Gram-Schmidt which OP was considering.