What is the best way to accurately describe this statistical probability? I am in the process of writing some information for an App. I need to express the probability of something happening but in a way that is correct but easy to understand. I'm confused on the actual math for this. I'll simplify the numbers here.
Assume a system has 1,000 possible unique codes and I have used 10. I set a computer to search for the codes at a rate of one per hour. How many hours statistically before I find a code ?
On the face of it, I am assuming 100 hours. But I have a feeling that this wouldn't be correct ?
So, the full analysis for random trials is that the initial probability of a hit is $p_0=k/n$ and $k=10,$ and $n=1000$ for your case. Define the number of trials until the first hit as $N_0$ which is a geometric random variable with expectation
$$
\mathbb{E}(N_0)=p_0^{-1}=\frac{n}{k}.
$$
This is indeed 100 as you guessed.
If you wanted  to find 2 codes your success probability would now be $$
p_1=(k-1)/n$$
and the expected time to find a second (distinct) code would be
$$
\mathbb{E}(N_0)=p_1^{-1}=\frac{n}{k-1},
$$
which is a little longer.
The expected time to find $r$ codes is thus
$$
\mathbb{E}(N_0)+ \mathbb{E}(N_1)+\cdots+ \mathbb{E}(N_{r-1})=
n\left(\frac{1}{k}+ \frac{1}{k-1}+\cdots+ \frac{1}{k-r+1}\right)
$$
which is $n(H_k-H_{k-r})$ where $H_k$ is the k_th harmonic number  (the sum of reciprocals of the first $k$ integers) and is approximately $\ln k$ for large $k$. So the overall time complexity is approximately
$$
n \ln \left(\frac{k}{k-r}\right)
$$
for $r&gt;1.$