2

there are M same balls and K different boxes. the boxes are labeled from 1,2,...,K. each box could have any number of balls, or be empty.

the question is: at least one box has only one ball, what is the number of this case?

4 Answers4

1

Theorem 2 of Stars and Bars allows for empty boxes. Now you could have only one box have one ball and this you could choose it in K ways. The rest you could use theorem 2. $ Thus, it is

${k\choose 1} [{{m-1+k-1-1}\choose {k-2}}]$.

Now you could have two boxes having only one ball and this you could choose it in ${k\choose 2}$ ways. The rest you could use theorem 2 again. This you subtract from the previous Thus it is ${k\choose 2} [{{m-2+k-2-1}\choose {k-3}}]$. Now you could have three boxes having only one ball and this you could choose it in ${k\choose 3}$ ways. The rest you could use theorem 2 again. This you add back from the previous Thus it is ${k\choose 3} [{{m-3+k-3-1}\choose {k-4}}]$. Keeps going until you have all the boxes to contain exactly only one ball in ${k\choose {m}}$ ways. ${k\choose {m}} [{{m-m+k-m-1}\choose {k-m-1}}]$ when k > m

You could add all and I think that will be the total number of ways you could have atleast one box contain only one ball which is

$${k\choose 1} [{{m-1+k-1-1}\choose {k-2}}]-{k\choose 2} [{{m-2+k-2-1}\choose {k-3}}]+{k\choose 3} [{{m-3+k-3-1}\choose {k-4}}]-\cdots+{k\choose {m}} [{{m-m+k-m-1}\choose {k-m-1}}]$$

$${k\choose 1} [{{m+k-3}\choose {k-2}}]-{k\choose 2} [{{m+k-5}\choose {k-3}}]+{k\choose 3} [{{m+k-7}\choose {k-4}}]\cdots+{k\choose {m}} [{{k-m-1}\choose {k-m-1}}]$$

  • Don't just add the terms, use the exclusion-inclusion principle to make an alternating sum. Avoid over counting. – Graham Kemp Mar 27 '14 at 03:13
1

There are $K \choose 1$ boxes that could have only one ball, and for each of those there are $K-1$ boxes to distribute the rest of the $M-1$ balls (counted by using the stars-and-bars principle with $K-2$ 'bars' and $M-1$ 'stars').

So far that's $\dbinom{K}{1}\dbinom{M+K-3 }{ M-1} = \dfrac{K!(M+K-3)!}{1!(K-1)!(M-1)!(K-2)!}$

However, to avoid double counting we must use the exclusion inclusion principle.  Subtract the ways to have two boxes with only one ball, add back those with three such boxes, etc. till you reach $K-1$ such boxes, or have used all $M$ balls.

$$ \sum_{i=1}^{\min(M,K-1)} \dfrac{(-1)^{i+1}K!(M+K-2-i)!}{i!(K-i)!(M-i)!(K-i-1)!}$$

Graham Kemp
  • 129,094
  • I agree that inclusion-exclusion gives a solution, but your formula gives zero for $K=4$ and $M=2$, for instance. You may like to double check your calculations. –  Mar 28 '14 at 14:52
0

It seems easier to count the number of ways of not having a single box with just one ball, and then subtract from the total way of putting $M$ balls in K different boxes, e.g., by using Stars and Bars : http://en.wikipedia.org/wiki/Stars_and_bars_(combinatorics) to get $(M+K-1)C(K-1)$. Throw 2 balls in each box, then you have $M-2K$ balls left. Now , use , e.g., Stars and Bars , to count the total number of ways of distributing $M-2K$ balls in $K$ boxes. Then subtract this last number from $(M+K-1)C(K-1)$.

EDIT: I think there is a problem in my answer; I assumed here that the negation of having at least one ball was having two-or-more balls, but I don't think that holds; the negation should include the case of boxes being empty. Please give me some time to think it through and rewrite; I will delete if I don't come up with anything soon.

user99680
  • 6,708
  • I was really hoping this was a Confederate States of America reference – Stella Biderman Mar 27 '14 at 02:28
  • @satishramanathan: thanks, but I think I may be wrong; the negation of having at least one ball should also include the cases of having empty boxes, which I did not cover. – user99680 Mar 27 '14 at 02:30
  • @StellaBiderman: a made-up quote that seems to make sense: "True Patriotic Confederates do not leave boxes empty!" – user99680 Mar 27 '14 at 02:31
0

There are $K$ ways in which you can choose the box with only one ball. It then leaves you with $M-1$ balls and $K-1$ boxes. Use the Stars and bars analogy given by user99680 to get the number of ways in which you can throw $M-1$ balls into $K-1$ boxes without constraints, and then multiply it by $K$ to get the answer to your question.

  • But what if more than one box has only one ball? – Carl Jun 05 '14 at 08:13
  • @Carl : The remaining $M-1$ balls are placed in the $K-1$ without any constraints on the number of balls in a box. So, it includes the cases when some of those boxes have exactly one ball each. – user137846 Jun 06 '14 at 22:39
  • Yes, but you would double count, because you could get to a given position in two ways (for example, choosing the first box to have 1 ball, and then the second box just "happens" to end up with one ball. Or alternatively choosing the second to have one ball and the first happens to end up with one ball) – Carl Jun 08 '14 at 00:58