# Chapter 3: Conditional Probability and Independence


```python
%%html
<style>
.tableHeader{
    font-size:16px;
}

.eqn{
    font-size:16px;
    color:blue;
}
</style>
```


<style>
.tableHeader{
    font-size:16px;
}

.eqn{
    font-size:16px;
    color:blue;
}
</style>


---

## 3.2 Conditional probabilities
$P(A \mid B)$ refers to the conditional probability that **A** occurs given than **B** has occurred

If $P(B)>0$ then
<span class='eqn'>$$
P(A \mid B) = \frac{P(AB)}{P(B)} \implies P(AB) = P(B)P(A \mid B)
$$</span>

### The multiplication rule
<span class='eqn'>$$
P(A_1A_2A_3 \cdots A_n) = P(A_1)P(A_2 \mid A_1)P(A_3 \mid A_1A_2) \cdots P(A_n \mid A_1 \cdots A_{n-1})
$$</span>


---

## 3.3 Bayes's formula
Let **A** and **B** be events, We may express **A** as:
<span class='eqn'>$$A = AB \cup AB^\complement$$</span>
for, in order for an outcome to be in **A**, it must either be in both **A** and **B** or be in **A** but not in **B**.

### 3.3.1 Bayes
<span class='eqn'>\begin{align}
P(A) &= P(AB) + P(AB^\complement) \\
&= P(A \mid B)P(B) + P(A \mid B^\complement)P(B^\complement) \\
&= P(A \mid B)P(B) + P(A \mid B^\complement)[1-P(B)]
\end{align}</span>

### 3.3.2
<span class='eqn'>\begin{align}
P(B \mid A) &= \frac{P(BA)}{P(A)} \\
&= \frac{P(A \mid B)P(B)}{P(A \mid B)P(B) + P(A \mid B^\complement)[1-P(B)]}
\end{align}</span>

### Definition
<span class='eqn'>$$
\frac{P(A)}{P(A^\complement)} = \frac{P(A)}{1-P(A)}
$$</span>
The odds of an event **A** tell how much more likely it is that the event **A** occurs than it is that it does not occur

### 3.3.3
<span class='eqn'>$$
\frac{P(B \mid A)}{P(B^\complement \mid A)} = \frac{P(B)}{P(B^\complement)} \frac{P(A \mid B)}{P(A \mid B^\complement)}
$$</span>

### 3.3.4 1st Bayes
<span class='eqn'>\begin{align}
P(A) &= \sum_{i=1}^{n} P(AB_i) \\
&= \sum_{i=1}^{n} P(A \mid B_i)P(B_i)
\end{align}</span>

### 3.3.5 2nd Bayes
<span class='eqn'>\begin{align}
P(B_j \mid A) &= \frac{P(AB_j)}{P(A)} \\
&= \frac{P(A \mid B_i)P(B_i)}{\sum_{i=1}^{n} P(A \mid B_i)P(B_i)}
\end{align}</span>

---

bb8aa54acbf188a4b30551b457bfbd4dc4f20cd9
ipynb
Jupyter Notebook
a-first-course-in-probability/03-conditional-probability-and-independence.ipynb
Shawn-Ng/basic-statistics
712c08673614360d3a1c27d5b14c14d9e70d80de
BSD-2-Clause
a-first-course-in-probability/03-conditional-probability-and-independence.ipynb
Shawn-Ng/basic-statistics
712c08673614360d3a1c27d5b14c14d9e70d80de
BSD-2-Clause
a-first-course-in-probability/03-conditional-probability-and-independence.ipynb
Shawn-Ng/basic-statistics
712c08673614360d3a1c27d5b14c14d9e70d80de
BSD-2-Clause
Qwen/Qwen-72B
1. YES
2. YES