3

Across this forum and external sources, I'm seeing two different formulas for "unordered sampling with replacement" and "stars and bars" combinatorics.

The first is $n+r-1 \choose r$, as suggested by https://math.stackexchange.com/a/923139/1510127, https://math.stackexchange.com/a/1894014/1510127, https://www.probabilitycourse.com/chapter2/2_1_4_unordered_with_replacement.php (though it later contradicts itself in a solution to a practice problem), and, more notably, Casella and Berger's Statistical Inference 2nd Edition, page 16. Casella and Berger, page 16

The second is $n+r-1 \choose r-1$, as suggested by Unordered Sampling With Replacement Intuition and, more notably, the official wikipedia article on stars and bars combinatorics.

Is there some nuance I'm missing out on? Are people using "unordered sampling with replacement" to refer to two different things?


**EDIT: thanks for the responses, everybody. What resolved my confusion was noting that in $n+r-1 \choose r$, $r$ refers to the size of a selection/sample, explicitly, thus framing the problem as a selection problem. Thus, an object being selected counts as a star. The sample space from which the selection is made is thus $n$, and this is the number of bins, 1 less of which is the number of bars.

OTOH, in $n+r-1 \choose r-1$, r refers to the number of bins, which you must then subtract 1 from to get the number of walls. Both use stars and bars, but, as alluded to below, the setup is different.**


1 Answers1

2

$\binom{n+r-1}{r}$ is correct, here is a classical explanation. Suppose we are unorderedly choosing $r$ out of $n$ distinct items with replacement, then each possibility is one-to-one corresponding to a non-negative solution $(x_1,\dots,x_n)$ of: $$ x_1+\dots+x_n=r$$ which is one-to-one corresponding to a positive solution $(y_1,\dots,y_n)$ (let $y_i:=x_i+1$) of: $$ y_1+\dots +y_n=n+r$$ There are $\binom{n+r-1}{n-1}=\binom{n+r-1}{r}$ of them. (There are $n+r$ stars, we need to choose $n-1$ out of $n+r-1$ bars.)

I think the example in the post Unordered Sampling With Replacement Intuition talks about a completely different thing but not unordered sampling with replacement.

Zoudelong
  • 1,721
  • 1
    Does it also follow that the Wikipedia article is also talking "about a completely different thing but not unordered sampling with replacement"? In other words, should I understand stars and bars as having to do with more than just the unordered sampling with replacement that you explain? Thank you! – slackbinhead Dec 14 '24 at 05:45
  • 3
    @lngsmnlrndn Contrast Zoudelong's answer with the enumeration of the number of solutions to $$x_1 + x_2 + \cdots + x_r = n,$$ which has $~\displaystyle \binom{n + r - 1}{r - 1}~$ solutions. – user2661923 Dec 14 '24 at 05:51
  • 1
    Yeah, they are talking about putting n indistinguishable balls into r distinguishable bins. As @user2661923 said, we should consider $x_1+\cdots+x_r=n$ instead. And stars and bars can help us solve many other similar problems. – Zoudelong Dec 14 '24 at 05:59