2

Given $n$ (unlabeled) balls, and $m$ (labeled) containers of equal size, I want to calculate what is the most probable distribution of balls, from the point of view of have many containers will remain empty. Balls are assigned randomly , with equal probabilites for each container. So, I believe the number of configurations in which $k$ containers out of the available $m$ contain at least one ball equals $$ C(k) = { {n -1} \choose {k -1} }{ {m} \choose {k} } $$ where the first term gives the number of combinations to put $n$ balls in $k$ containers with each container containing at least one ball (Put $N$ identical balls into $m$ different buckets, each bucket has at least one ball, how many ways?), and the second reflects the freedom in choosing the $k$ containers to place balls in. It is a matter now to maximise the function $C(k)$. I checked that when Stirling's approximation applies, for large arguments of the factorial, the maximum tends to $n$, so filling all the boxes. In other words, with many particles, it is unlikely any box will remain empty.

But plotting $C(k)$ for smaller $n$ and $m$, one notices the maximum occurs for $k<m$, so some containers are indeed empty. Now, the question.

I am interested in estimating when the transition occurs, i.e. for which values of $m, n$ the maximum of $C(k)$ occurs for $k < m$. I am stuck a bit as I cannot manipulate the binomial coefficients and the factorials for small values of their argument.

My attempt followed this route. Let us assume that with given $n$ and $m$, one computes the most likely outcome is such that $k$ containers only are filled. But then, one could divide the containers in two sets, filled and empty by the process described above, each considered as a container in itself. One can view the process as a Bernoulli process, in which balls are assigned to a larger Container, union of the selected $k$ "filled" containers) with probability proportional to $k$ (and this is a Bernoulli "success"), and the union of the $m-k$ empty containers, with probability proportional to $m-k$. The analogue of getting $k$ empty containers in the above described process is, for the Bernoulli process, to get all successes over the $n$ attempts. For the event "all successes" to be the expected value, the following conditions has to hold

$$ n p \geq n -1/2 $$

where $p$, the chance of success on the single draw, equals

$$ p = \frac {m-k}{m}$$

I end up then with the condition

$$ n (\frac {m-k}{m} ) \geq n -1/2 $$

At least, I believe this confirms that when $n \to \infty$, $k \to 0$.

Any hint on how to substantiate the condition found with a direct calculation on $C(k)$ would be greatly appreciated, thanks.

An aedonist
  • 2,568
  • What I understand you to be saying is this. We go through each of $n$ balls one after the other. For each ball, we pick one of the $m$ containers at random, each with equal probability, and place the ball in the selected container. Then your first claim is that the probability that exactly $k$ of the containers contain at least one ball is the expression $C(k)$ you wrote in your first paragraph. Is that correct? – user49640 Jun 11 '17 at 02:09
  • The process you describe is as I intended. But $C(k)$ represent the number of possibilities to distribute balls in such a way that only $k$ containers contain at least a ball (hence, $m-k$ are empty). $C(k)$ is then proportional to the probabilities of the event $m-k$ containers are empty. – An aedonist Jun 11 '17 at 02:26
  • I'm not entirely convinced that this is correct. For example, when $m = n = 3$, what probabilities does your formula give for $k = 1, 2, 3$? – user49640 Jun 11 '17 at 02:28
  • What if I find the value of $n$ that maximizes the probability that $k$ (out of the $m$ labelled) containers are not empty ("filled" with at least one ball)? – hardmath Jun 11 '17 at 02:38
  • @user49649, so, after correcting the main post for $m=n=3$, $C(1) = 3$, $C(2) =6 $, $C(3) = 1$, seems reasonable, no? – An aedonist Jun 11 '17 at 02:47
  • @hardmath, I believe the approach you suggest could also give the answer I am looking for. – An aedonist Jun 11 '17 at 02:48
  • For $m=n=3$, the probabilities should be $1/9$, $6/9$, $2/9$, for $k = 1, 2, 3$, respectively. I think you're probably making the mistake of treating certain outcomes as being equally likely when they're not. – user49640 Jun 11 '17 at 02:52
  • @user49460, thanks I see your point. For example with $k=2$, there are indeed three ways to choose the empty container: but then, with regards to the other two containers, I should select only the number of combinations such that each container contains at least a ball. I will edit shortly. – An aedonist Jun 11 '17 at 03:14
  • I think your count is incorrect: the number of positive integer solutions to $x_1+\dots+x_n=m$ is ${m-1 \choose n-1}$. – Ian Jun 11 '17 at 03:31
  • I fail to see why the count is incorrect, also in reference to @user49640. Let us take the case $m = n = 3$. So, for $k=1$, only one container filled, I have three possibilities, (3, 0 , 0), (0, 3, 0), (0, 0 ,3), each place in the parenthesis standing for a specific container. – An aedonist Jun 11 '17 at 03:34
  • For $k=3$, only one, (1,1,1). for $k=2$, there are 6, (0, 1, 2), (0, 2,1), (1,0,2), (2, 0, 1), (1,2, 0) (2,1, 0). – An aedonist Jun 11 '17 at 03:36
  • You fixed it now. – Ian Jun 11 '17 at 03:41
  • @Ian Indeed, just edited the main post, sorry for the mistakes, the formula did not match what I used for the calcs answering user49640 above – An aedonist Jun 11 '17 at 03:44
  • Let $n = m = 3$. Let's calculate the probability that $k = 1$. If I've placed the first ball in position $a$, the probability that the second ball is placed in that position is $1/3$. After that, the probability that the third ball is placed in that position is also $1/3$. So we get a probability of $1/3 \times 1/3 = 1/9$. For $k = 3$, the probability that the second ball will not be placed in the same position as the first one is $2/3$. The probability that the third ball will go in the last remaining position is $1/3$. So the overall probability is $2/3 \times 1/3 = 2/9$. – user49640 Jun 11 '17 at 03:45
  • The probability of $(3,0,0)$ is $1/27$, whereas the probability of $(1,1,1)$ is $2/9$. So if the experiment is conducted as you describe, determining the various probabilities is not as simple as counting the different types $(a,b,c)$. – user49640 Jun 11 '17 at 06:31

