<s> import numpy as np <EOL> ra = np . random <EOL> la = np . linalg <EOL> def GOE ( N ) : <EOL> """<STR_LIT>""" <EOL> m = ra . standard_normal ( ( N , N ) ) <EOL> m += m . T <EOL> return m / <NUM_LIT:2> <EOL> def center_eigenvalue_diff ( mat ) : <EOL> """<STR_LIT>""" <EOL> N = len ( mat ) <EOL> evals = np . sort ( la . eigvals ( mat ) ) <EOL> diff = np . abs ( evals [ N / <NUM_LIT:2> ] - evals [ N / <NUM_LIT:2> - <NUM_LIT:1> ] ) <EOL> return diff <EOL> def ensemble_diffs ( num , N ) : <EOL> """<STR_LIT>""" <EOL> diffs = np . empty ( num ) <EOL> for i in xrange ( num ) : <EOL> mat = GOE ( N ) <EOL> diffs [ i ] = center_eigenvalue_diff ( mat ) <EOL> return diffs <EOL> def normalize_diffs ( diffs ) : <EOL> """<STR_LIT>""" <EOL> return diffs / diffs . mean ( ) <EOL> def normalized_ensemble_diffs ( num , N ) : <EOL> """<STR_LIT>""" <EOL> diffs = ensemble_diffs ( num , N ) <EOL> return normalize_diffs ( diffs ) </s>
