%% Plot the eigenvalue density
RUNS = 1000;
N = 100;
sp = zeros(N, RUNS);

for j = 1:RUNS
    spec = eig(GSE(N));
    sp(:,j) = spec(2:2:end);
end;

figure;
sp1 = sp(1:end);
%histogram(sp(1:end), 25, 'Normalization', 'pdf');
[n,xout] = hist(sp1, 25);
bar(xout, n / length(sp1) / (xout(2)-xout(1)));
hold on;
x = linspace(-2,2);
plot(x, sqrt(4-x.^2)/2/pi, 'k-');

%% Plot the eigenvalue density for Circular Ensembles

RUNS = 1000;
N = 50;
sp = zeros(N, RUNS);

for j = 1:RUNS
    spec = eig(CUE(N));
    sp(:,j) = angle(spec);
end;

figure;
sp1 = sp(1:end);
%histogram(sp(1:end), 25, 'Normalization', 'pdf');
[n,xout] = hist(sp1, 50);
bar(xout, n / length(sp1) / (xout(2)-xout(1)));
hold on;
x = linspace(-pi,pi);
plot(x, ones(size(x))/(2*pi), 'k-');
