7

Question: $n$ persons are to be allocated to $q$ distinct rooms. Find the number of ways that this can be done if only $m$ of the $q$ distinct rooms have exactly $k$ persons each, where $1\le m\le q$ and $mk\le n$.

My attempt:

$$\binom{q}{m}\cdot\binom{n}{mk}\frac{(mk)!}{(k!)^mm!}\cdot m!\cdot(*)$$

First I selected $m$ rooms out of $q$ in which to arrange the $m\times k$ people, then I just selected $m$ groups of $k$ people from the $mk$ people selected out the total $n$ people, which I then arranged into the $m$ selected rooms. $^*$At this point $n-mk$ people are still left to be arranged in $q-m$ rooms in such a way that in none of those rooms there are $k$ people since the question explicitly states that "$\textbf{only}$ $m$ of the $q$ rooms". This is where I am getting stuck...


Source of the question is "Principles and Techniques in Combinatorics by Chen Chuan-Chong and Koh Khee-Meng" and the given answer is

$$(-1)^m\frac{q!n!}{m!}\sum_{j=m}^{q}(-1)^j\frac{(q-j)^{n-kj}}{(k!)^j(n-kj)!(j-m)!(q-j)!}$$


numerically plugging the following values $(n,q,m,k)=(15,7,4,3)$, we can quite clearly see that this set of values will give valid cases, just for the sake of argument, put $3$ persons each in first $4$ rooms and then the remaining $3$ persons be put into any $3$ of left rooms, with each room holding $1$ person. So, this will be a valid case, but on putting these values in the given answer formula, it makes no sense as there is negative factorial generated in the denominator, does that mean the given answer is wrong?

For the formula to make sense, $n \ge qk$, but this is as shown above, not a necessary condition to get valid cases.

lilychou
  • 1,475

4 Answers4

2

This can also be done using combinatorial classes from Analytic Combinatorics by Flajolet and Sedgewick. We get from first principles the marked class specification

$$\def\textsc#1{\dosc#1\csod} \def\dosc#1#2\csod{{\rm #1{\small #2}}} \textsc{SEQ}_{=q} (\mathcal{U}\times\textsc{SET}_{=k}(\mathcal{Z}) + \textsc{SET}_{\ne k}(\mathcal{Z})).$$

We then get for the EGF

$$F(z,u) = \left( \exp(z) + (u-1)\frac{z^k}{k!} \right)^q.$$

We have exactly $m$ instances of rooms with $k$ occupants and obtain

$$G(z) = [u^m] \left( \exp(z) - \frac{z^k}{k!} + u\frac{z^k}{k!} \right)^q = {q\choose m} \left( \exp(z) - \frac{z^k}{k!} \right)^{q-m} \frac{z^{mk}}{k!^m}.$$

Expanding the binomial and extracting coefficients we find

$$n! [z^n] {q\choose m} \frac{z^{mk}}{k!^m} \sum_{j=0}^{q-m} {q-m\choose j} \exp((q-m-j)z) (-1)^j \frac{z^{kj}}{k!^j} \\ = (-1)^m n! [z^n] {q\choose m} \frac{z^{mk}}{k!^m} \sum_{j=m}^{q} {q-m\choose j-m} \exp((q-j)z) (-1)^j \frac{z^{k(j-m)}}{k!^{j-m}} \\ = (-1)^m n! [z^n] {q\choose m} \sum_{j=m}^{q} {q-m\choose j-m} \exp((q-j)z) (-1)^j \frac{z^{kj}}{k!^j} \\ = (-1)^m n! {q\choose m} \sum_{j=m}^{q} {q-m\choose j-m} [z^{n-kj}] \exp((q-j)z) \frac{(-1)^j}{k!^j} \\ = (-1)^m n! {q\choose m} \sum_{j=m}^{q} {q-m\choose j-m} \frac{(q-j)^{n-kj}}{(n-kj)!} \frac{(-1)^j}{k!^j} \\ = (-1)^m n! \frac{q!}{m!} \sum_{j=m}^{q} \frac{1}{(j-m)! (q-j)!} \frac{(q-j)^{n-kj}}{(n-kj)!} \frac{(-1)^j}{k!^j}.$$

