Imagine we repeat the following loop some thousands of times:
$$ \begin{align} & \text{array} = []\\ & \text{for n} = 1: 10 000 \\ & k = 0 \\ & \text{while unifrnd}(0,1) < 0.3 \\ & k = k + 1 \\ & \text{end} \\ & \text{if k} \neq 0 \\ & \text{array} = [\text{array,k}] \\ & \text{end} \\ \end{align} $$
whereas "unifrnd(0,1)" means a random number drawn from the uniform distribution on the unit interval.
My question is then: What is then the value of k, which is the most often observed - except for k = 0? And is that the expectation of k?
Thanks very much