We have instituted random drug testing at our company. I was charged with writing the code to generate the weekly random list of employees. We've gotten some complaints because of people getting picked more frequently than they expected and our lawyer wants some evidence that these events fall within the bell curve of randomness.
I'm very confident in our code. I have now written several Monte Carlo simulations that back up the results we've had. That said, all my Monte Carlo simulations (each written from scratch, completely independently) also show a phenomenon that I can't explain and I'm hoping others can.
Here are the parameters I'm using: 4550 employees, of which 91 (2%) are picked each week at random.
The phenomenon we're encountering is this:
Over the first 20 weeks, we expect (according to the Monte Carlo simulations) roughly 32 people to be picked 3+ times (and around 2.7 people to be picked 4+ times, but let's just stick with the people picked 3+ times). And we've had the program going for about 20 weeks and the numbers seem to agree so far.
Over the first 40 weeks, the number of people picked 3+ times shoots up to 207 (more than 6 times as many in twice the time).
Over the first 52 weeks, the number shoots up again to 390 (30% more time than 40 weeks, but 90% more people picked 3 times).
Maybe I've written all my Monte Carlo simulations wrong, but I'm pretty sure I haven't. I've looked at all this a bunch of different ways and I'm convinced this phenomenon is real, but I need to be able to explain it to the VP of HR and I'm not sure why the number of people picked 3 times rises so fast from say 40 to 52 weeks (and this is all of the counts. The number of people picked 4+ times, the number of people picked 5+ times, etc).
I do understand that say, in the first 4 weeks, you can't possibly have anyone picked 5 times, so the first week where that would be possible would be week 5. So after 10 weeks, you have 5 times as many opportunities for someone to be picked 5 times as you do in 5 weeks (500% increase in odds over increase 100% in time).
But I'm not sure that explains the 40 week to 52 week changes. Or does it?
I've also ruled out any issues with the random number generator (I get the roughly the same results using the basic one as I do using the random number generator from the cryptography library).
Thanks to anyone who can explain this in a way that I can take back to HR and our legal guys.
To expound a bit on the process, here's an example: I have a database table that I've created called DrugTest. It has 2 columns: TestRun and Employee. Both columns are integers.
So for 52 weeks, I have TestRun values of 1 to 52 and then I have 91 random employee numbers (numbers between 0 and 4549) for each TestRun value. No employee can be picked twice in the same week (the primary key is (TestRun, Employee), ensuring unique employee numbers for each TestRun value).
For a sample run, I loaded up 52 weeks of data. Then I execute the following query:
select employee, count(*) as cnt from DrugTest where TestRun <= 52 group by employee having count(*) = 3 order by 2
The above query returns 313 results
select employee, count(*) as cnt from DrugTest where TestRun <= 40 group by employee having count(*) = 3 order by 2
The above query returns 178 results
select employee, count(*) as cnt from DrugTest where TestRun <= 20 group by employee having count(*) = 3 order by 2
The above query returns 34 results