##// END OF EJS Templates
Merge pull request #4305 from minrk/even-more-ways-to-get-ifaces...
Merge pull request #4305 from minrk/even-more-ways-to-get-ifaces Add even more ways to populate localinterfaces use netifaces for faster IPython.utils.localinterfaces when availlable, Parse subprocess output from ifconfig / ip addr / ipconfig. Lower priority than netifaces, but still higher priority than socket.gethostbyname. Fallback to gethostname otherwise. Should be much faster in worst case scenario where machine are badly configurred and can wait up to ~30s to start ipython. Slighly slower in other cases.

File last commit:

r9190:20a102a5
r12911:aeeb7f5a merge
Show More
rmtkernel.py
42 lines | 1.2 KiB | text/x-python | PythonLexer
#-------------------------------------------------------------------------------
# Core routines for computing properties of symmetric random matrices.
#-------------------------------------------------------------------------------
import numpy as np
ra = np.random
la = np.linalg
def GOE(N):
"""Creates an NxN element of the Gaussian Orthogonal Ensemble"""
m = ra.standard_normal((N,N))
m += m.T
return m/2
def center_eigenvalue_diff(mat):
"""Compute the eigvals of mat and then find the center eigval difference."""
N = len(mat)
evals = np.sort(la.eigvals(mat))
diff = np.abs(evals[N/2] - evals[N/2-1])
return diff
def ensemble_diffs(num, N):
"""Return num eigenvalue diffs for the NxN GOE ensemble."""
diffs = np.empty(num)
for i in xrange(num):
mat = GOE(N)
diffs[i] = center_eigenvalue_diff(mat)
return diffs
def normalize_diffs(diffs):
"""Normalize an array of eigenvalue diffs."""
return diffs/diffs.mean()
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)