0
$\begingroup$

I'm writing a software, where I need an event to occur on average 10 times per 24 hours.

I want to implement that by checking a random number against preset probability every second.

I've tried $10^{1/(3600\cdot 24)}-1$ as that probability, but that is incorrect. I also can calculate that probability using simulation, but that seems lame (as there may be delays in execution, and I want to be able to seamlessly adjust the interval and always get the correct result).

Can anybody help me with the formula and the rationale behind it?

1 Answers 1

2

There are $24\cdot3600=86400$ checks in $24$ hours; if you want the expected number of occurrences to be $10$ the probability needs to be $10/86400=1/8640$. By linearity of expectation the expected number of occurrences is $86400$ times the expected number of occurrences in one check, which is just $1\cdot p+0\cdot(1-p)=p$, the probability itself.

  • 0
    ) oh my. and there I was trying to find a complicated way to solve this! thanks a lot!2012-12-06