\documentclass[pdf,bndg,slideColor,colorBG]{prosper}

\input{preamble}

\title{Bayesian Networks and Decision Graphs}
\subtitle{}
\author{}
\email{}
\institution{Chapter 1}
\slideCaption{Chapter 1}


\begin{document}
\maketitle

%####################################################################################
%# Two perspectives on probability theory
%####################################################################################

\PDForPS{
\overlays{2}{
\begin{slide}{Two perspectives on probability theory}
\fromSlide{1}{
In many domains, the probability of an outcome is interpreted as a
\Red{relative frequency}:
\begin{itemize}
\item The probability of getting a three by throwing a six-sided die
  is $1/6$. 
\end{itemize}
\ \\
\ \\

However, we often talk about the probability of an event without being
able to specify a frequency for it:
\begin{itemize}
\item What is the probability that Denmark wins the world cup in 2010?
\end{itemize}

\begin{center}
\fbox{Such probabilities are called \Blue{subjective probabilities}}
\end{center}
}
\fromSlide{2}{
\ \\
\ \\
\ \\
\ \\

\underline{Possible interpretation:}
\begin{minipage}[t]{0.9\linewidth}
\begin{tabular}{p{0.6\linewidth}p{0.4\linewidth}}
\begin{minipage}[t]{\linewidth}
\begin{itemize}
\item I receive Dkr $1000$ if Denmark wins.
\item If I draw a red ball I receive Dkr $1000$.
\end{itemize}
\end{minipage}
&
\begin{minipage}{\linewidth}      
\scalebox{0.6}{
  \input{\figpath/l1-example13.pstex_t} 
} \\
\end{minipage}
    



\end{tabular}
\end{minipage}
}
\end{slide}}
}
{
\begin{slide}{Subjective probabilities}

In many domains, the probability of an outcome is interpreted as a
\Red{relative frequency}:
\begin{itemize}
\item The probability of getting a three by throwing a six-sided die
  is $1/6$. 
\end{itemize}
\ \\
\ \\

However, we often talk about the probability of an event without being
able to specify a frequency for it:
\begin{itemize}
\item What is the probability that Denmark wins the world cup in 2010?
\end{itemize}

\begin{center}
\fbox{Such probabilities are called \Blue{subjective probabilities}}
\end{center}
\ \\
\ \\
\ \\
\ \\

\underline{Possible interpretation:}
\begin{minipage}[t]{0.9\linewidth}
\begin{tabular}{p{0.6\linewidth}p{0.4\linewidth}}
\begin{minipage}[t]{\linewidth}
\begin{itemize}
\item I receive Dkr $1000$ if Denmark wins.
\item If I draw a red ball I receive Dkr $1000$.
\end{itemize}
\end{minipage}
&
 \begin{minipage}{\linewidth}      
\scalebox{0.6}{
  \input{\figpath/l1-example13.pstex_t} 
} \\
\end{minipage}
    

\end{tabular}
\end{minipage}



\end{slide}}



%####################################################################################
%# Basic probability axioms
%####################################################################################

\PDForPS{
\overlays{3}{
\begin{slide}{Basic probability axioms}
\fromSlide*{1}{
The set of possible outcomes of an ``experiment'' is called the
\Red{sample space} $\Red{\mathcal{S}}$:
\begin{itemize}
\item Throwing a six sided die: $\{1,2,3,4,5,6\}$.
\item Will Denmark win the world cup: $\{$yes,no$\}$.
\item The values in a deck of cards: $\{2,3,4,5,6,7,8,9,10,J,Q,K,A\}$.
\end{itemize}
}
\fromSlide*{2}{
\ \\
\ \\

An \Red{event} $\Red{\mathcal{E}}$ is a subset of the sample space:
\begin{itemize}
\item The event that we will get an even number when throwing a die:
  $\{2,4,6\}$.
\item The event that Denmark wins: $\{$yes$\}$.
\item The event that we will get a $6$ or below when drawing a card: $\{2,3,4,5,6\}$. 
\end{itemize}
}
\fromSlide*{3}{
\ \\
\ \\

We measure our uncertainty about an experiment by assigning
probabilities to each event. The probabilities must obey the following \Green{axioms}:



\begin{minipage}[b]{0.65\linewidth}
\begin{itemize}
\item $P(\Red{\mathcal{S}})=1$.
\item For all events $\Red{\mathcal{E}}$ it holds that
  $P(\Red{\mathcal{E}})\geq 0$.
\item If $\Red{\mathcal{E}_1}\cap \Blue{\mathcal{E}_2}=\emptyset$, then
  $P(\Red{\mathcal{E}_1}\cup \Blue{\mathcal{E}_2})=P(\Red{\mathcal{E}_1})+P(\Blue{\mathcal{E}_2})$.
\end{itemize}
\end{minipage}
 \begin{minipage}[t]{0.3\linewidth}      
{\psfrag{|E1}[c]{$\mathcal{E}_1$}
\psfrag{|E2}[c]{$\mathcal{E}_2$}
\psfrag{|S}[c]{$\mathcal{S}$}
      \includegraphics[scale=0.6]{\figpath/venn.eps} }
\end{minipage}



}

\end{slide}
}
}
{
\begin{slide}{Basic probability axioms}
The set of possible outcomes of an ``experiment'' is called the
\Red{sample space} $\Red{\mathcal{S}}$:
\begin{itemize}
\item Throwing a six sided die: $\{1,2,3,4,5,6\}$.
\item Will Denmark win the world cup: $\{$yes,no$\}$.
\item The values in a deck of cards: $\{2,3,4,5,6,7,8,9,10,J,Q,K,A\}$.
\end{itemize}
\ \\
\ \\

An \Red{event} $\Red{\mathcal{E}}$ is a subset of the sample space:
\begin{itemize}
\item The event that we will get an even number when throwing a die:
  $\{2,4,6\}$.
\item The event that Denmark wins: $\{$yes$\}$.
\item The event that we will get a $6$ or below when drawing a card: $\{2,3,4,5,6\}$. 
\end{itemize}
\ \\
\ \\

We measure our uncertainty about an experiment by assigning
probabilities to each event. The probabilities must obey the following \Blue{axioms}:


\begin{minipage}[b]{0.65\linewidth}
\begin{itemize}
\item $P(\Red{\mathcal{S}})=1$.
\item For all events $\Red{\mathcal{E}}$ it holds that
  $P(\Red{\mathcal{E}})\geq 0$.
\item If $\Red{\mathcal{E}_1}\cap \Blue{\mathcal{E}_2}=\emptyset$, then
  $P(\Red{\mathcal{E}_1}\cup \Blue{\mathcal{E}_2})=P(\Red{\mathcal{E}_1})+P(\Blue{\mathcal{E}_2})$.
\end{itemize}
\end{minipage}
 \begin{minipage}[t]{0.3\linewidth}      
{\psfrag{|E1}[c]{$\mathcal{E}_1$}
\psfrag{|E2}[c]{$\mathcal{E}_2$}
\psfrag{|S}[c]{$\mathcal{S}$}
      \includegraphics[scale=0.6]{\figpath/venn.eps} }
\end{minipage}


\end{slide}
}

