2

I think I need to use Inclusion-Exclusion principle here but I do not know how.

Also I was thinking that when everyone must get at least 1, then I can distribute 1 to everyone and have N items remaining to distrubute among N people so that some get 1 more and some get 2 more(3 items at max per person)

Arc
  • 23
  • Your idea is a good one: the original problem is equivalent to asking for the number of ways to distribute $N$ identical items amongst $N$ people so that no one gets more than $2$ items, so you might as well work with this simpler problem. – Brian M. Scott Apr 01 '20 at 20:14
  • @BrianM.Scott: this is brought out in the step $\left[x^{2n}\right]\left(x+x^2+x^3\right)^n=\left[x^n\right]\left(1+x+x^2\right)^n$. – robjohn Apr 01 '20 at 21:39

3 Answers3

1

Your thoughts are a good start. Indeed you can distribute $1$ item to everyone and then you have $N$ more items to distribute to $N$ people, with everyone getting at most $2$ items. You can do this by summing over the number of people who get $2$ items. If $k$ people get $2$ items, then $N-2k$ people must get $1$ item and $N-k-(N-2k)=k$ people must get $0$ items. There are $\binom N{k,k,N-2k}=\frac{N!}{(N-2k)!k!^2}$ ways to make those choices, so in total there are

$$ \sum_{k=0}^{\left\lfloor\frac n2\right\rfloor}\frac{N!}{(N-2k)!k!^2} $$

different distributions. I don’t think there's a closed form for this; Wolfram|Alpha just returns hypergeometric series.

joriki
  • 238,052
  • 1
    (+1) It's interesting that your answer and Parcly Taxel's sum exactly the same numbers; however, mine gives the same end result (while summing only $n/3$ terms instead of $n/2$). – robjohn Apr 01 '20 at 21:29
  • 1
    @robjohn: That is indeed very interesting. Even though you use generating functions and Parcly Taxel and I use counting, your solution ($+1$ BTW) is actually closer to what the OP was thinking of, since it corresponds to an inclusion–exclusion count: Your sum is the sum for balls in bins with limited capacity, where each bin filled beyond capacity subtracts capacity-plus-one (i.e. in this case three) from the upper index of the binomial coefficient in the inclusion–exclusion sum. – joriki Apr 01 '20 at 21:44
  • 1
    I have appended an Inclusion-Exclusion approach to my answer, which, of course, matches the Generating Function approach. – robjohn Apr 01 '20 at 22:59
1

Denote a person who gets $1,2,3$ items by $-,0,+$ respectively. Then the problem reduces to finding the number of ways to assign signs to $n$ people such that there are as many $+$ people as there are $-$ people. As a sum: $$\sum_{k=0}^{\lfloor n/2\rfloor}\binom n{2k}\binom{2k}k$$ These are the central trinomial coefficients, OEIS A002426.

Parcly Taxel
  • 103,344
1

Generating Function Approach

The number we want is $$ \begin{align} \underbrace{\left[x^{2n}\right]\overbrace{\left(x+x^2+x^3\right)^n}^{\substack{\text{each of $n$ people get}\\\text{$1$, $2$, or $3$ items}}}}_{\substack{\text{number of ways}\\\text{to distribute $2n$ items}}} &=\left[x^n\right]\left(1+x+x^2\right)^n\tag1\\ &=\left[x^n\right]\left(1-x^3\right)^n(1-x)^{-n}\tag2\\[12pt] &=\left[x^n\right]\sum_k\binom{n}{k}(-1)^kx^{3k}\sum_j\binom{-n}{j}(-1)^jx^j\tag3\\[3pt] &=\sum_k(-1)^k\binom{n}{k}\binom{2n-3k-1}{n-3k}\tag4\\ &=\sum_{k=0}^{\lfloor n/3\rfloor}(-1)^k\binom{n}{k}\binom{2n-3k-1}{n-1}\tag5 \end{align} $$ Explanation:
$(1)$: $\left[x^{n+k}\right]x^kP(x)=\left[x^n\right]P(x)$
$(2)$: $\left(1+x+x^2\right)(1-x)=1-x^3$
$(3)$: apply the Generalized Binomial Theorem
$(4)$: apply negative binomial coefficients
$\phantom{\text{(4):}}$ extract the coefficient of $x^n$ by setting $j=n-3k$
$(5)$: the terms in $(4)$ are non-zero for $3k\le n$, then apply $\binom{n}{k}=\binom{n}{n-k}$


