I have $n$ balls and throw them into $k$ baskets.

None of $k$ baskets should be empty. Which means each basket has at least one ball.

Balls and baskets are not distinguishable.

What is the number of cases of distribution of balls? And what is the number of each case?

I would be thankful if giving some rationale rather than just a formulae.


We need to make sure each of the baskets contain at least one ball, so why not first place a ball in each of the baskets. Once this is done, the non-empty condition is satisfied, so we can distribute the remaining balls without restriction. How many balls are left? How many ways are there of distributing this many balls between $k$ baskets?

Added Later: Let me introduce some terminology.

A partition of a positive integer $n$ is a collection of positive integers which has sum $n$. For example, $(2, 1)$ is a partition of $3$ because $2 + 1 = 3$. Two collections of positive integers which have the same numbers just in a different order are considered to define the same partition; for example $(2, 1)$ and $(1, 2)$ are two ways of writing the same partition.

In your situation, you will need to partition the remaining balls; note, your baskets are indistinguishable, that's why $(2, 1)$ and $(1, 2)$ should be considered the same. However, you can only partition the remaining balls into at most $k$ parts. If the number of remaining balls is less than $k$ (i.e. $n \leq 2k$), all the partitions will automatically have at most $k$ parts. If $n > 2k$, the problem is a fair bit harder. I'm not sure if there is an explicit formula for the number of ways of doing such partitions in terms of $n$ and $k$.

More information about partitions can be found here.

  • $\begingroup$ What makes this problem a little different/weird is that not only the balls but also the bins are indistinguishable. I think that takes it from a normal balls-and-bins problem to a partition problem—number theory land. $\endgroup$ – dfeuer Aug 28 '13 at 3:33
  • $\begingroup$ Well, I wasn't sure if the user's difficulty stemed from the non-empty condition or from, as you say, the partition aspect. If it is the former, I think I have addressed that. If it is the latter, I'm willing to expand my answer. $\endgroup$ – Michael Albanese Aug 28 '13 at 3:37
  • $\begingroup$ Uh... I thought that this problem has been solved already and I just couldn't find that solution. But when I read the answer and comments on it, it seems to be a new kind of balls-in-bins problem. Is it right? And thank you for your answer. I'll think about a solution based on your advice. $\endgroup$ – songsong Aug 28 '13 at 6:28
  • $\begingroup$ It has, it is just a bit harder than the standard balls in bins problem. $\endgroup$ – Michael Albanese Aug 28 '13 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.