3 Answers3

3

Using the Generalized Inclusion-Exclusion Principle

The sum of the probabilities of missing $j$ particular bins over all selections of $j$ particular bins is $$ \overbrace{\ \ \ \binom{m}{j}\ \ \ }^{\substack{\text{the number of}\\\text{ways to choose}\\\text{$j$ particular bins}}}\overbrace{\left(\frac{m-j}m\right)^n}^{\substack{\text{the probability}\\\text{of missing $j$}\\\text{particular bins}}}\tag{1} $$ Then, according to the Generalized Inclusion-Exclusion Principle, the probability of missing exactly $k$ bins is $$ \begin{align} \sum_{j=0}^m(-1)^{j-k}\binom{j}{k}\binom{m}{j}\left(\frac{m-j}m\right)^n &=\binom{m}{k}\sum_{j=0}^m(-1)^{j-k}\binom{m-k}{m-j}\left(\frac{m-j}m\right)^n\tag{2} \end{align} $$ In the question, $k$ is the number of non-empty bins, so we need to substitute $k\mapsto m-k$. Since $j$ is a dummy variable, we can also substitute $j\mapsto m-j$. This gives the probability of getting exactly $k$ non-empty bins to be $$\newcommand{\stirtwo}[2]{\left\{#1\atop#2\right\}} \begin{align} \binom{m}{k}\sum_{j=0}^m(-1)^{k-j}\binom{k}{j}\left(\frac{j}m\right)^n &=\binom{m}{k}\stirtwo{n}{k}\frac{k!}{m^n}\\ &=\bbox[5px,border:2px solid #C0A000]{\stirtwo{n}{k}\frac{(m)_k}{m^n}}\tag{3} \end{align} $$ where $\stirtwo{n}{k}$ is a Stirling Number of the Second Kind and $(m)_k$ is a Pochhammer Symbol or Falling Factorial.

One of the "defining" relations of the Stirling Number of the Second Kind is that $$ \sum_{k=0}^n\stirtwo{n}{k}(m)_k=m^n\tag{4} $$ and $(4)$ guarantees that the sum of $(3)$ over all $k$ is $1$, which is comforting.

Formula $(3)$ matches user49640's formula, though I believe this approach is different.


Looking for the Maximum

Now we are looking for when $\stirtwo{n}{k}(m)_k$ is maximum for $k=m$. Since $$ \frac{\stirtwo{n}{k}(m)_{k}}{\stirtwo{n}{k-1}(m)_{k-1}}=\frac{\stirtwo{n}{k}}{\stirtwo{n}{k-1}}(m-k+1)\tag{5} $$ we are looking for $n$ and $m$ so that $$ \stirtwo{n}{m}\ge\stirtwo{n}{m-1}\tag{6} $$ According to this Wikipedia article section, the maximum $m$ satisfying $(6)$ is asymptotically $$ m\sim\frac{n}{\log(n)}\tag{7} $$ If some $m$ satisfies $(6)$, any smaller $m$ will.

robjohn
  • 345,667
  • I asked the OP to clarify the question in the comments above. Does your calculation fit with what is described there? – user49640 Jun 11 '17 at 05:32
  • When I was writing my answer, the OP had a different formula than I have in $(1)$, but then they edited it and now our formulas match. Either the $\lfloor k\rfloor$ or $\lfloor k\rfloor+1$ in $(3)$ maximizes $(1)$. – robjohn Jun 11 '17 at 06:21
  • When $m = n = 3$ and $k = 1, 2, 3$, I find that the probabilities are $1/9$, $2/3$ and $2/9$. I asked the OP how the experiment was conducted, and the answer I received is in the comments above. I don't think your expression fits with the way the experiment is described. The OP says he/she wants "the most probable distribution of balls." – user49640 Jun 11 '17 at 06:28
  • Thanks for your inputs. I have been pondering on what user49640 said.on probabilities. Indeed I asked for the "most probable Distribution of balls", but I gave for granted that would match the distribution for which the number of available combinations is higher (there is a statistical mechanics Background to this Problem, and in that field maximising entropy, i.e. choosing a macrostate with the highest possible number of possible microstates, yields the most probable state. thanks to your inouts I fiund some inconsistencies in my reasoning. – An aedonist Jun 11 '17 at 17:47
  • It seems the most probable configuration does not coincide with the one for which the number of combinations is greater. – An aedonist Jun 11 '17 at 17:51
  • To clarify my issues using the $m = n = 3$ case, the following occurences are possible, (3,0,0), (0,3,0), (0,0,3), (1,2,0),(2,1,0), (1,0,2),(2,01), (0,1,2), (0,2,1), (1,1,1). So there are three ways to put all the balls in one box, one way to puch one ball in each box, and 6 ways whereby one box is empty. I then thought that the probabilites followed easily by computing,$ \it {number of cases / number of total cases}$, like in statistical thermodynamics, where each occurence is considered equiprobable. – An aedonist Jun 11 '17 at 18:23
  • 1
    @user37292 If the experiment is as you described it, then there are $m^n$ equiprobable outcomes. If the balls are numbered, then these outcomes are all distinguishable. If the balls aren't numbered, then some of them are indistinguishable. But erasing the numbers on the balls doesn't magically change the probabilities involved. The probabilities are still the same as if the balls were numbered. (I'm not talking about what might happen in some weird quantum mechanics sense, which I'm not qualified to discuss - I'm talking about ordinary probabilities.) – user49640 Jun 12 '17 at 00:27
  • @user49640, Indeed, you are right of course, the fact completely slippd through my atttention – An aedonist Jun 12 '17 at 09:00
  • @robjohn, tahnks for your answer, which I am trying to fully understand. I find the maximum result particularly puzzling. So for example, with $n=100$, one needs around 10 or less boxes for the expected outcome to be that at least one ball went in each box. It sound so counter-intuitive. One would bet that wth 100 balls, the probability to place at least one in 20 boxes would be virtually one. – An aedonist Jun 12 '17 at 09:07
  • @robjoh, let me clarify using the binomail distribution argument I sketched in the question. I have 30 boxes, 100 balls. Following your calculation, one would expect at least one empty box. How likely is it for one specific box to be empty at the end of the experiment? I consider the 9 boxes to "fill" as one box, selected with 29/30 probability, vs the remaining box, 1/30 chance. The chance to have all "successes", i.e. balls in the "big" box, is only 3.3% , according to the binomial distribution: one would expect then some "failures", i.e. the empty box to get at least one ball. – An aedonist Jun 12 '17 at 09:30
  • @robjohn Your calculation takes into account there are more ways to select the empty box and the probability that a specific box is empty has to be lower t´han the probability A box is e, but yet, the result is surprising. I have to study it proper. – An aedonist Jun 12 '17 at 09:31
  • @user37292: I am not sure what you are trying to say. There are $m^n$ equally probable states, each corresponding to a function from $\mathbb{Z}_n\to\mathbb{Z}_m$ (representing which bin each marble is in). The Inclusion-Exclusion formula $(2)$ simply counts how many of these have $k$ empty bins and divides it by $m^n$. Then we substitute $k\mapsto m-k$ to change $k$ to the number of non-empty bins and get $(3)$, the probability of having $k$ non-empty bins. – robjohn Jun 12 '17 at 15:00
  • @robjohn I'm not sure what you mean when you say "now we are looking for when [expression] is maximum for $k = m$." The way I understand the OP's question, $m$ and $n$ are fixed and we're looking for the maximum value for $k = 1, \dots, m$. – user49640 Jun 12 '17 at 22:03
  • @robjohn, indeed, I was again confusing combinations with probabilities, in spite of user49649 efforts to warn me. Now studying this Inclusion-Exclusion formula. Thanks a lot. – An aedonist Jun 13 '17 at 08:08
  • @user49640: from the question: "I am interested in estimating when the transition occurs, i.e. for which values of $m, n$ the maximum of $C(k)$ occurs for $k < m$." Since $k\le m$, the question is equivalent to asking to find when the maximum of $\stirtwo{n}{k}\frac{(m)_k}{m^n}$ occurs for $k=m$, unless I am misreading the question. – robjohn Jun 13 '17 at 08:28
  • @robjohn You're right, I hadn't noticed that. – user49640 Jun 13 '17 at 08:40
  • @robjohn, would you please be kind enough to give me a hint on how you applied the Inclusion-Exclusion principle. I just learnt about it and am unable to work the details out. For one, the Principle allows to compute the probability of an union of events. What particular events are you choosing? – An aedonist Jun 16 '17 at 10:22
  • @user37292: The standard Inclusion-Exclusion Principle takes a collection of sets ${S_j:1\le j\le n}$ and uses the sum of the sizes of all intersections of $k$ of those sets $$N_k=\sum_{|\alpha|=k}\left|\bigcap_{j\in\alpha}S_j\right|$$ to compute the size of the union of the sets $$\left|\bigcup_jS_j\right|=\sum_{k=1}^n(-1)^{k-1}N_k$$ – robjohn Jun 16 '17 at 22:28
  • The Generalized Inclusion-Exclusion Principle counts the number of elements in exactly $m$ of those sets $$\overbrace{\left|\bigcup_{|\alpha|=m} \bigcap_{j\in\alpha}S_j\right|}^{\substack{\text{in at least $m$}\\text{ of the $S_j$}}} -\overbrace{\left|\bigcup_{|\alpha|=m+1}\bigcap_{j\in\alpha}S_j\right|}^{\substack{\text{in at least $m+1$}\\text{ of the $S_j$}}}=\sum_{k}(-1)^{k-m}\binom{k}{m}N_k$$ See the link for the Generalized Inclusion-Exclusion Principle given in the answer for a proof. – robjohn Jun 16 '17 at 22:28
1

This isn't a complete answer to the OP's question, but it corrects the expression given for the required probability.

Let $P(n,m,k)$ be the probability that after $n$ balls are randomly assigned to $m$ containers, exactly $k$ of them have at least one ball in them.

Using the inclusion-exclusion formula, we find $$P(n,m,m) = 1 - m(1-1/m)^n + \binom{m}{2}(1-2/m)^n - \dots = \sum_{i=0}^{m-1} (-1)^i \binom{m}{i}(1 - i/m)^n.$$

Now, summing over all possible $k$-element subsets of the $m$ containers, we have $$P(n,m,k) = \binom{m}{k}(k/m)^nP(n,k,k) = \binom{m}{k} \sum_{i=0}^{k-1} (-1)^i \binom{k}{i}\left(\frac{k-i}{m}\right)^n = \frac{m!}{m^n(m-k)!}S(n,k),$$ where $S(n,k)$ denotes a Stirling number of the second kind.

user49640
  • 2,704
  • @user49460, would you please be kind enough to provide some more details on your answer? First, you compute Let P(n,m,k), the probability that after n balls are randomly assigned to m containers, exactly m of them have at least one ball in them. I believe this is done by considering the sets $A_j$, standing for all the sets with at least one empty container. So $P(n,m,m)$= 1 - probability (at least one box is empty). The next formula puzzles me. It is obtained multyplying $ {m} \choose {k}$ by $P(n,k,k)$, and a factor $(k/m)^n$. – An aedonist Jun 16 '17 at 11:57
  • The latter equals the probability all $n$ balls will fall in the k containers. I am unsure I get it. – An aedonist Jun 16 '17 at 11:57
  • First we find $P(n,m,m)$, the probability that all $m$ containers are filled. Letting $A_i$ be the event that the $i$th container is not filled, we are looking for the probability of the complement of $A_1 \cup \dots \cup A_m$. By the inclusion-exclusion formula, this is $1 - \sum_i P(A_i) + \sum_{i,j} P(A_i \cap A_j) - \dots$. – user49640 Jun 16 '17 at 12:27
  • Don't apologize. I only explained the part about $P(n,m,m)$ in my comment. There are $\binom{m}{k}$ ways to select a $k$-element subset of the set of containers. $(k/m)^n$ is the probability that all $n$ balls will be contained in a given $k$-element subset. And $P(n,k,k)$ is the conditional probability, given that all $n$ balls are in a particular $k$-element set of containers, that all $k$ of those containers will be filled. – user49640 Jun 19 '17 at 10:47
  • (Comment made before the last ) I can only apologise ofr my "thicknss", but I still do not get it. Ok I understand the way the inclusion-exclusion principle is used to compute $P(n,m,m)$. The next step confuses me. There are three factors used to calculate $P(n,m,k)$: te first counts the ways to select the $k$-subsets out of the $m$ containers. The third is also clear. But the $(k/m)^n$ term, it seems to me you are calculating the possibiliyt that out of the $n$ balls, all end in the $k$-subset. Then $P(n,k,k)$ gives the probability that each conttiner in the subset received at least a ball. – An aedonist Jun 19 '17 at 10:51
  • Ok I see how the $(k/m)^n$ factor is related to the condition, "given that all $n$ balls are in a particular $k$ -element set of containers", but does not that leave the case out, that only$ j$ out of $n $ balls fall into the $k $ -subset? Would not in this case probabilities $P(j,m,k) $ come into play? – An aedonist Jun 19 '17 at 14:03
  • I don't understand what case you're talking about. For example, If $m = 5$ and $k = 3$, let the containers be ABCDE. We want the probability that exactly three containers are filled. This is $\binom{5}{3}$ times the probability that exactly ABC is filled. Do you agree with that? Next, we calculate the probability that all the balls fall into ABC, even though they might not fill them, which is $(3/5)^n$. If that happens, we can pretend that $m = 3$ and $k = 3$, and calculate the conditional probability that all three containers are filled. This is $P(n,3,3)$. – user49640 Jun 19 '17 at 20:16
  • Indeed. These days. many many thanks. – An aedonist Jun 19 '17 at 20:17
1

Suppose we have fixed value of $m$, the number of bins, and we want to find the value $n$ which maximizes the chance of exactly $k$ nonempty bins, either for a single value of $k=K$ or for all $k\le K$. We can create a Markov process with $K+1$ states that computes these values.

Note that the labelling of the bins does not enter the computation. If $k$ out of $m$ bins are nonempty, then drawing a ball will result either in a new bin getting a ball with probability $(m-k)/m$ or preserving the same set of bins that have at least one ball with probability $k/m$.

Assume $1 \lt K \lt m$. Once more than $K$ bins have a ball, this will always remain true. So we group together all states with more than $K$ nonempty bins as a single "absorbing" state.

The state after drawing one ball is deterministic: one bin is nonempty and the rest of the $m-1$ bins are empty. So we have a state vector of length $K+1$ at step $1$:

$$ s_1 = (1,0,0,\ldots,0) $$

and the probability transition matrix looks like:

$$ M = \begin{bmatrix} 1/m & 1 - 1/m & 0 & 0 & \dots & 0 \\ 0 & 2/m & 1-2/m & 0 & \dots & 0 \\ 0 & 0 & 3/m & 1-3/m & \dots & 0 \\ \vdots & \vdots & \ddots & \ddots & \ddots & \vdots \\ 0 & 0 & \dots & (K-1)/m & 1-(K-1)/m & 0 \\ 0 & 0 & \dots & 0 & K/m & 1-K/m \\ 0 & 0 & \dots & 0 & 0 & 1 \end{bmatrix} $$

Thus the probability distribution of states at step $n$ is simply $s_1 M^{n-1}$. The next two steps give these results:

$$ s_2 = (m^{-1},1-m^{-1},0,\ldots,0) $$ $$ s_3 = (m^{-2},3m^{-1}-3m^{-2}, 1-3m^{-1}+2m^{-2},0, \ldots,0) $$

Numerical computation to find the step $n$ that maximizes a particular entry (the $k$th entry of $s_n$ is the probability that $k$ bins are nonempty) can be scaled to integer arithmetic by extracting a factor $1/m$ from matrix $M$. If the column vectors $e_j$, $j=1,..,K+1$ are the "standard basis vectors", then since $s_1 = e_1^T$:

$$ \Pr(k \text{ bins exactly are nonempty after } n \text{ balls}) = m^{1-n} e_1^T A^{n-1} e_k $$

where $A = mM$ is an upper triangular matrix with nonnegative integer entries.

Furthermore $A = P^{-1}D P$ is similar to its matrix $D$ of diagonal entries, so once $u^T = e_1^T P^{-1}$ and $v_k = P e_k$ are computed, the above probability is easy to find:

$$ \Pr(k \text{ bins exactly are nonempty after } n \text{ balls}) = \frac{u^T D^{n-1} v_k}{m^{n-1}} $$

hardmath
  • 37,015