Distinct objects into identical bins is a problem in combinatorics in which the goal is to count how many distribution of objects into bins are possible such that it does not matter which bin each object goes into, but it does matter which objects are grouped together. This problem is often trickier than the related problem of placing distinct objects into distinct bins.
Suppose there are 4 distinct roses which will be placed into 2 identical vases. How many ways can the roses be arranged?
If a rule of product approach is attempted, the question becomes, "Where does the first, second, third, or fourth flower go?" However, this doesn't account for having identical vases, since it doesn't matter if the flowers all went to the first vase or all went to the second vase. In either case, the end result is the same.
Since there is no clear idea on how to proceed, simply list out all the ways. Note that out of the 8 ways in total, 7 of them involve both vases:
In this wiki, the goal is to understand how one can deal with the general case in a sensible manner. Listing out cases is extremely tedious, and likely to result in double-counting or missing cases. Unlike the counting of distinct objects into distinct bins, which has a simple bijection argument, this process is slightly more involved and will lead you down the path of recursion.
Consider these two cases:
- Distinct objects into identical bins with no empty bin - Stirling numbers of the second kind
- Distinct objects into any number of identical bins - Bell numbers
A Stirling number of the second kind, denoted as or , is the number of ways a set of elements can be partitioned into non-empty sets.
Equivalently, a Stirling number of the second kind can identify how many ways a number of distinct objects can be distributed among identical non-empty bins. In this section, the basic cases for Stirling numbers of the second kind are explored in order to better understand how to solve "distinct objects into identical bins" problems.
Let be the number of distinct objects to be distributed among identical bins.
Consider these cases in which the number of bins is close to the number of objects:
1. Number of bins > Number of objects:
Clearly, since each bin needs at least 1 object, there are not enough objects to go around. Thus, the number of ways to do this is .
2. Number of bins = Number of objects:
Clearly, every bin must have exactly 1 object. Since the bins are the same, each bin contains 1 object each, and the order of bins does not matter. Thus, there is only way.
3. Number of bins = Number of objects - 1:
There is one bin which contains 2 objects, and the rest of the bins each will contain 1 object. Hence, it is sufficient to find the number of ways of picking 2 objects and placing those into a bin while the rest will go into an identical bin. Thus, there are ways of doing this.
4. Number of bins = Number of objects - 2:
There are 2 "extra" objects to be placed. There are two possible cases:
- 3 objects in one bin: There are ways to choose the 3 objects to go into this bin.
- 2 objects in one bin, occurring twice: First, there are ways to pick 4 objects, and then there are ways to place them into 2 bins of 2 objects. Thus, there are ways.
Hence, there are ways.
This process can continue, but it quickly gets complicated with the number of cases that need to be studied.
How many ways are there to place 7 distinct objects into 5 non-empty identical bins?
The objects will either be in a distribution of or Note that it does not matter what order the objects are in, only which objects are grouped together. For the first case, there are ways to choose the grouping of 3 objects. Then, in the second case, there are ways to select 4 objects out of the 7, and then there are ways to divide these 4 objects into 2 groups of 2. The total number of ways to arrange the objects is
Note that this could also be computed using the formula above.
Now consider the cases in which the number of bins is small.
Number of bins = 1:
Clearly, if the number of bins is 1, then all of the objects must be in this bin. Hence, there is only way to do this.
Number of bins = 2:
Consider a slightly different scenario, where there are balls in 2 bins. If the bins are not identical, then there are distributions of the balls since each ball can go into either bin. However, two of these distributions involve all of the balls placed into one bin. Hence, there are ways in which these balls can be placed into non-identical bins such that no bin remains empty.
Now consider how to modify this scenario to reflect the bins being identical. Let there be balls in the first bin and balls in the second bin. There is an equivalent distribution of having balls in the first bin and balls in the second bin. There are distributions of distinct objects into distinct bins for every distribution of distinct objects into identical bins. Hence, the distributions into identical bins have been double counted, and so the total number would be:
Now that several basic cases have been considered, the strategy moves to how to use these basic cases to develop a recursive relationship that gives for any number of objects and number of bins.
Here is a summary of the results in the previous section using Stirling notation:
Let there be distinct objects to be distributed among identical bins. Then
From these basic cases, any value of can be calculated through the recurrence relation:
To develop this relation, consider a single object to be fixed, and then consider where the remaining objects go. There are two cases:
- Case 1: The fixed object is in its own bin.
There are remaining objects to be distributed into bins, which gives distributions for this case.
- Case 2: The fixed object is in a bin with other objects.
The remaining objects are distributed into bins, which gives distributions. For each of these distributions, there are ways to group the fixed object with the other objects. Thus, there are distributions for this case.
Summing both cases together yields
The recurrence relation allows one to calculate Stirling numbers of the second kind from basic cases.
How many ways are there to place 5 flowers into 3 identical bins (such that no bin remains empty)?
The goal is to find . From the recurrence relation,
The values of and can be drawn from the basic cases: and . Thus,
Now consider an example in which the recurrence relation is used several times:
How many ways are there to place 7 flowers into 4 bins?
The goal is to find . From the recurrence relation,
These values can't be drawn from the basic cases, but the recurrence relation can be used again to calculate them separately.
From the recurrence relation, basic cases, and previous example,
Also from the recurrence relation, basic cases, and previous example,
Putting this together,
These examples show the power of the recurrence relation, which allows one to calculate any value of from other values of . For reference, here is a list of for
people of distinct heights want to take a photo. They form exactly vertical rows, such that each row is arranged in order of height. How many ways are there to do this?
This starts to look like arranging people into rows. Verify that the problem can be solved with Stirling numbers of the second kind:
- distinct objects: Yes, these people are of distinct heights.
- identical boxes: Yes, the order of the rows do not matter.
- Into boxes: Yes, the order of the items does not matter, because there is only way to arrange them in increasing order of height.
Thus, it is equal to (which is obtained from the above table).
Prove by induction that .
Base Case: For , . . Hence the base case is verified.
Induction Hypothesis: Assume it is true for some . By the recurrence relation:
Hence, by mathematical induction, the statement is true.
Previous examples required the objects to be placed in a specific number of non-empty bins. There is a related problem in which objects can be placed in any number of non-empty bins. Consider this example:
There are distinct flowers. How many ways can they be planted into identical vases?
These flowers can be placed into , , , or vases. The number of distributions of flowers into vases will thus be the sum of Stirling numbers of the second kind:
The Bell numbers count the number of ways distinct objects can be distributed into up to identical non-empty bins. In the language of sets, Bell numbers count the partitions of a set of objects into non-empty disjoint subsets whose union is the entire set.
The Stirling numbers denote the number of ways to arrange distinct objects into identical boxes,
and the Bell numbers denote the number of ways to arrange distinct objects into up to identical objects.
Hence, Bell numbers are computed as a sum of Stirling numbers:
From the table of Stirling numbers, the following Bell numbers are computed as the sum of each row:
The Bell numbers have their own recurrence relation:
This will be proven with combinatorics. Consider how the element is partitioned. Suppose that there are elements which are not in its box, then there are ways to pick these elements, and thereafter there are ways to arrange these elements into identical boxes. Hence, there are such arrangements. The resulting Bell number is the sum of all these arrangements across all possible values of .
It is interesting to note that the exponential generating function of the Bell numbers is
The simplest way to prove this is to show that the previous recurrence relation explains why , from which the result follows by solving the differential equation and evaluating at .
Suppose that is the product of distinct primes. How many ways are there to write as the product of positive integers , where the order of terms do not matter ?
Consider how placing distinct primes into identical boxes gives us a way of writing as the product of positive integers. First, find the prime factorization of each term of the product, and place the factors of each term into a box. Then, since is the product of distinct prime factors, each prime factor appears in a unique box. Since the product of all of these terms is , each prime factor must be in a box.
Conversely, given any arrangement of these distinct primes into identical boxes, multiply the primes in a box to create a term, and the product of these terms gives the value of . This establishes the bijection. Thus, the number of ways is