Picking objects

Say you have to pick objects from objects.


Counting functions

Let , , .

Total number of functions is .
Total number of injections is .

One way to calculate the total number of surjections is to first consider the sizes of the preimage sets of every . Define , . We know that for all , and . Let be a solution to . Then, the number of functions satisfying is . Thus, the total number of surjections is

Notice that if we remove the restriction, the formula basically gives the total number of functions from to , courtesy the multinomial theorem:

Evaluating directly is not easy. We could instead use the inclusion-exclusion principle to isolate all the cases when for some (functions that are not surjective), and subtract it away from . The number of non-surjective functions is

Subtracting it away from , we get (Note that setting the upper limit to or is the same)

Incidentally, the Sterling number of the second kind, which counts the number of ways to partition a set of size into non-empty subsets, is given by


Basic properties of the binomial coefficient

^ easy proof by induction