I'll start with a specific example of what I am trying to solve:
I have eight balls to be randomly placed into four buckets. Buckets #1-3 have the capacity of 2, 2, 3 respectively, while bucket #4 has an infinite capacity. A bucket can't be filled over its capacity. A ball will not be thrown to a bucket that is already full. I would like to calculate the probability that my eight balls will completely fill buckets #1-3.
The last time I studied maths formally was in university, a good 7-10 years ago. My limited memory/understanding of combinatorics is failing me. I'm a software guy, so I wrote a basic simulator for the problem, which seems to tell me that my eight balls will fill buckets #1-3 ~18% of the time. I'd like to understand how to approach the problem mathematically.
The capacities of each cell make this a tricky problem. The probability of reaching a given configuration depends on the sequence of cells selected. For example, throwing balls into cells 1,1,2, in that order, has probability $(1/4)^2(1/3)$ while 1,2,1 has probability $(1/4)^3.$ So determining equally likely outcomes is difficult. Instead we can solve using a Markov chain. Let the states of the chain be the vector of number of balls in the 4 cells after any number of balls have been thrown. We start in state $(0,0,0,0)$ and throw 8 balls, one by one, taking into account the capacities. After the first ball, we are in state $(1,0,0,0), (0,1,0,0), (0,0,1,0)$ or $(0,0,0,1)$. And they each have probability $1/4$ of occurring. Similarly, we must fill in a one-step transition matrix $P$ that gives the probability of moving from any state $(i,j,k,m)$ to any other after one more ball is thrown. With 8 balls thrown the capacities are: $2,2,3,8$ and so the number of states we need to consider is $3x3x4x9=324.$
We then compute the elements of the matrix $P$ of size 324x324 (mostly $0$). This was easy in Excel. Then we compute the power $P^8.$ The non-zero probabilities in row $(0,0,0,0)$ of $P^8$ tell us the probability of being at each given state after $8$ balls are thrown.
The results show that state $(2,2,3,1)$ has probability $0.1855$ and it is the most likely to occur. There are 36 states that can occur after 8 balls are thrown.