Application of the r-combination with repetition formula seems to fail

combinatoricsdiscrete mathematics

I was taught that the formula for r-combination with repetitions being allowed is

$${r + n -1 \choose r}$$

The intuition for that was the "Stars & Bars" method.

Based on this method, I took $r$ as the number of elements you choose and $n$ as the number of possible values an element can be.

This thought process seemed to work for 2 examples


Example #$1$:

There are $4$ stalls selling $1$ different food each(apple, banana, coke, nuggets). If
you are buying snacks for $20$ friends, how many different selections can you make?

Answer:
$r$(number of elements you choose) is $20$ here as we are choosing $20$ snacks for each of the friends. $n$(number of possible values an element can be) is $4$ as there as only $4$ stalls. Thus ${20 + 4 -1 \choose 20}$ works fine.


Example #$2$:

Choose $3$ numbers from ${1, 2, 3, 4}$.

Answer: $r$(number of elements you choose) is $3$ as we are choosing $3$ numbers.$n$(number of possible values an element can be) is $4$ as there as only $4$ numbers to choose from.Thus ${3 + 4 -1 \choose 3}$ works fine.


Now my thought process failed for this example, seen frequently on this SE:

How many solutions are there for $x_1 + x_2 + x_3 = 11$ where the $x_i$s are non-negative?

My wrong answer:$r$(number of elements you choose) is $3$ as we are choosing $3$ integers, $1$ for each $x$ from $11$ integers.$n$(number of possible values an element can be) is $11$ as there as $11$ possible integers to choose from. Obviously, ${3 + 11 -1 \choose 3}$ is wrong, $r$ is supposed to be $11$.


But why does my "thought" process fail for this example?


PS: How is $r$, $11$ in this case? Don't we only want to choose $3$ integers. All the solutions I see, treat $11$ as $r$ (ie the stars) which doesn't make sense as that would mean each star is of value $1$.

Best Answer

You should think of your final example as the number of ways to choose $11$ objects, each of which is of one of $3$ types: $x_1$ is the number of Type $1$ objects that you choose, $x_2$ the number of Type $2$ objects, and $x_3$ the number of Type $3$ objects that you select. Thus, you have $r=11$ and $n=3$. This is actually very similar to your example with the fruit.

I prefer a slightly different model: $r$ is the number of indistinguishable objects that you’re distributing amongst $n$ numbered containers. The $r$ objects are the stars, and the $n$ containers are the spaces between $n-1$ bars. This fits your last example very well, and it’s not hard to make it fit your other examples as well. In your first example the types of fruit are the containers: imagine labelling a jar with each of the types and distributing $20$ pebbles amongst the $4$ jars to describe a given selection. In your second example the containers are the numbers $1,2,3$, and $4$, and you’re distributing $3$ pebbles amongst those containers.