%####################################################################################
%# Conditional probabilities
%####################################################################################

\begin{slide}{Conditional probabilities}
Every probability is conditioned on a \underline{\Red{context}}. For
example, if we throw a dice:\newline
\begin{center}
``$P(\Red{\{\text{six}\}})=\frac{1}{6}$'' = ``$P(\Red{\text{six}}|\Red{\text{symmetric
dice}})=\frac{1}{6}$''.\newline
\end{center}

In general, if $\Red{\mathcal{A}}$ and $\Red{\mathcal{B}}$ are events and
$P(\Red{\mathcal{A}}|\Red{\mathcal{B}})=x$, then:
\begin{center}
``In the context of $\Red{\mathcal{B}}$ we have that $P(\Red{\mathcal{A}})=x$''\newline
\end{center}

\underline{\Red{Note:}} It is \underline{not} ``whenever
$\Red{\mathcal{B}}$ we have $P(\Red{\mathcal{A}})=x$'', but rather:
if $\Red{\mathcal{B}}$ and everything else known is irrelevant to $\Red{\mathcal{A}}$, then
$P(\Red{\mathcal{A}})=x$. \newline

\underline{\Blue{Definition:}} For two events $\Red{\mathcal{A}}$ and
$\Red{\mathcal{B}}$ we have:
\[
P(\Red{\mathcal{A}}|\Red{\mathcal{B}})=\frac{P(\Red{\mathcal{A}}\cap\Red{\mathcal{B}})}{P(\Red{\mathcal{B}})}
\]
\underline{\Blue{Example:}}
 \[
P(\Red{\mathcal{A}}=\{4\}|\Red{\mathcal{B}}=\{2,4,6\})=\frac{P(\Red{\mathcal{A}}\cap\Red{\mathcal{B}}=\{4\})}{P(\Red{\mathcal{B}}=\{2,4,6\})}=\frac{1/6}{3/6}=\frac{1}{3}.
\]

\end{slide}



%####################################################################################
%# Basic probability calculus: the fundamental rule
%####################################################################################

\begin{slide}{Basic probability calculus: the fundamental rule}

Let $\Red{\mathcal{A}}$, $\Red{\mathcal{B}}$ and $\Red{\mathcal{C}}$ be events.\newline

\underline{\Blue{The fundamental rule:}} $P(\Red{\mathcal{A}} \cap \Red{\mathcal{B}})=P(\Red{\mathcal{A}}|\Red{\mathcal{B}})P(\Red{\mathcal{B}})$.\newline

\underline{\Blue{The fundamental rule, conditioned:}} $P(\Red{\mathcal{A}} \cap
\Red{\mathcal{B}}|\Red{\mathcal{C}})=P(\Red{\mathcal{A}}|\Red{\mathcal{B}}\cap\Red{\mathcal{C}})P(\Red{\mathcal{B}}|\Red{\mathcal{C}})$.\newline
\newline \newline

\underline{\Blue{Proof:}} Derived directly from the definition of
conditional probability.


\end{slide}


%####################################################################################
%# Basic probability calculus: Bayes' rule
%####################################################################################

