**Prob and Stats**

# Comprehensive Guide on Combinations

*schedule*Aug 11, 2023

*toc*Table of Contents

*expand_more*

**mathematics behind data science**with 100+ top-tier guides

Start your free 7-days trial now!

Before we go through the mathematical definition of combinations, let's start with a motivating example.

# Number of possible combinations of choosing people

Suppose we must choose a group of $3$ out of a total of $5$ people. How many possible combinations are there?

Solution. Let's illustrate the scenario:

Here, we're referring to each person by their letter. One possible choice for the group is $\mathrm{ABC}$ and another is $\mathrm{ABD}$. However, we must make sure we don't double count, that is, if we've already counted the group $\mathrm{ABC}$, then we should not count the group $\mathrm{BAC}$ as another combination. This should make sense because groups $\mathrm{ABC}$ and $\mathrm{BAC}$ are identical - both groups have the same people in them. In fact, the word "combinations" in mathematics specifically means that the ordering of the elements within a group does not matter.

How should we go about counting all possible combinations without double counting? Our plan of attack is to count all possible permutations first and then remove the double counts.

Recall from our guide on permutations that the total number of ways to select a group of $3$ from $5$ people is:

The problem is that this number includes double counts. Our goal now is to discard these double counts. The key is to think about how many times we are counting each group. For instance, consider the group $\mathrm{ABC}$ - let's list all the permutations of $\mathrm{ABC}$ below:

```
ABC, ACB, BAC, BCA, CAB, CBA
```

We can use permutations once again to compute the number of arrangements, that is, $3!=6$. Because each group is counted $6$ times and we have $60$ groups (with duplicates), the total number of possible combinations (without duplicates) is:

Let's generalize this technique of counting combinations. Let $n$ be the number of distinct elements (e.g. people) and $r$ be the number of slots to fill. In our example, $n=5$ and $r=3$. The count of ordered elements is computed by permutation as:

If we plug in $n=5$ and $r=3$ as in our example, we would get \eqref{eq:wyoLmDM1wGk34IgoBTV}.

Next, we remove double counts by dividing \eqref{eq:rGaLX4K49ircyGf1BJO} by $r!$, which represents the number of ways to arrange any group:

Again, if we substitute $n=5$ and $r=3$ as in our example, we would get \eqref{eq:BlPvnZbjzvbGB7zIW9z}. What we have managed to derive here is the formula for combinations!

# Definition and formula for combinations

Combination refers to the number of ways of selecting $r$ elements from a total of $n$ elements without regard to order:

The left side is read as "n choose r".

# Difference between permutations and combinations

The main difference between permutations and combinations is that permutations are concerned with the ordering of the chosen elements whereas combinations are not.

For instance, the number of permutations of selecting two distinct letters from $\mathrm{A}$, $\mathrm{B}$ and $\mathrm{C}$ is:

On the other hand, the number of combinations for the same task is:

The formulas for permutations and combinations look similar, and in fact, combinations can be computed from permutations:

As we can see, computing combinations involves an additional step of removing double counts by dividing by the number of arrangements of any selection ($2!$ in this case). This also means that permutations must always be equal to greater than combinations for the same task.

Let's now go through some examples of applying the formula for combinations!

# Examples

## Number of combinations drawing balls

Suppose we have $8$ balls in a bag, of which $3$ are red and $5$ are green. How many possible combinations are there for choosing $2$ red and $4$ green balls?

Solution. The number of combinations of choosing $2$ red balls from $3$ red balls is:

Here, the ordering of the red balls does not matter. For instance, if we label the balls as $\color{red}\mathrm{R}_1$, $\color{red}\mathrm{R}_2$ and $\color{red}\mathrm{R}_3$, then $\color{red}\mathrm{R}_1\color{red}\mathrm{R}_2$ is the same as $\color{red}\mathrm{R}_2\color{red}\mathrm{R}_1$. This is the reason why we use combinations instead of permutations here.

The number of combinations of choosing $4$ green balls from $5$ green balls is:

The total possible number of combinations is their product, that is, $3\times5=15$.

## Number of diagonals of a hexagon (optional)

How many diagonals does a hexagon have?

Solution. Each vertex of a hexagon has $3$ diagonals:

Since a hexagon has $6$ vertices, the total number of diagonals is:

However, this number is misleading because we are double counting the diagonals. For instance, the diagonals from vertex $\mathrm{E}$ are:

Here, the diagonal $\mathrm{AE}$ is counted once again. Therefore, even though there are $18$ ordered diagonals, **half** of them are duplicated. Therefore the total number of unique diagonals is:

Even though this question does not use the combinations formula, the main idea is the same - we first compute the total number of permutations and then remove duplicates by division.