# Illustration of Binomial Coefficient

Say I have $$5$$ balls, each of a different colour, and want to pick $$3$$ of them. How many ways are there to do so?

This is a typical problem in any introduction course to statistics, and makes for a fun problem to tackle using visualisations. Hopefully this post leaves you with a little more intuition.

## A Typical Solution

The typical solution goes like this (see this thread for more details):

1. There are $$5$$ ways to pick the first ball.
2. After picking the first ball, there are only $$4$$ balls remaining. So there are $$4$$ ways to pick the second ball.
3. Repeating this logic, there are $$3$$ ways left to pick the third ball, and we can keep going on if we wanted.
4. We now have $$5 \times 4 \times 3 = 60$$ ways to pick $$3$$ balls, and this would be correct if the sequence that the balls were picked mattered. But since the sequence does not matter, we need to divide this number by the number of ways the $$3$$ balls could have been arranged.
5. So how many ways are there to arrange the $$3$$ balls? Well, we could use the same logic we applied above! We have $$3$$ ways to pick the first ball, $$2$$ to pick the second, and $$1$$ to pick the third. So there are $$3 \times 2 \times 1 =6$$ ways to arrange the $$3$$ balls.

And... we're done! There are $${5 \times 4 \times 3 \over 3 \times 2 \times 1} = {60 \over 6} = 10$$ ways to pick the balls. To make this solution a function of the total number of balls (denote as $$n$$) and the number of balls we want to pick (denote as $$r$$): $${n(n-1)...(n-r+1) \over r! }$$

Which is also equal to: $${n! \over {r!(n-r)!} }$$

This number is known as the binomial coefficient, because it is an important part of the binomial distribution. But this is all we need to know for now.

## Can we visualise this?

Well, you say, I follow the logic, but it's a little hard to picture in my head what's exactly going on. Can you help me visualise this?

Glad you asked! Let's start with Step 1 above: Pick the first ball. Well, clearly there are $$5$$ ways to do so.

Now let's pick the second ball. Remember, there were $$5$$ ways to pick the 1st ball, and for each of these, there are $$4$$ ways to pick the 2nd ball. So we have $$5 \times 4 = 20$$ options now.

Now let's pick the third ball. You should know the drill by now: for each of the $$20$$ options above, we have another $$3$$ ways to pick the 3rd ball. So we now have $$5 \times 4 \times 3 = 60$$ options and a screen full of balls!

If you look closely, you can see that there are many duplicates in the 60 options. In other words, the same 3 balls have been selected multiple times, just in different order. But we don't really care about the order, we just want to find unique ways to pick 3 balls! To find these duplicates, we sort the balls so that identical combinations are grouped together.

After sorting, we can see that there are actually only $$10$$ unique combinations, just that each combination is repeated $$6$$ times. There is only one thing left to do: eliminate all the duplicates to get the final answer: $$10$$!

It is important to remember that it is not by accident that each unique combination is repeated 6 times. This is simply the number of ways you can order 3 unique balls, i.e. $$3 \times 2 \times 1 = 3! = 6$$.

And there we have it - there are $$10$$ unique ways to choose 3 balls out of 5 balls.

## Back to the formula

Thankfully, we don't need all these balls everytime we calculate the binomial coefficient. We just need to apply the formula to calculate it: $${{n(n-1)...(n-r+1) \over r!} = {n! \over (n-r)!r!} }$$

But hopefully this visualisation has helped you gain some intuition on what's happening the next time you pull out that formula!