Distribution of eigenvalue spacings

I have been doing some experiments on classes of random matrices, and it seems (visually) that the distribution of eigenvalue spacings is consistent with GOE or GUE or GSE. Unfortunately, to test this, I would like to (a) be able to generate GOE/GUE/GSE spacing variates (I suppose I COULD generate very large Gaussian matrices and compute their eigenvalues, but this seems not very fast...), or even have some formula for the distribution function (there is the Wigner surmise, but it is not quite accurate). There are horrible-looking formulas in Mehta's book, but they don't seem usable, somehow. Algorithms/code must exist somewhere -- any pointers would be appreciated.

-
It is known that the GOE spectral distn is the same as that of a tridiagonal random matrix whose off-diagonal entries are square roots of chi-squared and whose diagonal entries are standard normal - would it be any quicker to sample from these and then use some off-the-peg code to compute the eigenvalues from the tridiagonal form? – Yemon Choi Feb 5 2011 at 23:27
@Yemon that could certainly help a lot, but I wonder what you mean by "the same". That is, it might be that the limiting distributions are the same, but one needs to know some explicit bounds on the speed of convergence to make this computationally useful. Is anything like that known? – Igor Rivin Feb 5 2011 at 23:48
In Yemon's comment, "the same" means literally the same for matrices of any size, not just asymptotically. – Mark Meckes Feb 6 2011 at 0:24
As Mark says (you just tridiagonalize the given symmetric matrix, using e.g. a sequence of Householder reflections). I rediscovered this some years ago, but I think it is in a paper of Trotter from the 1970s, and has probably been independently observed in several places. – Yemon Choi Feb 6 2011 at 0:41
For the details written out, see section 4.5 of this book: math.umn.edu/~zeitouni/technion/cupbook.pdf – Mark Meckes Feb 6 2011 at 0:47

I suggest you to take a look at the paper "How to Generate Random Matrices from the Classical Compact Groups" by F. Mezzadri, Notices AMS 54 (5), 592-604 (2007). Can be downloaded freely from here: http://www.google.es/url?sa=t&source=web&cd=1&ved=0CBcQFjAA&url=http%3A%2F%2Fwww.ams.org%2Fnotices%2F200705%2Ffea-mezzadri-web.pdf&rct=j&q=How%20to%20Generate%20Random%20Matrices%20from%20the%20Classical%20Compact%20Groups&ei=W-BNTb6nFZaShAfS2bWTDw&usg=AFQjCNESHv00uIyATuY1NETwTfH5IO1fhQ&cad=rja

-
@Andrei: this is a very cool/useful reference, but unfortunately it does not quite answer the question, since my question is equivalent to randomly generating spectra of symmetric or hermitian matrices, so generating random (eg) unitary matrices does not seem to help... – Igor Rivin Feb 5 2011 at 23:52

If 2% accuracy is sufficient, then you can just use Wigner's surmise. It is unlikely you will be able to beat that accuracy by generating random matrices and sampling the eigenvalue spacing. If higher accuracy is needed, you can find the spacing distribution by numerical integration of a Painleve differential equation, see Forrester & Witte arXiv:math-ph/0009023

A tabulated solution is in Haake's book "Quantum Signatures of Chaos", that is probably the easiest way to go.

-