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.
tabulate
function. $\endgroup$