##// END OF EJS Templates
Moving parallel->Parallel
Moving parallel->Parallel

File last commit:

r16057:a34981d9
r16057:a34981d9
Show More
rmtkernel.py
42 lines | 1.2 KiB | text/x-python | PythonLexer
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337 #-------------------------------------------------------------------------------
# Core routines for computing properties of symmetric random matrices.
#-------------------------------------------------------------------------------
Brian E. Granger
Updating RMT parallel example.
r4591 import numpy as np
ra = np.random
la = np.linalg
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337
def GOE(N):
"""Creates an NxN element of the Gaussian Orthogonal Ensemble"""
m = ra.standard_normal((N,N))
m += m.T
Brian E. Granger
Updating RMT parallel example.
r4591 return m/2
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337
Brian E. Granger
Updating RMT parallel example.
r4591 def center_eigenvalue_diff(mat):
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337 """Compute the eigvals of mat and then find the center eigval difference."""
N = len(mat)
Brian E. Granger
Updating RMT parallel example.
r4591 evals = np.sort(la.eigvals(mat))
diff = np.abs(evals[N/2] - evals[N/2-1])
return diff
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337
Brian E. Granger
Updating RMT parallel example.
r4591 def ensemble_diffs(num, N):
"""Return num eigenvalue diffs for the NxN GOE ensemble."""
diffs = np.empty(num)
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337 for i in xrange(num):
mat = GOE(N)
Brian E. Granger
Updating RMT parallel example.
r4591 diffs[i] = center_eigenvalue_diff(mat)
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337 return diffs
Brian E. Granger
Updating RMT parallel example.
r4591 def normalize_diffs(diffs):
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337 """Normalize an array of eigenvalue diffs."""
return diffs/diffs.mean()
Brian E. Granger
Updating RMT parallel example.
r4591 def normalized_ensemble_diffs(num, N):
"""Return num *normalized* eigenvalue diffs for the NxN GOE ensemble."""
diffs = ensemble_diffs(num, N)
return normalize_diffs(diffs)
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337