The Wigner Distribution for a Random Symmetric Matrix

less than 1 minute read

See Anderson, et. al. An introduction to random matrices, Cambridge University Press, page 6.

import numpy as np
from scipy.stats import norm,poisson
from sklearn.decomposition import PCA
import seaborn as sns
import pandas as pd
sns.set_style('darkgrid')
def random_symmetric_normalized(N, rvar=norm(0,1)):
X = rvar.rvs(N*N)
X = X.reshape((N,N))
Xt=np.triu(X)
Xn = (Xt + Xt.transpose()+np.diag(rvar.rvs(N)))/np.sqrt(N)
return Xn
w, v = np.linalg.eig(random_symmetric_normalized(1000))
j=sns.distplot(w,kde=False,bins=50,norm_hist=True)
x=np.linspace(-2,2,1000)
sns.lineplot(x,np.sqrt(4-x**2)/2/np.pi,ax=j)
l=j.set_title('Normally Distributed Entries (N=1000)')

w, v = np.linalg.eig(random_symmetric_normalized(1000,poisson(1)))
j=sns.distplot(w,kde=False,bins=50,norm_hist=True)
x=np.linspace(-2,2,1000)
sns.lineplot(x,np.sqrt(4-x**2)/2/np.pi,ax=j)
l=j.set_title('Poisson(1) Distributed Entries (N=1000)\n One large outlier')

Updated: