function v=popx(p,N)
% MCMC simulation of dying population, 
% P0 = N and probability p of survival.
pt = ones(1,N);
u = sum(pt);
v = u;
while u > 0
    pt = (rand(1,N)<=p*pt);
    u = sum(pt);
    v = [v,u];
end