
nmax=70;
subplot(3,1,3)
set(gca,'nextplot','replacechildren');
hold
xlabel('n', 'fontsize', 16)
ylabel('Var(X)', 'fontsize', 16)


subplot(3,1,1:2)
title('Sannsynsfordeling for antall ulykker','fontsize', 16 )
ylabel('f(x)','fontsize', 16)
xlabel('x', 'fontsize', 16)

set(gca,'nextplot','replacechildren');
for n = 7:nmax
subplot(3,1,1:2)
bar(0:1:20,[binopdf(0:1:20,n,7/n);poisspdf(0:1:20,7)]' )
axis([-0.5 20 0 1]);
legend('Binomisk', 'Poisson')
subplot(3,1,3)
[m,var]=binostat(1:1:n,7./(1:1:n));
plot(1:1:n,var,'-*r');
plot([1, n],[7,7],'-b');
axis([0 nmax 0 12])
legend('Binomisk', 'Poisson')
F2(n-6)=getframe(gcf);
end

h2=figure
movie(h2,F2,1,2)



movie2avi(F2,'binopoissfilm.avi','fps',2)