0

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$ ?

davcha
  • 1,745
  • Do you know what the probability that rand>p is? That should make it easy to compute the distribution of getx. z is just a vector of $n$ independent variables with that distribution (independent assuming Matlab's random number generator is good, anyway). – Ian Aug 07 '17 at 17:00
  • rand is uniform distribution. – davcha Aug 07 '17 at 21:32
  • Yes, so rand>p holds with probability what? – Ian Aug 07 '17 at 21:52

0 Answers0