# Probability for machine learning and data science – Basic Probability 3 of 6

In this post we will look at Counting. This post is organised as follows

1. Basic rule of counting
2. Permutations
3. Combinations

### Basic rule of counting

Take k tasks such that task I has n_i ways of doing it, then the total number of ways of doing k tasks is

n_1 \times n_2 \times n_3 \times .... \times n_4

We will see this by using an example

Lets take my favourite biryani restaurant which sells the following

• 3 types of biryani
• 15 types of gravies
• 3 types of desserts

Now that I like biryani I need to choose 1 biryani, 1 gravy and 1 dessert. In how many ways can I do it?

let us break the problem in notation and do it. First we need to determine the k value

The k value for the problem is 3

k = 3

tasks with

n_1 = 3, n_2 = 15, n_3 = 3

So when using the formula above we have

3 \times 15 \times 3 = 135

So i can choose between 135 possible ways of my food.

Before we wrote

n_1 \times n_2 \times n_3 \times …. \times n_4

we can write this in product notation like this

\prod\limits_{i=1}^{k}n_i

### Permutations

A permutation is defined as the number of ways of ordering n distant objects taken r at a time

^n p_r = n(n-1)(n-2)...(n-r+1)

Factorials

Lets us revise what a factorial is

the notation n! called n factorial is defined as

n! = n(n-1)(n-2)... 2 \times 1

Factorial in product notation

\prod\limits_{i=0}^{n-1}(n-i)

Lets write the permutation formula again

^n p_r = n(n-1)(n-2)...(n-r+1) = \frac{n!}{(n-r)!}

### Combinations

The combination is dealing with when we take objects in which order does not matter.

Combinations can be calculated by using

\binom{n}{r} = \frac{n!}{r!(n-r)!}

You can read more about Counting, Permutations and Combinations from this book.

The topics covered in my posts are from this book.

Happy Learning

This post is made possible using LaTeX