Balls in Bins simulation for R

Viewed 736

I would like to simulate the distribution for a fixed number of balls m in a fixed number of bins n in R. Up till now I have been using the Poisson approximation with rpois(). This is a decent approximation for a large number of balls in n bins.

However, rpois() only allows you to indicate a rate lambda, which is m/n. As a consequence, the number of positive bins is often smaller than the number of balls.

Would anybody know of a function or script that allows me to randomly distribute balls into bins?

Ultimately I seek to calculate the confidence intervals of -log(empty bins/total bins) by bootstrapping. This problem is 'breaking my balls' so to speak.

1 Answers
Related