1

I asked this question earlier today, but now need to extend it and can't seem to generalize it out to a third event:

My original question was: You have a list of 10,000 people. Every week, you randomly select 2% (200) of those people. What are the odds of one or more of those 2% getting picked the following week?

Now, I need to know, what are the odds of anyone picked in that first week getting picked the two following weeks?

Pete
  • 177

3 Answers3

1

A straightforward Monte Carlo method can be used to find a decent approximation. In Python2, we can do the following.

import random
def run_trials(num_people_total, num_people_selected, num_rounds, num_trials):
    matched = 0
    people = set(range(num_people_total))
    for _ in xrange(num_trials):
        resultant = set(random.sample(people, num_people_selected))
        for _ in xrange(num_rounds-1):
            resultant.intersection_update(random.sample(people, num_people_selected))
        if resultant:
            matched += 1
    return matched

running this simulation with 10000 people, 200 selected, 3 rounds, and 50000, I got 3909 hits, or about 7.8%.

Alternatively, since you said 5600 employees with 112 in your comment to Batman, I ran the code with 5600 people, 112 selected, and 100000 trials, obtaining 4315 hits, yielding 4.3%

0

Hint: Look at the complement event. For picking none of those initial two hundred the following week, you have (10000-200) people to choose from.

Batman
  • 19,390
  • You probably suspect I'm asking a homework problem. I'm not. Here's the problem. I'm a computer programmer who was tasked with writing the code to choose people randomly in our company for drug testing. We pick 2% of the employees each week. Our HR department is very concerned that this process be random and people can't be pulled from the list after being picked one week. Someone got picked 3 weeks in a row (initially I thought they had only been picked twice in a row). I need to explain to HR that this is not a 1 in a million thing and I need the math to back it up. – Pete Jan 12 '15 at 16:12
  • Did you initialize your random number generator properly? Look at the Binomial(# of weeks, .02) distribution (which is the number of times a person is going to be picked if you assume each person is picked indep. with 2% probability each week, so on average 200 people are picked a week) - with 3 weeks, the probability of 0,1,2,3 picks is 9.4119e-01 5.7624e-02 1.1760e-03 8.0000e-06 respectively (binopdf([0 1 2 3],3,0.02) in octave). – Batman Jan 12 '15 at 16:26
  • Yes. Really, I've validated the randomness of the picks in a number of ways. We just happened to have someone picked this week who was picked the 2 previous weeks. The numbers aren't actually 10,000 and 200. The real numbers are 5600 employees and 112 picked. The probability that anyone picked in one week will get picked the following week I can see is roughly 90%. I just don't get how to expand that out to 3 weeks in a row. – Pete Jan 12 '15 at 16:39
0

Sir, I have been looking this over and I looked at the answer to your previous question. You asked the probability of a person being selected in week 2 given that he was selected in week 1. Now you are wanting to know the probability of this person getting selected again in week three. This is mathematically equivalent to asking the probability of selection in week 3 given that he was selected in week two.

Then why not treat this in the same manner as the probability of rolling heads n times in a row on a fair coin. (so .5^n in that case). Here using the same method of solution from your earlier question and your new numbers of 5600 and 112, the probability of one of the people selected in week 1 being selected in week two is approximately 89.8%.

Here is some supporting math:

P(person from 1 being selected in week 2)=1- P(none from week 1 selected in week 2)

P(person from 1 being selected in week 2)= 1 - $\frac{5488 \choose 112}{5600 \choose 112}$=.898

Then the probability of one of those people being selected in week 3 is .898^2. This is .8064 or 80.64%. I hope I did not make a gross conceptual error here.

So there is a high probability that this can happen. If I made a mistake, please let me know. My other thought is to use Bayes' theorem.

sccard1
  • 26