This is the claim. Here the coeffcient extrator $[z^n]$ gives a zero value when $kj\gt n.$ This zero value is understood to extend to the term $(q-j)^{n-kj}/(n-kj)!.$

Marko Riedel
  • 64,728
1

The answer can be obtained by the generalised inclusion-exclusion principle as

$$ \sum_{j=m}^q(-1)^{j-m}\binom jma_j $$

where $a_j$ is the number of ways that at least $j$ rooms out of $q$ rooms include exatcly $k$ persons, given by

$$a_j=\binom{q}{j} \left(\left[\binom{n}{jk}\frac{(jk)!}{(k!)^j}\right]\cdot (q-j)^{n-jk}\right).$$

Note that for $m=0$, the fromula reduces to the inclusion-exclusion principle.

Amir
  • 11,124
0

To use the notation of the book (at page 149), let $P_r$ be the property that room $r$ has exactly $k$ people. Then for the number of allocations that satisfy exactly $m$ of the properties $P_r$ we have the formula

$$ E(m) = \sum_{j=m}^q (-1)^{j-m} \binom{j}{m} \sum_{i_1<i_2<\dots < i_j} \omega(i_1, \dots, i_j) $$

where the inner sum is over all $j$-combinations of $\{1,2,\dots, q\}$ and $\omega(i_1, \dots, i_j)$ is the number of allocations satisfying all of the properties $P_{i_1}, \dots, P_{i_j}$. In this case

$$ \omega(i_1, \dots, i_j) = \binom{n}{jk} \frac{(jk)!}{(k!)^j} (q-j)^{n-jk} $$

because we can do the allocation where the rooms $i_1, \dots, i_j$ have each exactly $k$ persons by first selecting the $jk$ persons that go in those $j$ rooms and ordering them in a line and then taking them in batches of $k$ (we divide by $(k!)^j$ because the order within a room doesn't matter). And for the remaining $n-jk$ people we choose any room out of the remaining $q-j$, which can be done in $(q-j)^{n-jk}$ ways.

So $\omega(i_1, \dots, i_j)$ is constant for each $(i_1, \dots, i_j)$ and the sum amounts to just multiplying by the number of terms $\binom{q}{j}$.

So

$$ E(m) = \sum_{j=m}^q (-1)^{j-m} \binom{j}{m} \binom{q}{j} \binom{n}{jk} \frac{(jk)!}{(k!)^j} (q-j)^{n-jk} \\ = (-1)^m\frac{q!n!}{m!}\sum_{j=m}^{q}(-1)^j\frac{(q-j)^{n-kj}}{(k!)^j(n-kj)!(j-m)!(q-j)!}. $$

ploosu2
  • 12,367
-1

I assume that the persons and the rooms are distinct, but order of people in a room does not matter, and that the question means there are exactly $m$ rooms that have exactly $k$ people, and the other rooms have a different amount of people.

The answer then is $$ \binom{q}{m}\binom{n}{mk}\frac{(mk)!}{(k!)^m}F(n-mk,q-m,k) $$ Where $F(a,b,c)$ is the number of ways we can distribute $a$ people over $b$ rooms with the restriction that none of the rooms have exactly $c$ people. I doubt that there is an explicit formula for $F$ but we can compute it by dynamic programming: $$ F(a,1,c)=\begin{cases}1 & a\neq c\\ 0 & a=c\end{cases}\; \forall a,c\in\mathbb{Z}_{\geq 0}\\ F(a,b+1,c)=\sum_{a'=0,a'\neq c}^{a}F(a-a',b,c)\binom{a}{a'}\;\forall a,c\in\mathbb{Z}_{\geq 0},b\in \mathbb{N} $$ In the second formula $a'$ is the number of people we put in the first room. There are $\binom{a}{a'}$ options to do so and then $F(a-a',b,c)$ to distribute the rest.