Skip to content

Instantly share code, notes, and snippets.

@1f0
Created April 16, 2019 03:12
Show Gist options
  • Save 1f0/ac3559f36f336d4b3dfd51bd1aefb18d to your computer and use it in GitHub Desktop.
Save 1f0/ac3559f36f336d4b3dfd51bd1aefb18d to your computer and use it in GitHub Desktop.
%% copy from ocw.mit.edu
%% random matrix theory
%n=20; s=30000; d=.05; %matrix size, samples, sample dist
n=10; s=1000; d=.05; % s=30000 is too slow
e=[]; %gather up eigenvalues
im=1; %imaginary(1) or real(0)
for i=1:s,
a=randn(n)+im*sqrt(-1)*randn(n);a=(a+a')/(2*sqrt(2*n*(im+1)));
v=eig(a)'; e=[e v];
end
hold off; [m x]=hist(e,-1.5:d:1.5); bar(x,m*pi/(2*d*n*s));
axis('square'); axis([-1.5 1.5 -1 2]); hold on;
t=-1:.01:1; plot(t,sqrt(1-t.^2),'r');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment