clear
Number_of_families=10000;
patience=5;

pop_index=0;
for family=1:Number_of_families
    for i=1:patience
        pop_index=pop_index+1;
        Gender(pop_index)=rand(1)<0.5;
        if Gender(pop_index)
            break
        end
    end
    Size(family)=i;
end

n=1:max(Size)*2;
pSize=histc(Size,n)/Number_of_families;
P=(0.5.^(n-1))*0.5;
figure(1)
hold off
bar(n,pSize,'r')
hold on
plot(n,P,'b')
