function x = randp(lamda)
%

x = 0; w = 0; lamdainv = 1/lamda;
while 0<1 % loop until return statement hit
  y = rande(lamdainv);
  w = w+y;
  if w >= 1
    p = x;
    return
  end
  x = x + 1;
end