\begin{slide}{Basic probability calculus: Bayes' rule}

\underline{\Blue{Bayes rule:}} 
\[
P(\Red{\mathcal{B}}|\Red{\mathcal{A}})=\frac{P(\Red{\mathcal{A}}|\Red{\mathcal{B}})P(\Red{\mathcal{B}})}{P(\Red{\mathcal{A}})}
\]

\underline{\Blue{Proof:}} 
\[
P(\Red{\mathcal{B}}|\Red{\mathcal{A}})P(\Red{\mathcal{A}})=P(\Red{\mathcal{B}}\cap
\Red{\mathcal{A}})=P(\Red{\mathcal{A}}|\Red{\mathcal{B}})P(\Red{\mathcal{B}})
\]


\underline{\Blue{Bayes rule, conditioned:}} 
\[
P(\Red{\mathcal{B}}|\Red{\mathcal{A}}\cap\Red{\mathcal{C}})=\frac{P(\Red{\mathcal{A}}|\Red{\mathcal{B}}\cap\Red{\mathcal{C}})P(\Red{\mathcal{B}}|\Red{\mathcal{C}})}{P(\Red{\mathcal{A}}|\Red{\mathcal{C}})}
\]

\underline{\Blue{Example:}} We have two diseases $\Red{\mathcal{A}_1}$
and $\Red{\mathcal{A}_2}$ that are the \Blue{only} diseases that can cause the symptoms
$\Red{\mathcal{B}}$.  If 
\begin{itemize}
\item $\Red{\mathcal{A}_1}$ and
$\Red{\mathcal{A}_2}$ are equally likely
($P(\Red{\mathcal{A}_1})=P(\Red{\mathcal{A}_2})$)
\item $P(\Red{\mathcal{B}}|\Red{\mathcal{A}_1})=0.9$
\item $P(\Red{\mathcal{B}}|\Red{\mathcal{A}_2})=0.3$
\end{itemize}
what are then the
probabilities $P(\Red{\mathcal{A}_1}|\Red{\mathcal{B}})$ and $P(\Red{\mathcal{A}_2}|\Red{\mathcal{B}})$?   


\end{slide}

%####################################################################################
%# Basic probability calculus
%####################################################################################

\PDForPS{
\overlays{2}{
\begin{slide}{Basic probability calculus}
\fromSlide{1}{
Let $\Red{\mathcal{A}}$, $\Red{\mathcal{B}}$ and $\Red{\mathcal{C}}$ be events.\newline

\underline{\Purple{Conditional probability:}} 
$
P(\Red{\mathcal{A}}|\Red{\mathcal{B}})=\frac{P(\Red{\mathcal{A}}\cap\Red{\mathcal{B}})}{P(\Red{\mathcal{B}})}
$\newline \newline

\underline{\Red{The fundamental rule:}} $P(\Red{\mathcal{A}} \cap \Red{\mathcal{B}})=P(\Red{\mathcal{A}}|\Red{\mathcal{B}})P(\Red{\mathcal{B}})$.\newline

\underline{\Red{The conditional fundamental rule:}} $P(\Red{\mathcal{A}} \cap
\Red{\mathcal{B}}|\Red{\mathcal{C}})=P(\Red{\mathcal{A}}|\Red{\mathcal{B}}\cap\Red{\mathcal{C}})P(\Red{\mathcal{B}}|\Red{\mathcal{C}})$.\newline
\newline \newline}
\fromSlide{2}{
\underline{\Blue{Bayes rule:}} $P(\Red{\mathcal{B}}|\Red{\mathcal{A}})=\frac{P(\Red{\mathcal{A}}|\Red{\mathcal{B}})P(\Red{\mathcal{B}})}{P(\Red{\mathcal{A}})}$. \newline

\underline{\Blue{Proof:}} $P(\Red{\mathcal{B}}|\Red{\mathcal{A}})P(\Red{\mathcal{A}})=P(\Red{\mathcal{B}}\cap \Red{\mathcal{A}})=P(\Red{\mathcal{A}}|\Red{\mathcal{B}})P(\Red{\mathcal{B}})$.\newline

\underline{\Blue{Bayes rule, conditioned:}} $P(\Red{\mathcal{B}}|\Red{\mathcal{A}}\cap\Red{\mathcal{C}})=\frac{P(\Red{\mathcal{A}}|\Red{\mathcal{B}}\cap\Red{\mathcal{C}})P(\Red{\mathcal{B}}|\Red{\mathcal{C}})}{P(\Red{\mathcal{A}}|\Red{\mathcal{C}})}$.\newline\newline\newline

\underline{\Green{Conditional independence:}} If
$P(\Red{\mathcal{A}}|\Red{\mathcal{B}}\cap\Red{\mathcal{C}})=P(\Red{\mathcal{A}}|\Red{\mathcal{C}})$ then $P(\Red{\mathcal{A}}\cap
\Red{\mathcal{B}}|\Red{\mathcal{C}})=P(\Red{\mathcal{A}}|\Red{\mathcal{C}})\cdot P(\Red{\mathcal{B}}|\Red{\mathcal{C}})$.
}
\end{slide}}
}
{
\begin{slide}{Basic probability calculus}

Let $\Red{\mathcal{A}}$, $\Red{\mathcal{B}}$ and $\Red{\mathcal{C}}$ be events.\newline

\underline{\Purple{Conditional probability:}} 
$
P(\Red{\mathcal{A}}|\Red{\mathcal{B}})=\frac{P(\Red{\mathcal{A}}\cap\Red{\mathcal{B}})}{P(\Red{\mathcal{B}})}
$\newline \newline

\underline{\Red{The fundamental rule:}} $P(\Red{\mathcal{A}} \cap \Red{\mathcal{B}})=P(\Red{\mathcal{A}}|\Red{\mathcal{B}})P(\Red{\mathcal{B}})$.\newline

\underline{\Red{The conditional fundamental rule:}} $P(\Red{\mathcal{A}} \cap
\Red{\mathcal{B}}|\Red{\mathcal{C}})=P(\Red{\mathcal{A}}|\Red{\mathcal{B}},\Red{\mathcal{C}})P(\Red{\mathcal{B}}|\Red{\mathcal{C}})$.\newline \newline

\underline{\Blue{Bayes rule:}} $P(\Red{\mathcal{B}}|\Red{\mathcal{A}})=\frac{P(\Red{\mathcal{A}}|\Red{\mathcal{B}})P(\Red{\mathcal{B}})}{P(\Red{\mathcal{A}})}$. \newline

\underline{\Blue{Proof:}} $P(\Red{\mathcal{B}}|\Red{\mathcal{A}})P(\Red{\mathcal{A}})=P(\Red{\mathcal{B}}\cap \Red{\mathcal{A}})=P(\Red{\mathcal{A}}|\Red{\mathcal{B}})P(\Red{\mathcal{B}})$.\newline

\underline{\Blue{Bayes rule, conditioned:}} $P(\Red{\mathcal{B}}|\Red{\mathcal{A}},\Red{\mathcal{C}})=\frac{P(\Red{\mathcal{A}}|\Red{\mathcal{B}},\Red{\mathcal{C}})P(\Red{\mathcal{B}}|\Red{\mathcal{C}})}{P(\Red{\mathcal{A}}|\Red{\mathcal{C}})}$.\newline

\underline{\Green{Conditional independence:}} If
$P(\Red{\mathcal{A}}|\Red{\mathcal{B}},\Red{\mathcal{C}})=P(\Red{\mathcal{A}}|\Red{\mathcal{C}})$ then $P(\Red{\mathcal{A}}\cap
\Red{\mathcal{B}}|\Red{\mathcal{C}})=P(\Red{\mathcal{A}}|\Red{\mathcal{C}})\cdot P(\Red{\mathcal{B}}|\Red{\mathcal{C}})$.

\end{slide}}



%####################################################################################
%# Probability calculus for variables
%####################################################################################

\begin{slide}{Probability calculus for variables}

\Blue{$A$} is a variable with states \Blue{$a_1,\ldots ,a_n$}; \Red{$B$} is a variable
with states \Red{$b_1,\ldots ,b_m$}.\newline

$P(\Blue{A})=(x_1,\ldots ,x_n)$ is a \underline{\Red{probability distribution}} ; $x_i\geq
0$;$\sum_{i=1}^nx_i=1$ ($\sum _{\Blue{A}}P(\Blue{A})=1$).\newline

$P(\Blue{A}|\Red{B})$ is a $\Blue{n}\times \Red{m}$ \underline{\Red{table}}
containing the numbers $P(\Blue{a_i}|\Red{b_j})$.\newline
\begin{center}
\fbox{\Red{Note:} {\Black{$\sum _{\Blue{A}}P(\Blue{A}|\Red{b_j})=1$ for all $\Red{b_j}$.}}}
\end{center}

\begin{table}
\begin{center}
\begin{tabular}{cc|ccc}
&      & \multicolumn{3}{c}{\Red{$B$}}\\	
&      & \Red{$b_1$} & \Red{$b_2$} & \Red{$b_3$} \\ \hline
\multirow{2}{0cm}{\Blue{$A$}}&\Blue{$a_1$} & $0.4$ & $0.3$ & $0.6$ \\
&\Blue{$a_2$} & $0.6$ & $0.7$ & $0.4$ 
\end{tabular}
\end{center}
\end{table}

$P(\Blue{A},\Red{B})$ is a $\Blue{n}\times \Red{m}$ table too; $\sum _{\Blue{A},\Red{B}}P(\Blue{A},\Red{B})=1$.

\begin{table}
\begin{center}
\begin{tabular}{cc|ccc}
&      & \multicolumn{3}{c}{\Red{$B$}}\\	
&      & \Red{$b_1$} & \Red{$b_2$} & \Red{$b_3$} \\ \hline
\multirow{2}{0cm}{\Blue{$A$}}&\Blue{$a_1$} & $0.16$ & $0.12$ & $0.12$ \\
&\Blue{$a_2$} & $0.24$ & $0.28$ & $0.08$ 
\end{tabular}
\end{center}
\end{table}

  

\end{slide}

%####################################################################################
%# The fundamental rule for variables
%####################################################################################
\PDForPS{
\overlays{2}{
\begin{slide}{The fundamental rule for variables}
\fromSlide*{1}{
$P(\Blue{A}|\Red{B})P(\Red{B})$: $\Blue{n}\times \Red{m}$ multiplications $P(\Blue{a_i}|\Red{b_j})P(\Red{b_j})=P(\Blue{a_i},\Red{b_j})$

\begin{table}
\begin{center}
\begin{tabular}{cccc}


\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	& $\Red{b_3}$ \\ \hline				
\Blue{$a_1$}    & $\Red{0.4}$   & $\Blue{0.3}$ & $0.6$  \\
\Blue{$a_2$}    & $\Red{0.6}$   & $\Blue{0.7}$ & $0.4$  
\end{tabular}

&

\begin{tabular}{ccc}
$\Red{b_1}$	& $\Red{b_2}$	& $\Red{b_3}$ \\ \hline				
$\Red{0.4}$   & $\Blue{0.4}$ & $0.2$  
\end{tabular}

&
=
&

\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	& $\Red{b_3}$ \\ \hline				
\Blue{$a_1$}    & $\Red{0.16}$   & $\Blue{0.12}$ & $0.12$  \\
\Blue{$a_2$}    & $\Red{0.24}$   & $\Blue{0.28}$ & $0.08$  
\end{tabular}\\

$P(\Blue{A}|\Red{B})$ & $P(\Red{B})$ & & $P(\Blue{A},\Red{B})$

\end{tabular}
\end{center}
\end{table}
}
\fromSlide*{2}{
\ \\
\ \\

\Blue{$A$} is independent of \Red{$B$} given \Purple{$C$} if $P(\Blue{A}|\Red{B},\Purple{C})=P(\Blue{A}|\Red{C})$. 


\begin{table}
\begin{center}
\begin{tabular}{ccc}


\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	& $\Red{b_3}$ \\ \hline				
\Blue{$c_1$}    & $(\Red{0.4},\Red{0.6})$   & $(\Red{0.4},\Red{0.6})$ & $(\Red{0.4},\Red{0.6})$  \\
\Blue{$c_2$}    & $(\Red{0.7},\Red{0.3})$   & $(\Red{0.7},\Red{0.3})$ & $(\Red{0.7},\Red{0.3})$  
\end{tabular}

& =
&

\begin{tabular}{c|cc}
		& $\Red{a_1}$	& $\Red{a_2}$  \\ \hline				
\Blue{$c_1$}    & $\Red{0.4}$   & $\Red{0.6}$  \\
\Blue{$c_2$}    & $\Red{0.7}$   & $\Red{0.3}$  
\end{tabular} \\
$P(\Blue{A}|\Red{B},\Purple{C})$
& &
$P(\Blue{A}|\Red{C})$
\end{tabular}
\end{center}
\end{table}
}
\end{slide}
}
}{
\begin{slide}{The fundamental rule for variables}

$P(\Blue{A}|\Red{B})P(\Red{B})$: $\Blue{n}\times \Red{m}$ multiplications $P(\Blue{a_i}|\Red{b_j})P(\Red{b_j})=P(\Blue{a_i},\Red{b_j})$

\begin{table}
\begin{center}
\begin{tabular}{cccc}


\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	& $\Red{b_3}$ \\ \hline				
\Blue{$a_1$}    & $\Red{0.4}$   & $\Blue{0.3}$ & $0.6$  \\
\Blue{$a_2$}    & $\Red{0.6}$   & $\Blue{0.7}$ & $0.4$  
\end{tabular}

&

\begin{tabular}{ccc}
$\Red{b_1}$	& $\Red{b_2}$	& $\Red{b_3}$ \\ \hline				
$\Red{0.4}$   & $\Blue{0.4}$ & $0.2$  
\end{tabular}

&
=
&

\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	& $\Red{b_3}$ \\ \hline				
\Blue{$a_1$}    & $\Red{0.16}$   & $\Blue{0.12}$ & $0.12$  \\
\Blue{$a_2$}    & $\Red{0.24}$   & $\Blue{0.28}$ & $0.08$  
\end{tabular}\\

$P(\Blue{A}|\Red{B})$ & $P(\Red{B})$ & & $P(\Blue{A},\Red{B})$

\end{tabular}
\end{center}
\end{table}

\ \\
\ \\

\Blue{$A$} is independent of \Red{$B$} given \Purple{$C$} if $P(\Blue{A}|\Red{B},\Purple{C})=P(\Blue{A}|\Red{C})$. 


\begin{table}
\begin{center}
\begin{tabular}{ccc}


\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	& $\Red{b_3}$ \\ \hline				
\Blue{$c_1$}    & $(\Red{0.4},\Red{0.6})$   & $(\Red{0.4},\Red{0.6})$ & $(\Red{0.4},\Red{0.6})$  \\
\Blue{$c_2$}    & $(\Red{0.7},\Red{0.3})$   & $(\Red{0.7},\Red{0.3})$ & $(\Red{0.7},\Red{0.3})$  
\end{tabular}

& =
&

\begin{tabular}{c|cc}
		& $\Red{a_1}$	& $\Red{a_2}$  \\ \hline				
\Blue{$c_1$}    & $\Red{0.4}$   & $\Red{0.6}$  \\
\Blue{$c_2$}    & $\Red{0.7}$   & $\Red{0.3}$  
\end{tabular} \\
$P(\Blue{A}|\Red{B},\Purple{C})$
& &
$P(\Blue{A}|\Red{C})$
\end{tabular}
\end{center}
\end{table}

\end{slide}


}
%####################################################################################
%# $3$-dimensional table 
%####################################################################################

%% \begin{slide}{$3$-dimensional table}

%% \begin{table}
%% \begin{center}
%% \begin{tabular}{cc|ccc}
%% &  & \multicolumn{3}{c}{\Red{Type}}\\
%% &  & \Red{Shirts}  & \Red{Jeans}  & \Red{Underwear} \\\hline
%% \multirow{6}{0.0cm}{\begin{turn}{90}\Blue{Weekday}\end{turn}}&\Blue{Mo}  & $(\Purple{252,105,63})$  & $(\Purple{324,135,81})$  & $(\Purple{144,60,36})$ \\
%% &\Blue{Tu}  & $(\Purple{357,149,89})$ & $(\Purple{459,191,115})$ & $(\Purple{204,85,51})$ \\
%% &\Blue{We}  & $(\Purple{399,166,100})$ & $(\Purple{513,214,128})$ & $(\Purple{228,95,57})$ \\
%% &\Blue{Th}  & $(\Purple{420,175,105})$ & $(\Purple{540,225,135})$ & $(\Purple{240,100,60})$ \\
%% &\Blue{Fr}  & $(\Purple{462,193,165})$ & $(\Purple{594,247,149})$ & $(\Purple{264,110,66})$ \\
%% &\Blue{Sa}  & $(\Purple{270,87,53})$ & $(\Purple{270,113,67})$ & $(\Purple{120,50,30})$
%% \end{tabular}
%% \end{center}
%% \end{table}


%% Turnover in $10^5$ Dkr distributed over \Blue{weekdays}, \Red{type}
%% and \Purple{shop} (\Purple{Copenhagen, Odense, Aalborg}).

%% \end{slide}


%% %####################################################################################
%% %# Probability calculus is like %-calculus
%% %####################################################################################

%% \begin{slide}{Probability calculus is like \%-calculus}

%% \begin{table}
%% \begin{center}
%% \begin{tabular}{cc|ccc}
%% &  & \multicolumn{3}{c}{\Red{Type}}\\
%% &  & \Red{Shirts}  & \Red{Jeans}  & \Red{Underwear} \\\hline
%% \multirow{6}{0.0cm}{\begin{turn}{90}\Blue{Weekday}\end{turn}}& \Blue{Mo}  & $(\Red{2.52,1.05,0.63})$  & $(\Red{3.24,1.35,0.81})$  & $(\Red{1.44,0.60,0.36})$ \\
%% &\Blue{Tu}  & $(\Red{3.57,1.49,0.89})$ & $(\Red{4.59,1.91,1.15})$ & $(\Red{2.04,0.85,0.51})$ \\
%% &\Blue{We}  & $(\Red{3.99,1.66,1.00})$ & $(\Red{5.13,2.14,1.28})$ & $(\Red{2.28,0.95,0.57})$ \\
%% &\Blue{Th}  & $(\Red{4.20,1.75,1.05})$ & $(\Red{5.40,2.25,1.35})$ & $(\Red{2.40,1.00,0.60})$ \\
%% &\Blue{Fr}  & $(\Red{4.62,1.93,1.65})$ & $(\Red{5.94,2.47,1.49})$ & $(\Red{2.64,1.10,0.66})$ \\
%% &\Blue{Sa}  & $(\Red{2.70,0.87,0.53})$ & $(\Red{2.70,1.13,0.67})$ & $(\Red{1.20,0.50,0.30})$
%% \end{tabular}
%% \end{center}
%% \end{table}


%% Turnover in \Red{\%} (\Blue{type}, \Red{weekday},\Red{shop})

%% \end{slide}


%% %####################################################################################
%% %# Distribution over weekdays
%% %####################################################################################

%% \begin{slide}{Distribution over weekdays}


%% \begin{table}
%% \begin{center}
%% \begin{tabular}{cc|ccccc}
%% &  & \multicolumn{3}{c}{\Red{Type}}\\
%% &  & \Red{Shirts}  & \Red{Jeans}  & \Red{Underwear} & & \\\cline{1-5}
%% \multirow{6}{0.0cm}{\begin{turn}{90}\Blue{Weekday}\end{turn}}&
%% \Blue{Mo}  & $(\Red{2.52,1.05,0.63})$  & $(\Red{3.24,1.35,0.81})$  &
%% $(\Red{1.44,0.60,0.36})$ & \hspace*{0.75cm}$\rightarrow$ & $12.0$ \\
%% &\Blue{Tu}  & $(\Red{3.57,1.49,0.89})$ & $(\Red{4.59,1.91,1.15})$ &
%% $(\Red{2.04,0.85,0.51})$  & \hspace*{0.75cm}$\rightarrow$ & $17.0$\\
%% &\Blue{We}  & $(\Red{3.99,1.66,1.00})$ & $(\Red{5.13,2.14,1.28})$ & $(\Red{2.28,0.95,0.57})$& \hspace*{0.75cm}$\rightarrow$ & $19.0$ \\
%% &\Blue{Th}  & $(\Red{4.20,1.75,1.05})$ & $(\Red{5.40,2.25,1.35})$ & $(\Red{2.40,1.00,0.60})$& \hspace*{0.75cm}$\rightarrow$ & $20.0$ \\
%% &\Blue{Fr}  & $(\Red{4.62,1.93,1.65})$ & $(\Red{5.94,2.47,1.49})$ & $(\Red{2.64,1.10,0.66})$ & \hspace*{0.75cm}$\rightarrow$ & $22.0$\\
%% &\Blue{Sa}  & $(\Red{2.70,0.87,0.53})$ & $(\Red{2.70,1.13,0.67})$ & $(\Red{1.20,0.50,0.30})$& \hspace*{0.75cm}$\rightarrow$ & $10.0$
%% \end{tabular}
%% \end{center}
%% \end{table}


%% \end{slide}




%####################################################################################
%# Marginalization
%####################################################################################

\begin{slide}{Marginalization}

\underline{We have} $P(\Blue{A},\Red{B})$ and \underline{we need} $P(\Blue{A})$.

\begin{table}
\begin{center}
\begin{tabular}{c|ccccc}
      & $\Red{b_1}$  & $\Red{b_2}$  & $\Red{b_3}$  & & \\ \cline{1-4}
$\Blue{a_1}$ & $\Purple{0.16}$ & $\Purple{0.12}$ & $\Purple{0.12}$ & $\Purple{\rightarrow}$ & $\Purple{0.4}$ \\
$\Blue{a_2}$ & $\Red{0.24}$ & $\Red{0.28}$ & $\Red{0.08}$ & $\Red{\rightarrow}$ & $\Red{0.6}$
\end{tabular}
\end{center}
\end{table}

$\Red{B}$ is \underline{marginalized out} of $P(\Blue{A},\Red{B})$:
\begin{equation}\nonumber
\begin{split}
"\Blue{A=a_1}" &= ("\Blue{A=a_1}"\wedge "\Red{B=b_1}") \vee  ("\Blue{A=a_1}"\wedge
"\Red{B=b_2}") \vee  ("\Blue{A=a_1}"\wedge "\Red{B=b_3}") \\
 &= \Purple{0.16+0.12+0.12} = \Purple{0.4}\\
"\Blue{A=a_2}" &= ("\Blue{A=a_2}"\wedge "\Red{B=b_1}") \vee  ("\Blue{A=a_2}"\wedge
"\Red{B=b_2}") \vee  ("\Blue{A=a_2}"\wedge "\Red{B=b_3}") \\
 &= \Red{0.24+0.28+0.08} = \Red{0.6}
\end{split}
\end{equation}


\begin{center}
\fbox{\Red{Notation:} $P(\Blue{A})=\sum _{\Red{B}} P(\Blue{A},\Red{B})$}
\end{center}

 

\end{slide}



%####################################################################################
%# Notation
%####################################################################################

\PDForPS{
\overlays{6}{
\begin{slide}{Notation}
\fromSlide{1}{
A \underline{\Red{potential}} $\phi$ is a table of real numbers over a set of variables,
\underline{\Red{dom}($\phi$)}.\newline

A table of probabilities is a probability potential.
}

\onlySlide*{2}{
\begin{center}
\underline{\Red{Multiplication}}
\end{center}

\begin{table}
\begin{center}
\begin{tabular}{cccc}

\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Purple{2}$   & $\Purple{1}$  \\
\Blue{$a_2$}    & $\Purple{3}$   & $\Purple{4}$ 
\end{tabular}
&
\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Red{1}$   & $\Red{2}$  \\
\Blue{$a_2$}    & $\Red{5}$   & $\Red{6}$ 
\end{tabular}
&
=
&
\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $$   & $$ \\
\Blue{$a_2$}    & $$   & $$
\end{tabular}

\end{tabular}
\end{center}
\end{table}}

\onlySlide*{3}{

\begin{center}
\underline{\Red{Multiplication}}
\end{center}
\begin{table}
\begin{center}
\begin{tabular}{cccc}

\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Purple{2}$   & $\Purple{1}$  \\
\Blue{$a_2$}    & $\Purple{3}$   & $\Purple{4}$ 
\end{tabular}
&
\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Red{1}$   & $\Red{2}$  \\
\Blue{$a_2$}    & $\Red{5}$   & $\Red{6}$ 
\end{tabular}
&
=
&
\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $2$   & $$ \\
\Blue{$a_2$}    & $$   & $$
\end{tabular}

\end{tabular}
\end{center}
\end{table}}



\onlySlide*{4}{
\begin{center}
\underline{\Red{Multiplication}}
\end{center}
\begin{table}
\begin{center}
\begin{tabular}{cccc}

\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Purple{2}$   & $\Purple{1}$  \\
\Blue{$a_2$}    & $\Purple{3}$   & $\Purple{4}$ 
\end{tabular}
&
\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Red{1}$   & $\Red{2}$  \\
\Blue{$a_2$}    & $\Red{5}$   & $\Red{6}$ 
\end{tabular}
&
=
&
\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $2$   & $2$ \\
\Blue{$a_2$}    & $$   & $$
\end{tabular}

\end{tabular}
\end{center}
\end{table}}

\onlySlide*{5}{
\begin{center}
\underline{\Red{Multiplication}}
\end{center}
\begin{table}
\begin{center}
\begin{tabular}{cccc}

\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Purple{2}$   & $\Purple{1}$  \\
\Blue{$a_2$}    & $\Purple{3}$   & $\Purple{4}$ 
\end{tabular}
&
\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Red{1}$   & $\Red{2}$  \\
\Blue{$a_2$}    & $\Red{5}$   & $\Red{6}$ 
\end{tabular}
&
=
&
\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $2$   & $2$ \\
\Blue{$a_2$}    & $15$   & $$
\end{tabular}

\end{tabular}
\end{center}
\end{table}}

\onlySlide*{6}{
\begin{center}
\underline{\Red{Multiplication}}
\end{center}
\begin{table}
\begin{center}
\begin{tabular}{cccc}

\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Purple{2}$   & $\Purple{1}$  \\
\Blue{$a_2$}    & $\Purple{3}$   & $\Purple{4}$ 
\end{tabular}
&
\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Red{1}$   & $\Red{2}$  \\
\Blue{$a_2$}    & $\Red{5}$   & $\Red{6}$ 
\end{tabular}
&
=
&
\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $2$   & $2$ \\
\Blue{$a_2$}    & $15$   & $24$
\end{tabular}

\end{tabular}
\end{center}
\end{table}}

\end{slide}}
}
{
\begin{slide}{Notation}
A \underline{\Red{potential}} $\phi$ is a table of real numbers over a set of variables,
\underline{\Red{dom}($\phi$)}.\newline

A table of probabilities is a probability potential.

\begin{center}
\underline{\Red{Multiplication}}
\end{center}
\begin{table}
\begin{center}
\begin{tabular}{cccc}

\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Purple{2}$   & $\Purple{1}$  \\
\Blue{$a_2$}    & $\Purple{3}$   & $\Purple{4}$ 
\end{tabular}
&
\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Red{1}$   & $\Red{2}$  \\
\Blue{$a_2$}    & $\Red{5}$   & $\Red{6}$ 
\end{tabular}
&
=
&
\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $2$   & $2$ \\
\Blue{$a_2$}    & $15$   & $24$
\end{tabular}

\end{tabular}
\end{center}
\end{table}

\end{slide}}

%####################################################################################
%# Multiplication of potentials
%####################################################################################

\PDForPS{
\overlays{5}{
\begin{slide}{Multiplication of potentials}

\onlySlide*{1}{
\begin{table}
\begin{center}
\begin{tabular}{cccc}


\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Purple{1}$   & $\Purple{3}$  \\
\Blue{$a_2$}    & $\Purple{4}$   & $\Purple{5}$ 
\end{tabular}
&
\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Red{$c_1$}    & $6$   & $7$  \\
\Red{$c_2$}    & $8$   & $9$ 
\end{tabular}
&
=
&
\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $(\_,\_)$   & $(\_,\_)$ \\
\Blue{$a_2$}    & $(\_,\_)$   & $(\_,\_)$
\end{tabular} \\
\vspace{0.5cm} & & & \\
$\phi_1(\Blue{A},\Red{B})$ & $\phi_2(\Red{C},\Red{B})$ & &
$\phi_3(\Blue{A},\Red{B},\Red{C})=\phi_1(\Blue{A},\Red{B})\cdot \phi_2(\Red{C},\Red{B})$ 
\end{tabular}
\end{center}
\end{table} 
} 

\onlySlide*{2}{
\begin{table}
\begin{center}
\begin{tabular}{cccc}


\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Purple{1}$   & $\Purple{3}$  \\
\Blue{$a_2$}    & $\Purple{4}$   & $\Purple{5}$ 
\end{tabular}
&
\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Red{$c_1$}    & $6$   & $7$  \\
\Red{$c_2$}    & $8$   & $9$ 
\end{tabular}
&
=
&
\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $(6_{\Red{c_1}},8_{\Red{c_2}})$   & $(\_,\_)$ \\
\Blue{$a_2$}    & $(\_,\_)$   & $(\_,\_)$
\end{tabular} \\
\vspace{0.5cm} & & & \\
$\phi_1(\Blue{A},\Red{B})$ & $\phi_2(\Red{C},\Red{B})$ & &
$\phi_3(\Blue{A},\Red{B},\Red{C})=\phi_1(\Blue{A},\Red{B})\cdot \phi_2(\Red{C},\Red{B})$ 
\end{tabular}
\end{center}
\end{table} 
} 

\onlySlide*{3}{
\begin{table}
\begin{center}
\begin{tabular}{cccc}


\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Purple{1}$   & $\Purple{3}$  \\
\Blue{$a_2$}    & $\Purple{4}$   & $\Purple{5}$ 
\end{tabular}
&
\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Red{$c_1$}    & $6$   & $7$  \\
\Red{$c_2$}    & $8$   & $9$ 
\end{tabular}
&
=
&
\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $(6_{\Red{c_1}},8_{\Red{c_2}})$   & $(21_{\Red{c_1}},27_{\Red{c_2}})$ \\
\Blue{$a_2$}    & $(\_,\_)$   & $(\_,\_)$
\end{tabular} \\
\vspace{0.5cm} & & & \\
$\phi_1(\Blue{A},\Red{B})$ & $\phi_2(\Red{C},\Red{B})$ & &
$\phi_3(\Blue{A},\Red{B},\Red{C})=\phi_1(\Blue{A},\Red{B})\cdot \phi_2(\Red{C},\Red{B})$ 
\end{tabular}
\end{center}
\end{table} 
} 

\onlySlide*{4}{
\begin{table}
\begin{center}
\begin{tabular}{cccc}


\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Purple{1}$   & $\Purple{3}$  \\
\Blue{$a_2$}    & $\Purple{4}$   & $\Purple{5}$ 
\end{tabular}
&
\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Red{$c_1$}    & $6$   & $7$  \\
\Red{$c_2$}    & $8$   & $9$ 
\end{tabular}
&
=
&
\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $(6_{\Red{c_1}},8_{\Red{c_2}})$   & $(21_{\Red{c_1}},27_{\Red{c_2}})$ \\
\Blue{$a_2$}    & $(24_{\Red{c_1}},32_{\Red{c_2}})$   & $(\_,\_)$
\end{tabular} \\
\vspace{0.5cm} & & & \\
$\phi_1(\Blue{A},\Red{B})$ & $\phi_2(\Red{C},\Red{B})$ & &
$\phi_3(\Blue{A},\Red{B},\Red{C})=\phi_1(\Blue{A},\Red{B})\cdot \phi_2(\Red{C},\Red{B})$ 
\end{tabular}
\end{center}
\end{table} 
} 

\onlySlide*{5}{
\begin{table}
\begin{center}
\begin{tabular}{cccc}


\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Purple{1}$   & $\Purple{3}$  \\
\Blue{$a_2$}    & $\Purple{4}$   & $\Purple{5}$ 
\end{tabular}
&
\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Red{$c_1$}    & $6$   & $7$  \\
\Red{$c_2$}    & $8$   & $9$ 
\end{tabular}
&
=
&
\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $(6_{\Red{c_1}},8_{\Red{c_2}})$   & $(21_{\Red{c_1}},27_{\Red{c_2}})$ \\
\Blue{$a_2$}    & $(24_{\Red{c_1}},32_{\Red{c_2}})$   & $(35_{\Red{c_1}},45_{\Red{c_2}})$
\end{tabular} \\
\vspace{0.5cm} & & & \\
$\phi_1(\Blue{A},\Red{B})$ & $\phi_2(\Red{C},\Red{B})$ & &
$\phi_3(\Blue{A},\Red{B},\Red{C})=\phi_1(\Blue{A},\Red{B})\cdot \phi_2(\Red{C},\Red{B})$ 
\end{tabular}
\end{center}
\end{table} 
} 

\end{slide}}
}
{
\begin{slide}{Multiplication of potentials}

\begin{table}
\begin{center}
\begin{tabular}{cccc}


\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $\Purple{1}$   & $\Purple{3}$  \\
\Blue{$a_2$}    & $\Purple{4}$   & $\Purple{5}$ 
\end{tabular}
&
\begin{tabular}{c|cc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Red{$c_1$}    & $6$   & $7$  \\
\Red{$c_2$}    & $8$   & $9$ 
\end{tabular}
&
=
&
\begin{tabular}{c|ccc}
		& $\Red{b_1}$	& $\Red{b_2}$	 \\ \hline				
\Blue{$a_1$}    & $(6_{\Red{c_1}},8_{\Red{c_2}})$   & $(21_{\Red{c_1}},27_{\Red{c_2}})$ \\
\Blue{$a_2$}    & $(24_{\Red{c_1}},32_{\Red{c_2}})$   & $(35_{\Red{c_1}},45_{\Red{c_2}})$
\end{tabular} \\
\vspace{0.5cm} & & & \\
$\phi_1(\Blue{A},\Red{B})$ & $\phi_2(\Red{C},\Red{B})$ & &
$\phi_3(\Blue{A},\Red{B},\Red{C})=\phi_1(\Blue{A},\Red{B})\cdot \phi_2(\Red{C},\Red{B})$ 
\end{tabular}
\end{center}
\end{table} 
\end{slide}
}

%####################################################################################
%# Marginalization of potentials
%####################################################################################

\PDForPS{
\overlays{4}{
\begin{slide}{Marginalization of potentials}

\onlySlide*{1}{
$$
\sum _{\Red{B}}\left (
\text{
\begin{tabular}{c|cc}
      & $\Red{b_1}$  & $\Red{b_2}$ \\ \hline
$\Blue{a_1}$ & $\Red{2}$ & $\Red{3}$ \\
$\Blue{a_2}$ & $\Red{1}$ & $\Red{4}$ 
\end{tabular}
}
 \right ) = 
\text{
\begin{tabular}{c|c}
$\Blue{a_1}$ & $\_$\\
$\Blue{a_2}$ & $\_$
\end{tabular}
}
$$
}

\onlySlide*{2}{
$$
\sum _{\Red{B}}\left (
\text{
\begin{tabular}{c|cc}
      & $\Red{b_1}$  & $\Red{b_2}$ \\ \hline
$\Blue{a_1}$ & $\Red{2}$ & $\Red{3}$ \\
$\Blue{a_2}$ & $\Red{1}$ & $\Red{4}$ 
\end{tabular}
}
 \right ) = 
\text{
\begin{tabular}{c|c}
$\Blue{a_1}$ & $5$\\
$\Blue{a_2}$ & $5$
\end{tabular}
}
$$
}

\onlySlide*{3}{
$$
\sum _{\Red{B}}\left (
\text{
\begin{tabular}{c|cc}
      & $\Red{b_1}$  & $\Red{b_2}$ \\ \hline
$\Blue{a_1}$ & $\Red{2}$ & $\Red{3}$ \\
$\Blue{a_2}$ & $\Red{1}$ & $\Red{4}$ 
\end{tabular}
}
 \right ) = 
\text{
\begin{tabular}{c|c}
$\Blue{a_1}$ & $5$\\
$\Blue{a_2}$ & $5$
\end{tabular}
}
$$

$$
\sum _{\Blue{A}}\left (
\text{
\begin{tabular}{c|cc}
      & $\Red{b_1}$  & $\Red{b_2}$ \\ \hline
$\Blue{a_1}$ & $\Red{2}$ & $\Red{3}$ \\
$\Blue{a_2}$ & $\Red{1}$ & $\Red{4}$ 
\end{tabular}
}
 \right ) = 
\text{
\begin{tabular}{c|c}
$\Red{b_1}$ & $\_$\\
$\Red{b_2}$ & $\_$
\end{tabular}
}
$$
}

\onlySlide*{4}{
$$
\sum _{\Red{B}}\left (
\text{
\begin{tabular}{c|cc}
      & $\Red{b_1}$  & $\Red{b_2}$ \\ \hline
$\Blue{a_1}$ & $\Red{2}$ & $\Red{3}$ \\
$\Blue{a_2}$ & $\Red{1}$ & $\Red{4}$ 
\end{tabular}
}
 \right ) = 
\text{
\begin{tabular}{c|c}
$\Blue{a_1}$ & $5$\\
$\Blue{a_2}$ & $5$
\end{tabular}
}
$$

$$
\sum _{\Blue{A}}\left (
\text{
\begin{tabular}{c|cc}
      & $\Red{b_1}$  & $\Red{b_2}$ \\ \hline
$\Blue{a_1}$ & $\Red{2}$ & $\Red{3}$ \\
$\Blue{a_2}$ & $\Red{1}$ & $\Red{4}$ 
\end{tabular}
}
 \right ) = 
\text{
\begin{tabular}{c|c}
$\Red{b_1}$ & $3$\\
$\Red{b_2}$ & $7$
\end{tabular}
}
$$
}

\end{slide}}
}
{
\begin{slide}{Marginalization of potentials}
$$
\sum _{\Red{B}}\left (
\text{
\begin{tabular}{c|cc}
      & $\Red{b_1}$  & $\Red{b_2}$ \\ \hline
$\Blue{a_1}$ & $\Red{2}$ & $\Red{3}$ \\
$\Blue{a_2}$ & $\Red{1}$ & $\Red{4}$ 
\end{tabular}
}
 \right ) = 
\text{
\begin{tabular}{c|c}
$\Blue{a_1}$ & $5$\\
$\Blue{a_2}$ & $5$
\end{tabular}
}
$$

$$
\sum _{\Blue{A}}\left (
\text{
\begin{tabular}{c|cc}
      & $\Red{b_1}$  & $\Red{b_2}$ \\ \hline
$\Blue{a_1}$ & $\Red{2}$ & $\Red{3}$ \\
$\Blue{a_2}$ & $\Red{1}$ & $\Red{4}$ 
\end{tabular}
}
 \right ) = 
\text{
\begin{tabular}{c|c}
$\Red{b_1}$ & $3$\\
$\Red{b_2}$ & $7$
\end{tabular}
}
$$
\end{slide}
}


\end{document}





