It really depends on which distribution you want to use, everything you specified was average. I would, as you said, expect the Poisson distribution to suit your needs perfectly, but you also put a “uniform random variable” in the name, which is a different distribution, anyway, just go with the first one.
So, if the Poisson distribution is what you want, you can easily generate samples using the cumulative density function. Just follow the pseudo code here: Generating Poisson RVs , with 5 seconds being your value for lambda. Let me call this function Poisson_RN ().
The algorithm at this point is quite simple.
global float next_time = current_time()
boolean function foo()
if (next_time < current_time())
next_time = current_time() + Poisson_RN();
return true;
return false;
source
share