%EMPTY BOXES

%%% parameters

m=10000; %no. of balls 
n=20000; %no. of boxes

s=zeros(1,n);
z=zeros(1,m);

clf reset;
%grid on;
%ylim([0.3,0.7]);
%hold on;
%h = axes('Position',[0 0 1 1],'Visible','off');

for (i=1:m)
   ind=randi([1,n]); 
   s(ind)=s(ind)+1; 
   z(i)=sum(s==0); 
end 
   
    
 
t=[1:m];
 
plot(t, z/n, 'Color', [0,0,1], 'LineWidth',2);

hold on;

plot(t, exp(-m/n)+zeros(1,m), 'Color', [0,0,0]);
% plot(t, p1+zeros(1,n), 'Color', [0.5,0.5,0.5]);
% plot(t, p2+zeros(1,n), 'Color', [0.5,0.5,0.5]);
 
str=strcat('n', sprintf('=%d', n), ' m', sprintf('=%d', m));
legend(str,'FontSize',10, 'Location','northeast');

xlabel('no. of balls','FontSize',10);
ylabel('no. of empty boxes','FontSize',10);

title('Empty boxes','FontSize',10);
hold off;