0

If I have $r$ items and I am making $n$ distinct choices with replacement, then there are $r^{n}$ possible selections. However, how could I count with the added constraint that each of the $r$ items must be selected at least once?

This problem implies that I want to count all $r^n$ possibilities, but I want to exclude cases where any of the $r$ items were selected zero times. That is, if I have items $(r_1,r_2,r_3)$ and choices $(n_1,n_2,n_3,n_4,n_5)$, the following would be a VALID selection because each $i$ was chosen at least once: $\{r_1:\{n_1,n_2,n_3\}, r_2:\{n_4\}, r_3:\{n_5\}\}$. However, the following would be INVALID to include: $\{r_1:\{n_1,n_2,n_3\}, r_2:\{n_4,n_5\}, r_3:\{\}\}$ because $r_3$ was not chosen.

I'd like to use this as a step in a derivation for another question.

efthimio
  • 197
  • 6
  • See https://math.stackexchange.com/questions/1526459/counting-surjective-functions/1526510#1526510 and the linked questions there. – Mike Earnest Jan 24 '21 at 23:00

1 Answers1

0

Since each item must be selected at least once the possible counts can be expressed using Stirling number of second kind: $$ r!{n \brace r}=\sum_{i=0}^r (-1)^i\binom ri (r-i)^n. $$ The right hand side expression can be obtained using inclusion-exclusion principle.

user
  • 27,958