N=evstr(x_dialog('nombre de tirages','10'));
m=evstr(x_dialog('nombre d''experiences?','50000'));
NR=ones(m,1);Ntot=2;xbasc();
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 fraction boules rouges:');disp(mean(XN));
disp('intervalle de confiance:');
disp([mean(XN)-2*st_deviation(XN)/sqrt(m),mean(XN)+2*st_deviation(XN)/sqrt(m)]);
occ=zeros(N+1,1);
for i=1:N+1;
    occ(i)=1/m*sum(bool2s(NR==i*ones(m,1)));
end
chi=sum((occ-ones(N+1,1)/(N+1)).^2./(ones(N+1,1)/(N+1)));
disp('test du chi2 (vrai si v1<v2):');
disp([m*chi,cdfchi("X",N,0.95,0.05)]);
plot2d3((1:N+1)/(N+2),occ,rect=[0,0,1,max(occ)]);
plot2d((1:N+1)/(N+2),1/(N+1)*ones(1,N+1),2);
xtitle('frequence empiriques fraction boules rouges')