##// END OF EJS Templates
Ported the IPython Sphinx directive to 0.11....
Ported the IPython Sphinx directive to 0.11. This was originally written by John Hunter for the 0.10 API, now it works with 0.11. We still need to automate its test suite, but at least now it runs and the script itself can be executed as a test that produces screen output and figures in a subdir.

File last commit:

r1337:53a3e331
r2439:858c6e09
Show More
rmtkernel.py
44 lines | 1.2 KiB | text/x-python | PythonLexer
#-------------------------------------------------------------------------------
# Core routines for computing properties of symmetric random matrices.
#-------------------------------------------------------------------------------
import numpy
ra = numpy.random
la = numpy.linalg
def GOE(N):
"""Creates an NxN element of the Gaussian Orthogonal Ensemble"""
m = ra.standard_normal((N,N))
m += m.T
return m
def centerEigenvalueDiff(mat):
"""Compute the eigvals of mat and then find the center eigval difference."""
N = len(mat)
evals = numpy.sort(la.eigvals(mat))
diff = evals[N/2] - evals[N/2-1]
return diff.real
def ensembleDiffs(num, N):
"""Return an array of num eigenvalue differences for the NxN GOE
ensemble."""
diffs = numpy.empty(num)
for i in xrange(num):
mat = GOE(N)
diffs[i] = centerEigenvalueDiff(mat)
return diffs
def normalizeDiffs(diffs):
"""Normalize an array of eigenvalue diffs."""
return diffs/diffs.mean()
def normalizedEnsembleDiffs(num, N):
"""Return an array of num *normalized eigenvalue differences for the NxN
GOE ensemble."""
diffs = ensembleDiffs(num, N)
return normalizeDiffs(diffs)