% Yi-Kai Liu % 5/9/01 % Plot the distribution of eigenvalues, and % the distribution of nearest-neighbor spacings. % FIXME: Look at spacings between eigenvalues in middle of range *only* % (so that density of eigenvalues in the sample is roughly constant). % Another way is to change variables to compensate for the expected % semicircular distribution, thus forcing the density to stay constant. % OK: Figure out scaling, and plot expected curves % OK: Vertical scaling is OK. The area under the curves appears % to be less than 1, but this is because of the histogram scaling. % Requires the following variables: % distribution_name, save_to_disk, base_filename, % N, num_matrices, d, sp dnumbins = 60; % Number of bins to plot eigenvalues spnumbins = 120; % Number of bins to plot spacings % Plot distribution of eigenvalues, and the semicircle [ddist, dbins] = hist(d(:), dnumbins); figure bar(dbins, ddist ./ (num_matrices*N)) title(['Distribution of eigenvalues--', distribution_name, ', ',... 'N=', num2str(N), ', ', num2str(num_matrices), ' matrices']); hold on t = -1.0 : .02 : 1.0; dbinwidth=2.0/dnumbins; plot(t, dbinwidth*(2.0/pi)*sqrt(1-t.^2), 'r'); % Semicircle distribution hold off if save_to_disk == 1 saveas(gcf, [base_filename, '-a.fig']); end; % Plot distribution of spacings, and the Wigner surmise [spdist, spbins] = hist(sp(:), spnumbins); figure bar(spbins, spdist ./ (num_matrices*(N-1))); title(['Distribution of spacings--', distribution_name, ', ',... 'N=', num2str(N), ', ', num2str(num_matrices), ' matrices']) hold on s = 0.0 : .02 : spbins(spnumbins); spbinwidth = spbins(spnumbins)/spnumbins; plot(s, spbinwidth*(pi*s/2.0).*exp(-pi*(s.^2)/4.0), 'r'); % Wigner surmise hold off if save_to_disk == 1 saveas(gcf, [base_filename, '-b.fig']); end; % Plot distribution of spacings, and the Wigner surmise. % Use only spacings from the middle 3/5 of the semicircle % (where the eigenvalue density is roughly constant). % Pick the spacings between the middle 3/5 of the eigenvalues, % then renormalize the spacings to have mean=1. sp_midpart = sp(1+round(0.2*(N-2)):1+round(0.8*(N-2)), :); for m = 1 : num_matrices sp_midpart(:,m) = sp_midpart(:,m) ./ mean(sp_midpart(:,m)); end spnumbins = round(spnumbins*0.6); [spdist, spbins] = hist(sp_midpart(:), spnumbins); figure bar(spbins, spdist ./ (num_matrices*(1+0.6*(N-2)))); title(['Distribution of spacings (from middle 3/5 of semicircle)--',... distribution_name, ', ',... 'N=', num2str(N), ', ', num2str(num_matrices), ' matrices']); hold on s = 0.0 : .02 : spbins(spnumbins); spbinwidth = spbins(spnumbins)/spnumbins; plot(s, spbinwidth*(pi*s/2.0).*exp(-pi*(s.^2)/4.0), 'r'); % Wigner surmise hold off if save_to_disk == 1 saveas(gcf, [base_filename, '-c.fig']); end;