1

Say I have a bag, and I want to draw from it 5 balls, of colours Red, Blue and Green, and I care about the order (i.e. permutations) I draw them in.

As an example, lets say I have 20 Red Balls, 5 Blue balls and 3 Green balls. The number only really matters if it's fewer than the draws I have (i.e. it could have been 5 red balls).

The closest question I have found to this is: Counting permutation of duplicate items but that supposes that $p+q+r+⋯=n$ draws, but my example is $p+q+r+⋯>n$.

Trying to apply the formula there doesn't make sense to me:

$$\dfrac{n!}{p!q!r!\cdots}$$

Even if I 'clamp' the number of balls to the total number of draws, I get $p+q+r+⋯>n$, and I don't think I can follow the cancellation logic by setting $p=n$, using $\binom{a}{b}=\dfrac{a!}{b!(a-b)!}$. If I do, and $a=b$, then I simply get $\binom{a}{b}_{a=b}=\dfrac{a!}{a!} = 1$. Which is nonsense.

What am I missing, that would let me calculate this?

  • 3
    You can choose $5$ balls from $20$ red, $5$ blue and $5$ green balls and then subtract cases with $5$ green balls and $4$ green balls. – Math Lover Feb 01 '22 at 15:25
  • Also check Principle of Inclusion Exclusion and generating functions that would work more generally. – Math Lover Feb 01 '22 at 15:28
  • 1
    For handling $p+q+r+\dots>n$ you can calculate the number of options where you don't care and then subtract the number of ways you could have $p+q+r+\dots\leq n$. To handle $\leq$ rather than $=$... you can include a new category of ball corresponding to a void selection allowing you to describe it as an $=$ style problem like most others are. As for actually solving such a problem, stars-and-bars coupled with inclusion-exclusion or generating functions are going to be the usual go-to approaches. – JMoravitz Feb 01 '22 at 15:35
  • Are you asking for permutations, or simply combos of $5$ balls of different colors ? – true blue anil Feb 01 '22 at 16:00
  • @trueblueanil permutations, I'll make it clear in my question/tags – AncientSwordRage Feb 01 '22 at 16:06

2 Answers2

1

A quick way for your particular example: without restrictions on the colours there are $3^6= 243$ possibilities but $1$ has five green balls and ${5 \choose 1}\times 2=10$ have four green balls, making the answer $243-1-10=232$

A more general approach is related to exponential generating functions: the $\frac{n!}{p!q!r!\cdots}$ expression is the number of ways of arranging $n$ balls where $p$ are of one colour, $q$ of a second, $r$ of a third, etc. and $n=p+q+r+\cdots$. So somehow you want those $p!,q!,r!$ etc. appearing in the denominator and then sum over the different possibilities. You could for example find the coefficient of $x^n$ in the expansion of $$\left(\tfrac{x^0}{0!}+\tfrac{x^1}{1!}+\cdots+\tfrac{x^{20}}{20!}\right)\left(\tfrac{x^0}{0!}+\tfrac{x^1}{1!}+\cdots+\tfrac{x^5}{5!}\right)\left(\tfrac{x^0}{0!}+\tfrac{x^1}{1!}+\tfrac{x^2}{2!}+\tfrac{x^3}{3!}\right)$$ and then multiply this by $n!$. The expansion gives $$1+3x+\frac92x^2+\frac92x^3+\frac{10}{3}x^4+\frac{29}{15}x^5+\frac{131}{144}x^6+\cdots+\tfrac1{1751689445887180800000}x^{28}$$ and multiplying by the factorials gives $$1,3,9,27,80,232,655,\ldots,174053880$$ confirming the $232$ found earlier. $(655$ would have been the number of possibilities if you had wanted to draw $6)$

Henry
  • 169,616
  • I'm quite confused, but this feels close to helping me understanding a more general case. – AncientSwordRage Feb 01 '22 at 18:31
  • If there is any particular bit you are confused by, feel free to comment. For example taking $\tfrac{x^0}{0!}$ from the first bracket, $\tfrac{x^2}{2!}$ from the second, and $\tfrac{x^3}{3!}$ from the third and multiplying by $5!$ gives $\frac{5!}{0!2!3!}x^5=10x^5$ and says there are $10$ ways of ordering $0$ red, $2$ blue, $3$ green. – Henry Feb 01 '22 at 18:57
  • I get this better now, but I'm stuck at how we assign $n=p+q+r+...$ but can still use the generating function select fewer than $n$ balls. I'm guess it's because we're actually drawing a subset of balls, where n is actually 28, but k is 5... And the generating function gives a convenient way to do/write that? – AncientSwordRage Feb 05 '22 at 13:31
  • 1
    Roughly speaking that, yes. The exponential generating function actually tells you the answer for each possible number $n$ of balls drawn from the $28$, so $1$ when the number of balls drawn is $n=0$, and $3$ when $n=1$, and $9$ when $k=2$, ... and $174053880$ when $n=28$ – Henry Feb 05 '22 at 15:24
  • This is all very good, but I think I'm going to hit the issue that my actual problems might have the equivalent of hundreds of ball colours. Multiplying every one will be fruitless, but if I can just pick the ones that sum powers to 6 (1+1+1+3 etc..) it might be easier.... But then I'm back at combinations. – AncientSwordRage Feb 06 '22 at 14:38
0

With your clarification that you are asking for permutations, the formula will be

$5!(\frac1{5!0!0!} + \frac1{4!1!0!} + \frac1{4!0!1!} +... +\frac1{0!2!3!})$

$\frac1{5!0!0!}$ represents $5$ red, $0$ blue and $0$ green, etc down to $0$ red, $2$ blue and $3$ green

  • How do I calculate the summation for arbitrary numbers? – AncientSwordRage Feb 01 '22 at 18:28
  • 1
    For small cases, you can sum term by term leaving out inessential factorials $(1!,0!)$, thus $5!/5! + 2(5!/4!) + ...+ 5!/(2!3!).$ Otherwise, you can use exponential generating functions. Your problem is akin to, say finding the number of $6$ letter permutations of MISSISSIPPI which has been explained in layman terms at https://math.stackexchange.com/questions/20238/6-letter-permutations-in-mississippi – true blue anil Feb 01 '22 at 19:02