subplot(4,1,4)
set(gca,'nextplot','replacechildren');
hold
subplot(4,1,3)
set(gca,'nextplot','replacechildren');
hold
xlabel('k', 'fontsize', 16)
ylabel('Var(X)', 'fontsize', 16)

subplot(4,1,4)
xlabel('k', 'fontsize', 16)
ylabel('P(X=0)', 'fontsize', 16)

subplot(4,1,1:2)
title('Sannsynsfordeling for antall raude kuler','fontsize', 16 )
ylabel('f(x)','fontsize', 16)
xlabel('x', 'fontsize', 16)

set(gca,'nextplot','replacechildren');
for k = 1:50
subplot(4,1,1:2)
bar(0:1:10,[binopdf(0:1:10,10,0.1);hygepdf(0:1:10,k*10,k,10)]' )
axis([-0.5 11 0 1]);
legend('Binomisk', 'Hypergeometrisk')
subplot(4,1,3)
[m,var]=hygestat(10:10:10*k,1:1:k,10);
plot(1:1:k,var,'-*r');
plot([1, k],[0.9,0.9],'-b');
axis([0 50 0 1.2])
subplot(4,1,4)
axis([0 50 0 1.1])
plot([1,k],[binopdf(0,10,0.1),binopdf(0,10,0.1)],'-b')
plot(1:1:k,hygepdf(0,10:10:k*10,1:1:k,10),'*-r')
axis([0 50 0 1.1])
legend('Binomisk', 'Hypergeometrisk')
F(k)=getframe(gcf);
end

h2=figure
movie(h2,F,1,2)
movie2avi(F,'hygebinofilm.avi','fps',2)