clear;
clf();
stacksize(150000000); // augmente la taille de la memoire
dim=1000;
Ncolhisto=60;

rand("normal");


////cas hermitien
//A=rand(dim,dim);
//
//M=(A+A'+%i*(A-A'))/(2*sqrt(dim));

//cas symetrique

A=rand(dim,dim);

M1=(A+A')/sqrt(2);

M=M1/sqrt(dim);

Col_histo=linspace(-2.5,2.5,Ncolhisto);
v=-2:0.01:2;
abs_densite=[-2.5,v,2.5];

ord_densite=[0,sqrt(4-v^2),0]/(2*%pi);

s=sort(real(spec(M)));

subplot(4,1,1);

histplot(Col_histo,s);

plot2d(abs_densite,ord_densite,style=5,frameflag=5);

xtitle("Histogramme des valeurs propres");

subplot(4,1,2);

x=s(1:$-1)-s(2:$);

histplot(linspace(0,16/dim,round(dim/20)),x);

xtitle("Histogramme des ecarts entre les valeurs propres successives");

subplot(4,1,3);

rand("uniform");

s=sort(4*rand(1,dim));

x=s(1:$-1)-s(2:$);

histplot(linspace(0,16/dim,round(dim/20)),x);

xtitle("Histogramme des ecarts entre les valeurs successives d''un echantillon de v.a. uniformes");

subplot(4,1,4)

Netapes=floor(dim/50);

vpmax=[];
for i=1:Netapes
	M2=M1(1:i*50,1:i*50)/sqrt(i*50);
	vp=max(real(spec(M2)));
	vpmax=[vpmax,vp];
end

plot2d(1:Netapes,vpmax,style=5);
xtitle("Valeurs propres maximales");
xselect();