The stars and bars method counts the ways to share identical items among different bins. The stars and bars calculator gives the number of distributions with a minimum in each bin, with empty bins allowed, and with at least one item in each bin.
How the calculation works
- Enter the number of identical items to share, such as candies, coins or balls.
- Enter the number of bins, such as children, boxes or days, and the minimum that each bin must receive (0 if bins may stay empty).
- The calculator removes the minimum from each bin and counts the ways to share the free items with the formula C(free + bins − 1, bins − 1).
- It also shows the counts with empty bins allowed and with at least one item in each bin.
Example
You share 12 identical candies between 4 children, and each child must get at least 2. After the minimum, 12 − 4 × 2 = 4 candies are free, and they can be shared in C(4 + 3, 3) = 35 ways. If empty hands were allowed, there would be C(15, 3) = 455 ways, and with at least one candy each, C(11, 3) = 165 ways. The condition of 2 each keeps 7.7 % of the unrestricted ways.
Why it matters
The calculator helps students of discrete mathematics and probability, teachers, programmers and puzzle lovers to count the solutions of an equation in integers or the ways to share goods. It shows the effect of a minimum on the number of possibilities, which is hard to see in the formula alone.
Good to know
The method needs identical items and distinguishable bins. If the items are different from each other, or the bins identical, the count is another one. The calculator limits n to 60 and the number of bins to 12 so the numbers stay exact, and for upper limits on a bin the inclusion–exclusion method is needed.
Related tools
The combinations calculator counts the choices C(n, k) used in the formula, the permutations calculator counts ordered arrangements, the derangements calculator counts the arrangements with no fixed place, and the hypergeometric distribution calculator finds probabilities when drawing without replacement.