Suppose that I have $n$ balls to be divided among $k$ buckets so that each bucket has a non-negative number of balls. This is a classic stars and bars problem: the number of ways to do this division is $\binom{n+k-1}{k-1}$. (In my application, $k>>n$.)
I would like to run a simulation where, for each repetition, I can randomly select one of the $\binom{n+k-1}{k-1}$ possible divisions. But I do not know how to make this random selection.
Could you please help with an algorithm?
I have a feeling that I just need to find the right discrete distribution and simulate realizations of it, but I do not know how to arrive at this discrete distribution.
If you want to simulate choosing a bucket at random for each ball, you can simply generate $n$ random integers in the range $[1,k]$. If you want to generate each possible distribution of balls with equal probability, you could generate $n$ different random integers in the range $[1,n+k-1]$ and use them in conjunction with the stars-and-bars model to generate the associated distribution.