1
$\begingroup$

Similar to this question, Frequency of Item in Combination.

I am randomly sampling S objects out of N=99 objects into 9 boxes labeled by a single character, "A-I". Question 1: I want to find the probability of M boxes having 2 or more objects, dependent on how many objects I sample, S out of N. Currently I am only able to do so by simulation (see code below), which is RNG dependent, but accurate. Question 2: Is there a distribution I can follow here? I'm bouncing between binomial and hypergeometric, but I am uncertain how to implement it.

mycountL <- double(9)
names(mycountL) <- LETTERS[1:9]

# Change this for sample drawing size
xTimes = 18

set.seed(12)
for(i in 1:10000){
  nL <- names(which(table(sample(rep(LETTERS[1:9],11), xTimes ))>=2))
  lL <- length(nL)
  mycountL[lL] <- mycountL[lL]+1
}

mycountL/10000 #For probabilities. Drawing 18 times is the lowest sample possible to draw exactly 2 in each LETTER, except that it is highly unlikely.

Edits: Clarification

$\endgroup$
3
  • $\begingroup$ This is not simple. At stats.stackexchange.com/a/410506/919 I show how to solve this problem using the smaller example of M=2 with 99 replaced by 5 and 9 replaced by 6. $\endgroup$
    – whuber
    Commented Mar 26, 2020 at 21:38
  • $\begingroup$ I somewhat understand the mathematics but implementing it is another challenge altogether. I'm afraid I can't wrap my head around your "first" step. $\endgroup$
    – Sumner18
    Commented Mar 27, 2020 at 19:33
  • $\begingroup$ If it helps, thing of that step as just being two applications of the tabulate function. $\endgroup$
    – whuber
    Commented Mar 27, 2020 at 20:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.