Monday 14 July 2014

Stars and Bars combinatorics




This is my second question on MSE, as my first one had format issues. So apologies for that!



I have a problem here.




How many ways can you distribute 4 balls into 3 boxes?




I would calculate $x_1 + x_2 + x_3 = 4$ (right?)

But further on, there is a fixed constraint on each of the variables, stating that only a maximum of $2$ is allowed in each box. (non negative allowed).
So I write, $$y_1 = x_1 - 2, y_2 = x_2 - 2, y_3 = x_3 - 2$$



This gives




$$x_1 - 2 + x_2 -2 + x_3 -2 = 4-2-2-2$$
$$y_1+y_2+y_3 = -2$$





I am stuck there. It gives a negative value, how will I be able to count for it? Please correct me and help if there are any problems!



Thank you so much! :)


Answer



So your example is to count the number of solutions $(x_1,x_2, x_3)$ to $$x_1 + x_2 +x_3 = 4 \text{ where } 0 \le x_i \le 2 \text{ for all } i$$



The generating function way to do this is to compute the coefficient of $x^4$ in $(1+x+x^2)^4 = x^6 + 3x^5 + 6x^4 + 7x^3 + 6x^2 + 3x + 1$,
which equals $6$ here.



Another way: count all solutions without maximum restrictions by stars and bars:
this gives $\binom{6}{2} = 15$. There are $3$ trivial ones with one $x_i =4$, the others $0$, which we subtract and also a few where some $x_i = 3$. (these options are mutually exclusive, and at most one can be equal to $3$) The last problem is equivalent to the remaining two variables summing to $1 = 4-3$, so there are $2$ solutions for fixed $x_i = 3$, and there are $3$ choices for the $x_i$, so $6$ solutions in all have this property. And $15 - 3 - 6 = 6$ agreeing with the first solution.



No comments:

Post a Comment

real analysis - How to find $lim_{hrightarrow 0}frac{sin(ha)}{h}$

How to find $\lim_{h\rightarrow 0}\frac{\sin(ha)}{h}$ without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...