Generating Functions for Multinomials Find a generating function $(x_1, x_2, ... , x_m)$ whose coefficients of $x_1^{r_1}x_2^{r_2} ... x_m^{r_m}$ is the number of ways $n$ people can pick a total of $r_1$ candies of type $1$, $r_2$ candies of type $2$, ... $r_m$ candies of type $m$ if:
Each person picks either two candies of one type or no candies at all.
Workings:
Let $P(r_1,r_2, ..., r_m)$ denote the number of ways $n$ people can pick a total of $r_1$ candies of type $1$, $r_2$ candies of type $2$, ... $r_m$ candies of type $m$ such that each person pickes either two candies of one type or no candies at all.
So:
$r_1 + r_2 + ... r_m = n$
Consider these cases seperate.
Two candies of one type would mean they would take $x^2$ candies of a certain type or no candies at all.
I'm wondering if what I said so far is correct and I'm not sure on what to do next.
Any help will be appreciated.
 A: For illustrative purposes suppose that there are $3$ types of candy and just the two of us picking. The generating function for my outcomes is simply $1+x_1^2+x_2^2+x_3^2$: the term $1$ corresponds to my picking no candy at all, and for $k=1,2,3$ the term $x_k^2$ corresponds to my picking $2$ candies of type $k$. Those four outcomes are the only possible outcomes for me, so this is the entire generating function if I’m the only participant.
But I’m not: you’re also a participant. You have the same choices as I, so your the generating function for your outcomes is also $1+x_1^2+x_2^2+x_3^2$. We choose independently, so any of my outcomes can combine with any of yours. The mathematical operation that corresponds to that is multiplication: our combined outcomes are described by the product of our generating functions, i.e., by
$$(1+x_1^2+x_2^2+x_3^2)^2=1+2x_1^2+2x_2^2+2x_3^2+2x_1^2x_2^2+2x_1^2x_3^2+2x_2^2x_3^2+x_1^4+x_2^4+x_3^4\;.$$
Each term has the form $ax_1^jx_2^kx_3^\ell$; $j$ is the total number of type $1$ candies that the two of us have picked, $k$ is the total number of type $2$ candies that we’ve picked, $\ell$ is the total number of type $3$ candies that we’ve picked, and $a$ is the number of different ways in which this outcome can occur. For example, if I pick no candy at all, and you take $2$ type $3$ candies, my choice is described by the $1$ term of my generating function, yours is described by the $x_3^2$ term of your generating function, and the product of those two terms, representing our combined choices, is $1\cdot x_3^2=x_3^2$. This shows an outcome in which we’ve chosen altogether $2$ type $3$ candies and nothing else. But that same total outcome arises when I take $2$ type $3$ candies, and you take nothing. That outcome is represented by the product of my $x_3^2$ term and your $1$ term, which is $x_3^2\cdot1=x_3^2$. And when we collect terms in the product, we end up with a $2x_3^2$ term, meaning that there are $2$ ways in which the two of us can have taken $2$ type $3$ candies and nothing else. Each of the other terms in the product can be interpreted similarly. Thus, for $n=2$ and $m=3$ the desired generating function is
$$g(x_1,x_2,x_3)=(1+x_1^2+x_2^2+x_3^2)^2\;;$$
can you generalize these ideas now to get the generating function for $n$ people and $m$ types of candy?
