# Thread: Need Help Calculating A Percentage For a Script

1. ## Need Help Calculating A Percentage For a Script

Hi all, new here so take it easy on me.

I'm designing a script designed to trigger a random drill within a 30 day time frame. I don't yet know how many times the check will occur, so for now we'll say that it will run X times within the 30 day period and it should only activate the drill once within the 30 day timeframe. If it doesn't occur within the 30 day timeframe then it will trigger at the end of the 30 days.

Each time the script runs it will evaluate some conditions, then decide whether or not to activate by generating a random number between 0 and 32767. A percentage of these numbers is allocated to "yes, activate" and the larger percentage is allocated to "No, don't activate." I need to figure out the percentage that will provide an even 'chance-to-trigger' out of the X times it is run within the 30 day period.

The only thing I'm coming up with is 1/X, but that seems far too simple.

2. ## Re: Need Help Calculating A Percentage For a Script

If by "run" you mean generate the random number and have a chance to "activate the drill", then I would say yes 1/X is the correct solution regardless of its appeared simplicity.

If it "runs" 15 times in a 30 day period you need one of these 15 to activate the drill. (1/15) However it seems like the probability it will be activating the drill at the end of the thirty days will be higher and thus doing away with the "randomness" on most occasions.

3. ## Re: Need Help Calculating A Percentage For a Script

Could it randomly run the check and activate the drill on the second of one month and 23rd of the next month? Since it's designed to "trigger a random drill within a 30 day time frame", and that would put either 51 or 52 days between the two checks?