# Math Background

Lesson 4 Chapter 2

To tackle and solve the probability problem, there is always a need to * count how many elements available in the event and sample space*. Here, we discuss some important counting principles and techniques.

**Get the source code for this lesson**

## Counting all possible outcomes

Let's consider the special case of having two experiments as and . The basic principle states that if one experiment () results in N possible outcomes and if another experiment () leads to M possible outcomes, then conducting the two experiments will have possible outcome, in total. Assume experiment has M possible outcomes as and has N possible outcomes as .

It is easy to **prove** such a principle for its special case. All you need in to **count all possible outcomes** of two experiments:

The generalized principle of counting can be expressed as below:

**Generalized Basic Principle of Counting**

## Permutation

* What is a permutation?* Suppose we have three persons called Michael, Bob, and Alice. Assume the

*three of them stay in a queue*. How many possible arrangements we have? Take a look at the arrangements as follows:

As above, you will see *six** permutations*. Right? But, we cannot always write all possible situations! We need some math. The intuition behind this problem is that we have *three places* to fill in a queue when we have three persons. **For the first place**, we have three choices. **For the second place**, there are two remaining choices. **Finally**, there is only one choice left for last place! So we can extend this conclusion to the experiment that we have choices. Hence, we get the following number of permutations:

which you can compute by Python as below:

## Combination

The **combination** stands for different combinations of objects from a larger set of objects. For example, assume we have a total number of objects. ** With how many ways can we select objects from that objects?** Let's get back to the above examples. Assume we have

**three candidates**named Michael, Bob, and Alice, and we

*o*

**nly desire to select two****candidates**. How many different combinations of candidates exist?

Let's get back to the general question: How many selections we can have if we desire to pick objects from objects?

**Combination**

The above definition can be generalized.