I came across two different formulas for the stars and bars problem which made me confused. Some say it is $n+k-1 \choose k$ (e.g. Number of ways of choosing $m$ objects with replacement from $n$ objects) and others say $n+k-1 \choose k-1$. I am confused as to which formula is the correct one? Thanks!
Asked
Active
Viewed 456 times
1 Answers
1
The number of $k$-tuples of non-negative integers summing to $n$ is $\binom{n+k-1}{n}=\binom{n+k-1}{k-1}$ (see here). For a proof note that with $n+k-1$ positions we choose which $k-1$ of them to fill with bars, while the rest get stars. My guess is that where you saw $\binom{n+k-1}{k}$ the definitions of $k,\,n$ have been exchanged, but double-check the sources you read.
J.G.
- 118,053
-
Thanks for the reply J.G. I still can't square the interpretation of the formula $n+k+1 \choose n$ from wikipedia and that from the link I shared even when we exchange the definition of $k$ and $n$. Could it be that the interpretation for both formulas are different? – Lydia Mar 20 '19 at 15:01
-
1@Lydia It is absolutely clear from the context that $m$ in the link you shared represents "stars" and $n-1$ represents the "bars". It is seen already from the phrase "a set of $$ distinct objects". You are misleaded by commutativity of summation (the freedom to interchange $n$ and $m$ in the expression $n+m-1$). – user Mar 20 '19 at 15:26
-
There is a very simple, effective discussion/proof of ${n+k+1 \choose k}$ in https://brilliant.org/wiki/integer-equations-star-and-bars/ – novice_2 Mar 22 '19 at 10:23
-
@amitava That's basically the proof I dedicated one sentence to. – J.G. Mar 22 '19 at 10:39
-
@J.G. You are right. I did not check that before. But let this link also be here, if not a problem. I somehow found the language is very simple with lots of example. – novice_2 Mar 22 '19 at 10:50