Stars and Bars (and bagels) - Numberphile
Why Mathematics Stack Exchange recommends it
Mathematics Stack Exchange answerers and commenters link it when explaining or justifying the stars and bars method for counting distributions of identical objects, often as a friendlier explanation than the formula alone.
Recommended by 5 people across 5 different months, 2018 to 2021.
What it is
Numberphile video in which Berkeley mathematician Ken Ribet explains the stars and bars counting technique using a bagel-ordering problem. He shows how placing dividers among identical items counts the ways to distribute them into groups, and connects it to binomial coefficients.
What people said
Recommends The Room · 2018-12 · Mathematics Stack Exchange · on “Plain simple combinatorics formula vs. using polynomials for counting the number of balls which can be picked from a given set”
@MikeEarnest and Ned really appreciate your help. And for anyone reading this, and would want to learn more about Stars and Bars approach, here's a video for you : [this video]
Recommends yuvraj97 · 2019-05 · Mathematics Stack Exchange · on “A Question related to probability.”
Thanks for telling me about stars and bars. Previously I don't know about it but now I get it. A great explanation here [this video] Can you provide any research paper, journal or any article that explains it more mathematically.
Recommends Robert Z · 2019-06 · Mathematics Stack Exchange · on “How to place $k$ objects in $P$ boxes, such that many objects can be placed in one box”
Let $x_i$ be the number of objects in box $i$ with $i=1,\dots ,P$ . Then we have to count the number of non negative integer solutions, i.e. $x_i\geq 0$ , of $$x_1+x_2+\dots+x_{P-1}+x_P=k.$$ Which is the same (see Stars and Bars Thm 2 [LINK] ) to place $P-1$ bars $|$ which divides a sequence of $k+P-1$ stars $\underbrace{\star\star\dots \star\star}_{k+P-1}$ into $P$ blocks: $$ \binom{k+P-1}{P-1}=\binom{k+P-1}{k}.$$ A similar reasoning works when we have to count the number of positive integer solutions, i.e. $x_i\geq 1$ , (see Stars and Bars Thm 1 [LINK] ) which is given by $$\binom{k-1}{P-1}.$$ P.S. I recommend also the Numberphile's video Stars and Bars (and bagels) [this video] .
Recommends Luke Collins · 2019-08 · Mathematics Stack Exchange · on “Combinatorics problem: How many ways this row can be filled?”
Clearly we need $N\geqslant 2M-1$ , otherwise there are not enough grey blocks. Place the $M$ red blocks in a row, and interlace $M-1$ grey blocks between every two so that you have an alternating pattern: $${\color{red} R}{\color{gray} G}{\color{red} R}{\color{gray} G}\cdots{\color{gray} G}{\color{red} R}$$ Now you can insert the remaining $N-2M+1$ grey blocks in any of these spaces: $$\,\_\,{\color{red} R}\,\_\,{\color{gray} G}{\color{red} R}\,\_\,{\color{gray} G}\cdots{\color{red} R}\,\_\,{\color{gray} G}{\color{red} R}\,\_\,$$ There are $M+1$ such spaces (to the right of each $\color{red}R$ , plus the one at the front). We can choose were to put the grey blocks by "choosing" these spaces
Recommends K.defaoite · 2020-09 · Mathematics Stack Exchange · on “Ordering soups in a restaurant”
EDIT: This assumes the order in which the soup is bought is of no importance (not specified in the question.) Also I have changed the erroneous ${}_{2+9-1}\mathrm{C}_{2-1}$ to the correct ${}_{2+9-1}\mathrm{C}_{9-1}$ . Part A: We don't get to pick the flavors for the first four bowls of soup, so they don't need to be considered. For the remaining $2$ bowls of soup, we can choose every flavor except mushroom, since we need to have exactly four bowls of mushroom soup. That means we have $10-1=9$ choices for each of the remaining $2$ bowls of soup. Based on stars and bars , which is beautifully explained in this Numberphile video [this video] , we can say that the number of ways to select two bowls
Cites David Diaz · 2018-06 · Mathematics Stack Exchange · on “A student must pick 5 classes from 12 courses, if he must have at least one WH class or USH class, how many different choices does he have?”
We will take "At least one USH or WH" to mean that you could take all five courses from this set. This is odd, but it is the best semantic match for the question wording. If it is supposed to mean one or both, this approach wont work. In this case, the "stars and bars" [this video] technique applies. Ken Ribet is a better teacher than I. If you don't have time for a sixteen minute video, here's a summary: Your question can be reframed by asking how many ways can you toss k balls into n buckets. Or, how many ways can you insert n - 1 separators into a list of k potential courses. The spaces in between separators represent different buckets (potential courses). There are one fewer separators than b
Cites Luke Collins · 2019-06 · Mathematics Stack Exchange · on “Consider piles of red, blue, and green balls where each pile contains at least 10 balls...”
$\left(\!\binom nk\!\right)$ denotes the number of choosing $k$ out of $n$ things with repetition allowed, and order not important; it is given by $\binom{n+k-1}{k}$ . This is called multichoose [LINK] , and it's where the " $2-1$ " comes from. The Wikipedia article on Stars and Bars [LINK] is also helpful to understand this concept, there is a Numberphile video [this video] on YouTube too. Solution : There are red, blue and green balls. You can choose at most one red ball. Thus if you choose the red ball, then you have $9$ balls left to choose, basically which of them are blue, and which are green. This can be done in $\left(\!\binom29\!\right) = \binom{2+9-1}{9}=10$ ways. On the other hand, if
Cites Kaushik · 2021-04 · Mathematics Stack Exchange · on “In how many ways can you give out $12$ apples to $5$ unique children?”
If there is no restriction on how much each child should or should not get, then you can use the stars and bars method ( [this video] ) as @5201314 pointed out. What you basically do is divide the $12$ apples into $5$ groups (here, children) using $4$ dividers. Think of the apples and dividers as one entity. Place them in a row. You'll get $16$ of them. Now from that $16$, choose $4$ of them to be dividers. You can do that in $\binom{16}{4}$ ways. This is nothing but the number of unique distributions.