![Page 1: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/1.jpg)
Placing balls in bins
![Page 2: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/2.jpg)
Problem of balls in bins
• Count the number of ways to place a collec4on A of m ≥ 1 balls into a collec4on B of n bins, n ≥ 1.
• Balls are labeled (dis4nguishable) or unlabeled (indis4nguishable)
• Bins are labeled (dis4nguishable) or unlabeled (indis4nguishable)
• Placement is either unrestricted, injec4ve (one-‐to-‐one) or surjec4ve (onto)
• We thus have 12 cases. However, we will ignore the situa4on when both the balls and the bins are unlabeled. Thus, effec4vely we will consider the other 9 case.
![Page 3: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/3.jpg)
What do we know from our earlier studies?
• The number of integer solu4ons to x1+x2+ …….. + xn = m when
• C(n+m-‐1,n-‐1) is also the number of combina4ons of selec4ng m elements with repe44ons from a set of n objects.
• This is the same problems as the problem of distribu4ng m pennies to n kids.
![Page 4: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/4.jpg)
What do we know from our earlier studies?
• The four types of func4ons f: A à B where |A|=m & |B|=n:
Figure 1
![Page 5: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/5.jpg)
9 cases
![Page 6: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/6.jpg)
A: m labeled balls; B: n labeled bins; Unrestricted placements
• Interpreta4ons: – Count the number of func4ons f: A à B. – We get one-‐to-‐one matching of ball plcements and func4on f by placing ball i into bin j if f(i)=j.
• Formula – Let g(m,n) denote the number of placements. Then g(m,n)=nm.
– When n=2, g(m,n)=2m. This number is the same as the number of binary strings of length m.
![Page 7: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/7.jpg)
A: m labeled balls; B: n labeled bins; one-‐to-‐one placements
• Interpreta4ons: – Count the number of injec4ve func4ons f: A à B.
• Formula – Let g(m,n) denote the number of placements. Then g(m,n)=n(n-‐1)(n-‐2)….(n-‐m+1) = P(m,n).
– When m > n, g(m,n)=0. • Addi4onal comments: – g(m,n)=n! when |A|=|B|. This func4on f on A is called a permuta4on.
– The Pigeonhole Principle states that there is no injec4on if m > n: for any func4on in such a case, there must be at least one bin (pigeonhole) with at least two balls (pigeons).
![Page 8: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/8.jpg)
A: m labeled balls; B: n labeled bins; onto placements
• Interpreta4ons: – Count the number of surjec4ve func4ons f: A à B.
• Formula – Let denote the number of placements. Then
• Addi4onal comments: – Why does this work? nm is the number of func4ons. We then remove the number of onto func4ons whose range has n-‐1 elements; n-‐2 elements; etc.
![Page 9: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/9.jpg)
A: m unlabeled balls; B: n labeled bins; unrestricted placements
• Interpreta4ons: – The number of integer solu4ons to x1+ … +xn=m, xi ≥ 0. – Distribu4ng n pennies to m kids, a kid may get 0 penny
• Let g(m,n) denote the number of placements. Then
![Page 10: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/10.jpg)
A: m unlabeled balls; B: n labeled bins; one-‐to-‐one placements
• Interpreta4ons: – Counts the number of subsets of {1,2, …, n} of size m.
• Let g(m,n) denote the number of placements. Then g(m,n) =
![Page 11: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/11.jpg)
• Interpreta4ons: – The number of integer solu4ons to x1+ … +xn=m, xi ≥ 1. – Distribu4ng n pennies to m kids, a kid may get at least 1 penny – Counts the number of ways of wri4ng m as a sum of n posi4ve integers where different orderings are counted as different.
• Let g(m,n) denote the number of placements. Then g(m,n) =
A: m unlabeled balls; B: n labeled bins; onto placements
![Page 12: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/12.jpg)
• Interpreta4ons:
A: m labeled balls; B: n unlabeled bins; unrestricted placements
![Page 13: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/13.jpg)
• Interpreta4ons (con4nued):
A: m labeled balls; B: n unlabeled bins; unrestricted placements (contd)
![Page 14: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/14.jpg)
• Formula:
A: m labeled balls; B: n unlabeled bins; unrestricted placements (contd)
![Page 15: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/15.jpg)
• Interpreta4on: Either you can do it (when m ≤ n) or you cannot do it when m > n.
• Count = 1 when m ≤ n, otherwise it is zero
A: m labeled balls; B: n unlabeled bins; one-‐to-‐one placements (contd)
![Page 16: Placingballsinbins - Simon Fraser Universitybinay/10114/BallsInBins.pdf · Problemofballsinbins • Countthe&number&of&ways&to&place&acollec4on&A&of&m&≥ 1&balls&into&acollec4on&B&of&n&bins,&n&≥1.&](https://reader033.vdocuments.us/reader033/viewer/2022042006/5e7031e8a684276e5f53db29/html5/thumbnails/16.jpg)
• Interpreta4ons: – Counts the number of par44ons of {1,2, …, m} into exactly n nonempty blocks.
• Formula: S(m,n) =
A: m labeled balls; B: n unlabeled bins; onto placements