Inclusion-Exclusion Approach

The number of ways to distribute $2n$ identical balls to $n$ people where each person gets $1$, $2$, or $3$ balls, is the same as the number of ways to distribute $n$ identical balls to $n$ people where each person gets $0$, $1$, or $2$ balls (just start each person with $1$ ball).

Let $S(j)$ be the arrangements where person $j$ has $3$ or more balls. We want to count the number of arrangements in none of the $S(j)$. We will apply the Generalized Principle of Inclusion-Exclusion, where the sum of the intersection of $k$ of the $S(j)$ is $$ N(k)=\overbrace{\ \ \ \binom{n}{k}\ \ \ }^{\substack{\text{the number of}\\\text{ways to choose}\\\text{the $k$ people to}\\\text{have the $3$ or}\\\text{more balls}}}\overbrace{\binom{n-3k+n-1}{n-3k}}^{\substack{\text{use stars and bars}\\\text{to count the number}\\\text{of ways to distribute}\\\text{the remaining $n-3k$}\\\text{balls to $n$ people}}}\tag6 $$ The number of ways to be in none of the $S(j)$ is $$ \begin{align} \sum_k(-1)^{k-0}\binom{k}{0}N(k) &=\sum_k(-1)^k\binom{n}{k}\binom{2n-3k-1}{n-3k}\tag7\\ &=\sum_{k=0}^{\lfloor n/3\rfloor}(-1)^k\binom{n}{k}\binom{2n-3k-1}{n-1}\tag8 \end{align} $$ which matches $(5)$.

robjohn
  • 345,667
  • 1
    The terms in this sum are quite different than those in joriki's and Parcly Taxel's answers, but the end result is the same (since all three answers are correct). – robjohn Apr 01 '20 at 21:34
  • $+1$. Note that this corresponds to counting the arrangements of balls in bins with limited capacity using inclusion–exclusion; the index $k$ is the number of bins filled beyond capacity. – joriki Apr 01 '20 at 21:46
  • I was considering appending the inclusion-exclusion argument (which I may still do). Also notice that the truncation in the last step is necessary; if we include the terms where $3k\ge2n$, we get non-zero negative binomial coefficients, and if we include those, we get an order $n$ repeated difference of an $n-1$ degree polynomial, which vanishes. – robjohn Apr 01 '20 at 21:56
  • Yes. When I use the balls-in-bins-with-limited-capacity formula, I usually write that contrary to the usual convention the binomial coefficient is taken to be zero for negative upper index, to avoid complicated limits for the sums. But I nearly tricked myself here recently, when I forgot that I'd changed the convention and almost concluded from the fact that the result was a sum of binomial coefficients with lower index $3$ that it must be a polynomial of degree $3$ :-) – joriki Apr 01 '20 at 22:01
  • 1
    [Extended Conversation] I often use the negative binomial coefficients, so only consider the coefficient $0$ when the lower index is negative. Then I need to remember that $\binom{n}{k}=\binom{n}{n-k}$ is only true when $n$ is a non-negative integer. – robjohn Apr 01 '20 at 22:05
  • The number given by the Generalized Inclusion-Exclusion Principle for the number of ways to be in no set, is simply the total number of sets minus the result the standard Inclusion-Exclusion Principle (which counts the number of ways to be in at least $1$ set). – robjohn Apr 01 '20 at 22:57
  • 1
    Thank you for the detailed answer – Arc Apr 02 '20 at 21:04