Conditonal Probability and Bayes theorem are two of the most important foundational concepts of probability which are used extensively in machine learning algorithms. Let us revise the basic mathematical treatment of those concepts and try to solve some problems.

Conditional probability of events A and B `P(A\mid B) = \frac{P(A\cap B)}{P(B)}`

Bayes Theorem

```
\begin{aligned}
P(A \mid B) &= \frac{P(A\cap B)}{P(B)}, \text{ if } P(B) \neq 0, \\
P(B \mid A) &= \frac{P(B\cap A)}{P(A)}, \text{ if } P(A) \neq 0, \\
\Rightarrow P(A\cap B) &= P(A\mid B)\times P(B)=P(B\mid A)\times P(A), \\
\Rightarrow P(A \mid B) &= \frac{P(B \mid A) \times P(A)} {P(B)}, \text{ if } P(B) \neq 0.
\end{aligned}
```

**A couple has two children, the older of which is a boy. What is the probability that they have two boys?**

```
\begin{aligned}
P(B) &= Older one is boy \\
P(A) &= Two boys \\
\\
\\
P(A|B) &= \frac{P(B/A) P(A)}{P(B)} \\
&=\frac{P(older~one~is~boy~given~two~boys) * P(having~two~boys)}{P(older~one~is~boy)} \\
Given Fact, \\
P(older~one~is~boy~given~two~boys) &= 1 \\
P(A|B) &= \frac{1 * 1/2*1/2}{1/2} \\
&= 1/2
\end{aligned}
```

**A couple has two children, one of which is a boy. What is the probability that they have two boys?**

```
\begin{aligned}
A &= having two boys\\
B &= one child is a boy\\
\\
\\
P(one~child~boy) &= 1-P(both~children~not~boys)\\
&= 1- 1/4 \\
&= 3/4\\
P(having~two~boys~given~one~child~boy) &= \frac{P(one~child~is~boy~gicen~both~children~boys) * P(both~children~boys)}{P(one~child~boy)} \\
&=\frac{1 * 1/4}{3/4} \\
&= 1/3\\
\end{aligned}
```

**A family has two children. Given that one of the children is a boy, and that he was born on a Tuesday, what is the probability that both children are boys?**

```
\begin{aligned}
P(BB) &= Probablity~of~having~both~boys~of~two~children \\
P(B) &= Probablity~of~having~one~boy~of~two~children\\
P(BT) &= probablity~of~having~a~boy~born~on~Tuesday \\
\\
P(BB|BT) &= \frac{P(BT|BB) *P(BB)}{ P(BT)} \\
P(BT|BB) &=P(having~boy~born~on~Tuesday~given~both~children~are~boys) \\
P(BT|BB) &=P(Either~of~two~can~be~boy~~born~on~Tuesday~given~both~boys) \\
\\
P(BT|BB) &= 1- P(boys~born~on~other~days)\\
&=1-6/7*6/7 \\
&= 1-36/49 = 13/49\\
\\
P(BB) &= 1/2*1/2 = 1/4 \\
\\
P(BT) &= P(one~of~the~child~is~a~boy~born~on~Tuesday) \\
&=1-P((both~boys~born~on~non-Tuesdays) + both~girl) \\
&= 1- 13/14 * 13/14 \\
&= 1- 169 /196 = 27/196\\
\\
P(BB|BT) &= P(BT|BB) *P(BB)/ P(BT) \\
&= 13/49 * 1/4 / 27/196 \\
&=13/49 * 1/4 * 196 /27 \\
&= 13/27
\end{aligned}
```

**Balls numbered 1 through 20 are placed in a bag. Three balls are drawn out of the bag without replacement. What is the probability that all the balls have odd numbers on them**

Three balls drawn with out replacement

Total Probability = P(1st ball) * P(2nd ball) * P(3rd ball)

**= 10/20 9/19 8/18**