Skip to content

Commit

Permalink
more wip
Browse files Browse the repository at this point in the history
Pim-Mostert committed Oct 13, 2024

Verified

This commit was signed with the committer’s verified signature.
1 parent 15a1a7c commit bed51dc
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions docs/2. Complex Bayesian Network.md
Original file line number Diff line number Diff line change
@@ -768,25 +768,39 @@ graph TD

```math
\begin{align}
\begin{align*}
P(Q_1|\hat{Y}_1,\hat{Y}_2,\hat{Y}_3)
= & \frac{P(\hat{Y}_1,\hat{Y}_2,\hat{Y}_3|Q_1)P(Q_1)}{P(\hat{Y}_1,\hat{Y}_2,\hat{Y}_3)} \\
= & \frac{P(\hat{Y}_1,\hat{Y}_2,\hat{Y}_3|Q_1)P(Q_1)}{\sum\limits_{q_1}{P(\hat{Y}_1,\hat{Y}_2,\hat{Y}_3|Q_1)P(Q_1)}} \\
= & \frac{a_1(q_1)b_1(q_1)}{\sum\limits_{q_1}{a_1(q_1)b_1(q_1)}} \\
= & P(Q_1)\frac{P(\hat{Y}_1,\hat{Y}_2,\hat{Y}_3|Q_1)}{P(\hat{Y}_1,\hat{Y}_2,\hat{Y}_3)} \\
= & a_1(q_1)b_1(q_1) \\
P(Q_2|\hat{Y}_1,\hat{Y}_2,\hat{Y}_3)
= & \frac{P(\hat{Y}_1,\hat{Y}_2,\hat{Y}_3|Q_2)P(Q_2)}{P(\hat{Y}_1,\hat{Y}_2,\hat{Y}_3)} \\
= & \frac{P(\hat{Y}_1,\hat{Y}_2,\hat{Y}_3,Q_2)}{\sum\limits_{q_2}{P(\hat{Y}_1,\hat{Y}_2,\hat{Y}_3,Q_2)}} \\
= & \frac{P(\hat{Y}_2,\hat{Y}_3|Q_2)P(\hat{Y}_1, Q_2)}{\sum\limits_{q_2}P(\hat{Y}_2,\hat{Y}_3|Q_2)P(\hat{Y}_1, Q_2)} \\
= & \frac{a_5(q_2)b_5(q_2)}{\sum\limits_{q_2}{a_5(q_2)b_5(q_2)}} \\
\end{align}
= & \frac{P(\hat{Y}_2,\hat{Y}_3|Q_2,\hat{Y}_1)P(Q_2|\hat{Y}_1)}{P(\hat{Y}_2,\hat{Y}_3|\hat{Y}_1)} \\
= & \frac{P(\hat{Y}_2,\hat{Y}_3|Q_2)}{P(\hat{Y}_2,\hat{Y}_3|\hat{Y}_1)}P(Q_2|\hat{Y}_1) \\
= & a_5(q_2)b_5(q_2)
\end{align*}
```

The likelihood of the model can be obtained by summing all normalization factors corresponding to the local connections:

```math
\begin{align*}
P(\hat{Y}_1,\hat{Y}_2,\hat{Y}_3)
= & \frac{P(\hat{Y}_1,\hat{Y}_2,\hat{Y}_3)}{P(\hat{Y_1}|\hat{Y_2},\hat{Y_3})P(\hat{Y}_2,\hat{Y}_3|\hat{Y}_1)}P(\hat{Y}_1|\hat{Y}_2,\hat{Y}_3)\frac{P(\hat{Y}_2,\hat{Y}_3|\hat{Y}_1)}{P(\hat{Y}_2|\hat{Y}_3,\hat{Y}_1)P(\hat{Y}_3|\hat{Y}_2,\hat{Y}_1)}P(\hat{Y}_2|\hat{Y}_3,\hat{Y}_1)P(\hat{Y}_3|\hat{Y}_2,\hat{Y}_1) \\
= & c_1c_4c_5c_8c_9
\end{align*}
```

### Python example

HIER WAS IK GEBLEVEN

```python
import numpy as np

0 comments on commit bed51dc

Please sign in to comment.