Distribution of a sequence obtained from a simple stochastic process

24 Views Asked by At

I have the following program:

function x = getx(x = 0, p = .5)
  if rand > p
    x = getx(x)+1;
  else
    x = 0;
  end
end

for i=1:n
  z(i) = getx();
end

What is the distribution of $z$ ?