Hi Guys,
I need some help regarding algorithm for randomness. So Problem is.
There are 50 events going to happen in 8 hours duration. Events can happen at random times. Now it means in each second there is a chance of event happening is 50/(8*60*60)= .001736. How can I do this with random generation algorithm?
I can get random number
int r = rand();
double chance = r/RAND_MAX;
if(chance < 0.001736)
then event happens
else
no event
But most of times rand() returns 0 and 0<0.001736 and I am getting more events than required.
Any suggestions?