0

I'm having a problem figuring out this problem, it is similar to combining sets of non-unique letters, but is slightly different.

Let k, m, and n be positive integers. We have nm balls, m colors, n balls, and k uniquely labeled bins. How many different ways are there to select n balls to put into the k bags?

For example, if m = 3, n = k = 2, the result is 21. There are 3 colors where we are choosing 2 balls out of the total 6 to place into 2 bins.

(-, WW), (-,WR), (-, WB) ...

(WW, -), (WR, -) ...

(W,W), (W,R) ...

(B,W), (B,R) ...

The normal version of this problem does not require the selection of a subset of the total elements. That problem yields n! / x1! x2! x3! ... where x1, x2, x3 are groups of duplicated letters.

correction (clarity) -> you have a total of nm balls. n balls of each color where there are m colors; from here you then choose n of these total nm balls randomly and place them into the k distinct bins.

Community
  • 1
  • 1
COner
  • 77
  • 1
  • 7

2 Answers2

0

Let me be sure I have the question right. We have m colors. We have k bins. We want to select n balls and place them in the bins. We have enough balls of each color that we don't have to worry about running out of any particular color.

In that case, the problem boils down to how many ways we have have n balls of m*k kinds. (A kind being determined by color and bin.) There is a standard trick to calculate this. First let's number the kinds. Put down all of the balls of the first kind. Then a divider. Then all the balls of the second kind. Then a divider. And so on until we have all n balls and k*m - 1 dividers down. This procedure is completely reversible, if we take n + k*m - 1 things in a row, select n of them to be balls and the rest to be dividers, we can then color the balls and put them into bins to get to n balls of m colors in k bins.

Therefore the answer is choose(n + k*m - 1, n).

(Note, this is the reasoning that I came up with after I knew the answer. My actual path to the answer was much longer and more circuitous.)

btilly
  • 43,296
  • 3
  • 59
  • 88
  • so just to clarify... a 'kind' is an arbitrary set of n balls that have been selected out of the total? – COner Mar 01 '11 at 04:41
  • @user636990 - A 'kind' is a color and bin. The idea is that red balls in the first bin are distinguishable from red balls in the second bin or blue balls in the first bin, but we don't distinguish between two balls of the same color in the same bin. – btilly Mar 01 '11 at 06:15
-1

I believe that you can treat this problem as m independent n-multicombinations.

So the answer is m * multichoose(n, k), where multichoose(a, b) = C(a + b -1, b).


Edit: This assumes you are asking about n balls of each color and placing all nm balls.

ThomasMcLeod
  • 7,603
  • 4
  • 42
  • 80
  • The problem you solved is very clearly not the problem asked. – btilly Feb 28 '11 at 16:40
  • @btilly, not so clearly, actually. In your answer, you are also making assumptions that are not stated in the question. Specifically, the question does not state there are the same number of balls of each color. My assumptions are just as valid as yours. – ThomasMcLeod Feb 28 '11 at 23:01
  • Compare your answer to the worked out example. With m = 3, n = 2, k = 2, only 2 balls get placed in the example, where your answer would require 6 balls placed. – btilly Mar 01 '11 at 00:48
  • @btilly, unfortunately the worked out example is not complete. You're still making assumptions. – ThomasMcLeod Mar 01 '11 at 03:42
  • I'm aware that my answer made assumptions, which is why my answer started off with a specific list of assumptions made. However I see no way to reconcile your answer with the problem as stated. – btilly Mar 01 '11 at 04:27