## STATS FOR DS

# Conditional Probability

--

The conditional probability of A given B (represented as P(A|B) ), is the probability of occurring event A given that event B has (or if ) occurred.

The Formula for calculating is P(A|B)=P(A∩B) / P(A). Let’s understand this formula with an example:

Let’s take the famous marbles in the bag example, we have 4 green and 3 red balls in the bag. What is the probability of drawing a green ball, when the first ball drawn is a red ball?

There are two events occurring in the question,

Event A: Drawing a red ball; Event B: Drawing a green ball.

Here, the probability of drawing a red ball is P(A)= 3/7, then the probability of drawing a green ball is P(B)= 4/6, And hence by the multiplicative rule of independent events:

P(A and B) =P(A)*P(B) =P(A)*P(B|A) =3/7*4/6 =12/42

≈0.2.

From the above conditional probability formula we get;

P(A∩B)=P(A)*P(B|A), now dividing both sides with P(A) (or sending P(A) to the other side)gives us,

`P(A∩B)/P(A) = P(B|A)*P(A)/ P(A)`

P(B|A) = P(A∩B)/P(A) or P(A|B) = P(A∩B)/ P(B)

P(A∩B) = P(B|A)*P(A) = P(A|B)*P(B)

**P(A|B) = P(B|A)*P(A) / P(B) ... Bayes Theorem**