Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \section{D-separation algorithm.}
- Using the d-separation algorithm we want to prove that D(Good Diet) and F(Little Free Time) are conditionally independent, if W(Overweight) and R(Reduced Stress) are given.
- \subsection{First step: Draw the ancestral graph}
- \begin{center}
- \begin{tikzpicture}[
- node/.style={ellipse, draw=black!120, fill=gray!10, very thick, minimum size=14mm},
- ]
- %Nodes
- \node[node] (lft) {Little Free Time};
- \node[node] (ex) [below=of lft] {Exercise};
- \node[node] (gd) [right=of ex] {Good Diet};
- \node[node] (rs) [left=of hc] {Reduced Stress};
- \node[node] (ow) [right=of hc] {Overweight};
- %Lines
- \draw[->] (lft.south) -- (ex.north);
- \draw[->] (ex.south) -- (rs.north);
- \draw[->] (ex.south) -- (ow.north);
- \draw[->] (gd.south) -- (ow.north);
- \end{tikzpicture}
- \end{center}
- \subsection{Second step: Moralize}
- \begin{center}
- \begin{tikzpicture}[
- node/.style={ellipse, draw=black!120, fill=gray!10, very thick, minimum size=14mm},
- ]
- %Nodes
- \node[node] (lft) {Little Free Time};
- \node[node] (ex) [below=of lft] {Exercise};
- \node[node] (gd) [right=of ex] {Good Diet};
- \node[node] (rs) [left=of hc] {Reduced Stress};
- \node[node] (ow) [right=of hc] {Overweight};
- %Lines
- \draw[->] (lft.south) -- (ex.north);
- \draw[->] (ex.south) -- (rs.north);
- \draw[->] (ex.south) -- (ow.north);
- \draw[->] (gd.south) -- (ow.north);
- \draw[-] (gd.west) -- (ex.east);
- \end{tikzpicture}
- \end{center}
- \subsection{Third step: Disorient}
- \begin{center}
- \begin{tikzpicture}[
- node/.style={ellipse, draw=black!120, fill=gray!10, very thick, minimum size=14mm},
- ]
- %Nodes
- \node[node] (lft) {Little Free Time};
- \node[node] (ex) [below=of lft] {Exercise};
- \node[node] (gd) [right=of ex] {Good Diet};
- \node[node] (rs) [left=of hc] {Reduced Stress};
- \node[node] (ow) [right=of hc] {Overweight};
- %Lines
- \draw[-] (lft.south) -- (ex.north);
- \draw[-] (ex.south) -- (rs.north);
- \draw[-] (ex.south) -- (ow.north);
- \draw[-] (gd.south) -- (ow.north);
- \draw[-] (gd.west) -- (ex.east);
- \end{tikzpicture}
- \end{center}
- \subsection{Fourth step: Delete givens}
- \begin{center}
- \begin{tikzpicture}[
- node/.style={ellipse, draw=black!120, fill=gray!10, very thick, minimum size=14mm},
- ]
- %Nodes
- \node[node] (lft) {Little Free Time};
- \node[node] (ex) [below=of lft] {Exercise};
- \node[node] (gd) [right=of ex] {Good Diet};
- %Lines
- \draw[-] (lft.south) -- (ex.north);
- \draw[-] (gd.west) -- (ex.east);
- \end{tikzpicture}
- \end{center}
- \subsection{Results}
- \paragraph{} As the variables are connected, they are Bayes dependent. The result was verified using the implementation of the d-separation algorithm in Python.\footnote{Code of the algorithm:.https://github.com/lingxuez/bayes-net.}
- Inputs(number of nodes, edges, queries):
- \begin{center}
- \newline 6 6 1
- \newline F E
- \newline E R
- \newline E W
- \newline D W
- \newline E H
- \newline D H
- \newline D F \mid W R
- \end{center}
- \paragraph{} The output is: False. That means that D and F are not conditionally independent, confirming the above manual tracing of the algorithm.
- \section{Exact inference by enumeration.}
- \paragraph{}
- The probability that is going to be computed is the probability of having a good diet, given that the person is not overweight and has high cholesterol level.
- This algorithm uses the sums of hidden variables, which in this case are F(Little Free Time) and E(Exercise).
- Rewriting full joint entries using product of CPT entries:
- \[ P(D|\neg W, R) = \alpha * \sum_{F} \sum_{E} P(D, F, E, \neg W, R) \]
- \[ P(D|\neg W, R) = \alpha * \sum_{F} \sum_{E} P(D)* P(F) * P(E|F) * P(\neg W|D, E) * P(R|E) \]
- \[ = \alpha * P(D) * \sum_{F} \sum_{E} P(F) * P(E|F) * P(\neg W|D, E) * P(R|E) \]
- \[ = \alpha * P(D) * [ (P(F) * P(E|F) * P(\neg W|D, E) * P(R|E) + P(F) * P(\neg E|F) * P(\neg W|D, \neg E) * P(R|\neg E))\]
- \[+ (P(\neg F) * P(E|\neg F) * P(\neg W|D, E) * P(R|E) + P(\neg F) * P(\neg E|\neg F) * P(\neg W|D, \neg E) * P(R|\neg E))]\]
- \[ = \alpha * 0.4 * [0.8 * 0.1 * 0.95 * 0.95 + 0.8 * 0.9 * 0.15 * 0.45 + 0.2 * 0.7 * 0.95 * 0.95 + 0.2 * 0.3 * 0.15 * 0.45]\]
- \[ = \alpha * 0.4 * (0.0722 + 0.0486 + 0.12635 + 0.00405)\]
- \[ = \alpha * 0.4 * 0.2512 = \alpha * 0.10048 \]
- \[ P(\neg D|\neg W, R) = \alpha * \sum_{F} \sum_{E} P(\neg D, F, E, \neg W, R) \]
- \[ P(\neg D|\neg W, R) = \alpha * \sum_{F} \sum_{E} P(\neg D)* P(F) * P(E|F) * P(\neg W|\neg D, E) * P(R|E) \]
- \[ = \alpha * P(\neg D) * \sum_{F} \sum_{E} P(F) * P(E|F) * P(\neg W|\neg D, E) * P(R|E) \]
- \[ = \alpha * P(\neg D) * [ (P(F) * P(E|F) * P(\neg W|\neg D, E) * P(R|E) + P(F) * P(\neg E|F) * P(\neg W|\neg D, \neg E) * P(R|\neg E))\]
- \[+ (P(\neg F) * P(E|\neg F) * P(\neg W|\neg D, E) * P(R|E) + P(\neg F) * P(\neg E|\neg F) * P(\neg W|\neg D, \neg E) * P(R|\neg E))]\]
- \[ = \alpha * 0.6 * [0.8 * 0.1 * 0.35 * 0.95 + 0.8 * 0.9 * 0.99 * 0.45 + 0.2 * 0.7 * 0.35 * 0.95 + 0.2 * 0.3 * 0.99 * 0.45]\]
- \[ = \alpha * 0.6 * (0.0266 + 0.32076 + 0.04655 + 0.02673)\]
- \[ = \alpha * 0.6 * 0.42064 = \alpha * 0.252384 \]
- \[ \alpha = 1 / (0.10048 + 0.252384)\]
- \[ \alpha = 1 / 0.352864\]
- \[ P(D|\neg W, R) = 0.10048 / 0.352864 \approx 0.2847555\]
- The result can be verified in the output of seventh query from the listed code.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement