Essential Maths for ML – Part 2
In my last blog [Essential Maths for ML - Part 1] we have discussed about various type of events. In this blog let's discuss other important concepts related to probability.
1. Rules of probability
a. Addition Rule:
- If A and B are any two events that are not mutually exclusive events, then the probability of occurrence of either A or B is given by
P(A U B) = P(A) + P(B) - P(A ∩ B)
- If A and B are any two events that are mutually exclusive events, then the probability of occurrence of either A or B is given by
P(A U B) = P(A) + P(B)
b. Multiplication Rule:
- If A and B are two independent events then probability of occurrence of A and B is given by
P(A∩B) = P(A) * P(B)
Conditional Probability
Conditional probability of occurrence of event A given that event B has already occurred is denoted by P(A/B) where A and B are dependent events. Now probability of occurrence of event A and event B is given by
P(A∩B) = P(B) * P(A/B) so P(A/B) =P(A∩B) / P(B)
Let's also understand another important concept before we discuss some examples,
If there are total n samples and suppose we want to take out r items from the total samples then number of ways we can select r items is given by
nCr = (n!) /(r!) * (n-r)!
Now let's understand above concepts using some examples:
Ex1. A number is selected at random from the range 1 to 30, then what should be the probability of
a. Number is divisible by either 3 or 7
Consider A be the event that selected number divisible by 3 and B be the event that selected number is divisible by 7
Step 1: To calculate the number ways we can select the one number from the range given.
n(S) = 30 C 1 = 30 using this formula
Step 2: Now find the sample space for event A and event B.
A = {3,6,9,12,15,18,21,27,30}
so n(A) = 10
B = {7,14,21,28}
so n(B) = 4
n(A∩B) = {21} = 1
From the above steps it is clear that event A and B are not mutually exclusive events so the probability of occurrence of A or B will be given by
P(A U B) = P(A) + P(B) - P(A ∩ B)
P(A) = 10/30 P(B) = 4/30 and P(A ∩ B) = 1/30
P(A U B) = 13/30
b. Number is divisible by 5 or 13
Consider A be the event that selected number divisible by 5 and B be the event that selected number is divisible by 13
Step 1: To calculate the number ways we can select the one number from the range given.
n(S) = 30 C 1 = 30 using this formula
Step 2: Now find the sample space for event A and event B.
A = {5,10,15,20,25,30}
so n(A) = 6
B = {13,26}
so n(B) = 2
n(A∩B) = { } = 0
From the above steps it is clear that event A and B are not mutually exclusive events so the probability of occurrence of A or B will be given by
P(A U B) = P(A) + P(B) - P(A ∩ B)
P(A) = 6/30 P(B) = 2/30 and P(A ∩ B) = 0
P(A U B) = 8/30
Ex2: Suppose a box contains 5 red and 4 blue balls two balls are drawn at random from the box. Find the probability that both of them are red and balls are drawn one after another without replacement.
Let A be the event of drawing the red ball in first draw and B be the event of drawing the red ball in the second draw. Since we are not replacing first ball the sample space for second ball will be changed.
P(A) = 5/9 because we have to select red ball from 9 balls.
P(B/A) = 4/8 because we have to select red ball from 8 balls and only 4 red balls are left in the bag as we are not replacing the ball back.
So probability of occurring of event A and B will be :
P(A∩ B) = P(A) * P(B/A)
= 5/9 * 4/8 = 5/18
I hope you will find this blog useful and informative. In my next blog we will continue discussing the mathematical concepts required to understanding the machine learning models.
For doing practice of above concepts you can refer to
Please do not forget to follow me on my blog page.
Stay safe and healthy.
Nice Blog Thanks for sharing, useful information for us. Apply for online teaching jobs at home.
ReplyDelete