N=evstr(x_dialog('nombre de tirages?','20'));
m=evstr(x_dialog('nombre d''experiences?','50'));
NR=ones(m,1);Ntot=2;
for i=1:N
  u=rand(m,1);
  ind=find(u<1/Ntot*NR);
  NR(ind)=NR(ind)+1;
  Ntot=Ntot+1;
end
XN=1/Ntot*NR;
disp('esperance empirique du nombre de boules rouges:');disp(1/m*sum(XN));
xset('window',0);xbasc();
plot2d3(1:m,-sort(-XN));
xtitle('proportion de boules rouges','experience','proportion')
xset('window',1);xbasc();
occ=zeros(N+1,1);
for i=1:N+1;
  occ(i)=1/m*sum(bool2s(NR==i*ones(m,1)));
end
plot2d3((1:N+1)/(N+2),cumsum(occ));
plot2d((1:N+1)/(N+2),1/(N+1)*(1:N+1),2);
xtitle('fonction de repartition boules rouges','proportion','F')

