\documentclass[11pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{epsfig}
\usepackage{graphicx}
\usepackage{pstricks,pst-node}
\usepackage[tight]{subfigure}
\usepackage{epsf}
\usepackage{tabularx}
\usepackage{rotating}
%\usepackage{algorithm}
%\usepackage{algorithmic}
\usepackage{boxedminipage}

\newcommand{\handout}[5]{
  \noindent
  \begin{center}
  \framebox{
    \vbox{
      \hbox to 5.78in { {#1} \hfill #2 }
      \vspace{4mm}
      \hbox to 5.78in { {\Large \hfill #5  \hfill} }
      \vspace{2mm}
      \hbox to 5.78in { {\em #3 \hfill #4} }
    }
  }
  \end{center}
  \vspace*{4mm}
}

\newcommand{\lecture}[5]{\handout{#1}{#2}{#3}{#4}{#5}}

\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{observation}[theorem]{Observation}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{fact}[theorem]{Fact}
\newtheorem{assumption}[theorem]{Assumption}

% 1-inch margins, from fullpage.sty by H.Partl, Version 2, Dec. 15, 1988.
\topmargin 0pt
\advance \topmargin by -\headheight
\advance \topmargin by -\headsep
\textheight 8.9in
\oddsidemargin 0pt
\evensidemargin \oddsidemargin
\marginparwidth 0.5in
\textwidth 6.5in

\parindent 0in
\parskip 1.5ex
%\renewcommand{\baselinestretch}{1.25}

\begin{document}

\lecture{Statistical Techniques in Robotics (16-831, F10)}{Lectures 5 \& 6 (9/7/10 and 9/9/10)}{Lecturer: Drew Bagnell}{Scribe: Brian Coltin and Hugh Cover \footnotemark}
{Graphical Models}

\footnotetext{Some content adapted from previous scribe: Byron Boots}

\section{Graphical Models}

Graphical models are a framework for reasoning about uncertain quantities and the structural relationships between them.
They are a union of probability and graph theory. Nodes represent random variables and edges represent the links, or relationships between these random variables. 

Graphical models can be viewed as a:
\begin{itemize}
\item{\textbf{Communication tool}} that helps to \textit{compactly} express beliefs about a system.
\item{\textbf{Reasoning tool}} that can be used to \textit{extract} relationships that were not obvious when formulating the problem. In
particular graphical models enable us to visualize conditional
independence.
\item{\textbf{Computational skeleton}} that helps organize how we perform computations on random variables.
\end{itemize}

We will examine three types of graphical models:
\begin{itemize}
\item{\textbf{Bayes' Nets} (Directed Graphical Models)}
\item{\textbf{Gibbs Fields} (Undirected Graphical Models)} 
\item{\textbf{Factor Graphs} (Undirected Graphical Models)} 
\end{itemize}

Graphical models are the equivalent of a circuit diagram --- they are
written down to visualize and better understand a problem.

\section{Bayes' nets}

One of the most common graphical models is called a Bayes' net.
Bayes' nets are also known as Bayesian networks, belief networks,
directed graphical models,
and directed independence diagrams. In short, a Bayes' net is a directed acyclic graph with nodes representing uncertain quantities (random
variables) and edges that encode relationships between them (often causal).

\begin{figure}[h]
\begin{center}
\begin{pspicture}(-1,-1)(5,7)
\psset{arrowscale=2}
\rput(2,4){\circlenode{a}{\makebox[1cm]{$A$}}}
\rput(0,2){\circlenode{b}{\makebox[1cm]{$B$}}}
\rput(4,2){\circlenode{c}{\makebox[1cm]{$C$}}}
\rput(6,0){\circlenode{d}{\makebox[1cm]{$D$}}}
\ncline[arrows=->]{a}{b}
\ncline[arrows=->]{a}{c}
\ncline[arrows=->]{b}{c}
\ncline[arrows=->]{c}{d}
\end{pspicture}
\end{center}
\caption{A Bayesian network.}
\label{fig:graph1}
\end{figure}

In Figure \ref{fig:graph1}, we have uncertain quantities A, B, C, and we draw directed arrows between them to represent relationships (typically causal). A bayesian network encodes a joint probability distribution over all the nodes in the graph.
In this case, our Bayes' net encodes the joint probability distribution, $P(A,B,C,D)$.

The basic factorization of the probability distribution using the
chain rule of probability is
$$P(A,B,C,D)=P(A)P(B|A)P(C|A,B)P(D|A,B,C)\mbox{.}$$
\noindent This factorization always holds, and is not dependent on any
particular graphical model.

In the network shown in Figure \ref{fig:graph1}, we can use the edges
in the graph to eliminate unnecessary
conditional dependencies.

$$P(A,B,C,D)=P(A)P(B|A)P(C|A,B)P(D|C)$$

For an arbitrary Bayes' net with nodes $x_1, x_2, \ldots, x_n \in X$,
we can derive the joint distribution $P(X)$ as the product of each node $x_i$ given its parents $\pi(x_i)$.

$$P(X)=\prod_{x_i}P(x_i|\pi(x_i))$$

Note that this factorization strategy only works if there are no cycles
in the graph, and that Bayes' nets are acyclic by definition.

Bayes' net are often
thought of as encoding causal relationships. However, these
relationships are not necessarily causal. In our example, one
should think of A as influencing B and C rather than A causing B and
C. If all the arrows on a Bayes' net are flipped, then the resulting
Bayes' net is equivalent to the original, since they both represent the
same joint probability distribution.

In general, the absence of
arrows is important in a Bayes net: \emph{less} arrows mean
\emph{more} structure.


%%%%%%%%%%%%%%%%%%%%%% end lecture 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%% start lectur 6  %%%%%%%%%%%%%%%%%%%%%%%%%%%%

\subsection{Determining Dependencies}
Bayes' nets can be used to quickly determine whether pairs of variables are dependent on each other. This is done by following all available paths between the two variables and checking if the path is 'blocked'. A path is any sequence of edge connected nodes leading from the first variable to the second. The Bayes' net in Figure \ref{fig:graph2} has 2 paths from A to E.
$$A \to B \to D \to E$$
$$A \to C \to D \to E$$
Blockages are determined by visiting each node on a path and comparing the structure of surrounding nodes and edges to the 3 rule situations explained below.

Two variables are independent if \emph{all} available paths between them are blocked. Any unblocked paths show a possibility of dependence. It should be noted that this analysis can only be as good as the Bayes' net it is based on; an incomplete net may be missing paths that show a dependence.

\begin{figure}[h]
\begin{center}
\begin{pspicture}(-1,-1)(7,5)
\psset{arrowscale=2}
\pscircle*[linecolor=cyan](0,2){.6cm}
\rput(0,2){\circlenode{a}{\makebox[1cm]{$A$}}}
\rput(2,4){\circlenode{b}{\makebox[1cm]{$B$}}}
\rput(2,0){\circlenode{c}{\makebox[1cm]{$C$}}}
\rput(4,2){\circlenode{d}{\makebox[1cm]{$D$}}}
\pscircle*[linecolor=cyan](6,4){.6cm}
\rput(6,4){\circlenode{e}{\makebox[1cm]{$E$}}}
\ncline[arrows=->]{a}{b}
\ncline[arrows=->]{a}{c}
\ncline[arrows=->]{c}{d}
\ncline[arrows=->]{b}{d}
\ncline[arrows=->]{d}{e}
\end{pspicture}
\end{center}
\caption{There are 2 paths from $A$ to $D$.}
\label{fig:graph2}
\end{figure}

\subsubsection{Rule 1: Markov Chain}
Figure \ref{fig:markov} is a Bayes' net representation of a simple markov chain.

\begin{figure}[h]
\begin{center}
\begin{pspicture}(-1,-1)(5,1)
\psset{arrowscale=2}
\rput(0,0){\circlenode{a}{\makebox[1cm]{$x_1$}}}
\rput(2,0){\circlenode{b}{\makebox[1cm]{$x_2$}}}
\rput(4,0){\circlenode{c}{\makebox[1cm]{$x_3$}}}
\ncline[arrows=->]{a}{b}
\ncline[arrows=->]{b}{c}
\end{pspicture}
\end{center}
\caption{A Bayesian network representation of a Markov chain.}
\label{fig:markov}
\end{figure}

An example of such a chain is the process of robot localization, although the usual $z_i$ and $u_i$ terms have been omitted for simplicity. If the robot knows the current state, $x_2$, then it does not need any information about past states, $x_1$, in order to determine the next state, $x_3$. For example if the robot can only be on the $1_{st}$ or $2_{nd}$ floor of a building and it knows that it's previous state was that it was on the $1_{st}$ floor. As there were no inputs any previous information about the robot's state is irrelevant, it must still be on the $1_{st}$ floor. This is the same as saying that $x_1$ and $x_3$ are independent if $x_2$ is known.
$$P(x_3|x_2,x_3)=P(x_3|x_2)$$
In the case where $x_2$ is not known then knowledge of past states could provide information on the current state $x_3$. If our robot did not know it's state at $x_2$ but knew it was on the $1_{st}$ floor at $x_1$ then, given no inputs, $x_3$ has a high probability of being the $1_{st}$ floor. This is the same as saying that $x_1$ and $x_3$ could be dependent if $x_2$ is not known.

\begin{figure}[h]
\begin{center}
\begin{pspicture}(-1,-1)(5,1)
\psset{arrowscale=2} 
\rput(0,0){\circlenode{a}{\makebox[1cm]{$A$}}}
\pscircle*[linecolor=red](2,0){.6cm}
\rput(2,0){\circlenode{b}{\makebox[1cm]{$B$}}}
\rput(4,0){\circlenode{c}{\makebox[1cm]{$C$}}}
\ncline[arrows=->]{a}{b}
\ncline[arrows=->]{b}{c}
\end{pspicture}
\end{center}
\caption{Markov chain is \textbf{BLOCKED} given $B$.}
\label{fig:rule1}
\end{figure}

The rule is therefore that in a chain of nodes, as shown in Figure \ref{fig:rule1}, C is independent from A if B is known. This means there is a blockage on any path passing through a Markov chain with a known middle node. 

\subsubsection{Rule 2: Two Parents, One Child (The Bagpipes Case)}
\begin{figure}[h]
\begin{center}
\begin{pspicture}(-2,-2)(6,4)
\psset{arrowscale=2}
\rput(2,0){\circlenode{a}{\makebox[1.5cm]{ @CMU}}}
\rput(0,2){\circlenode{b}{\makebox[1.5cm]{GPA}}}
\rput(4,2){\circlenode{c}{\makebox[1.5cm]{Bagpipes}}}
\ncline[arrows=->]{c}{a}
\ncline[arrows=->]{b}{a}
\end{pspicture}
\end{center}
\caption{The Bagpipes Case.}
\label{fig:bagpipes}
\end{figure}

Figure \ref{fig:bagpipes} is a simplified Bayes' net representation of the process of getting into CMU. Carnegie Mellon wants to admit students with a high GPA but it is also important to keep the school bagpipe band strong. A student's chances of getting into CMU can therefore be influenced by their GPA and also by their bagpipe playing skills. 

Given any student applying to CMU knowing that they have good grades doesn't tell us anything about their bagpipe skills, the two are independent. This is changed if we then discover that the student was admitted. Now if we know they are good at the bagpipes our expectation of their grades is reduced as their admittance has been 'explained away'. The reverse is true if we know they have particularly high grades. Thus knowledge about admittance creates a dependence between the student's bag piping skills and their GPA.

\begin{figure}[h]
\begin{center}
\begin{pspicture}(-1,-1)(5,3)
\psset{arrowscale=2} 
\rput(0,2){\circlenode{a}{\makebox[1cm]{$A$}}}
\pscircle*[linecolor=green](2,0){.6cm}
\rput(2,0){\circlenode{b}{\makebox[1cm]{$B$}}}
\rput(4,2){\circlenode{c}{\makebox[1cm]{$C$}}}
\ncline[arrows=->]{a}{b}
\ncline[arrows=->]{c}{b}
\end{pspicture}
\end{center}
\caption{Two parents, one child case is \textbf{NOT BLOCKED} given B.}
\label{fig:rule2}
\end{figure}

The rule is therefore that in a 'two parents, one child' case, as shown in Figure \ref{fig:rule2}, A is dependent on C if B is known. The inverse is also true, A is independent from C if B is not known. This means that there is a blockage on a path passing through the 'two parent, one child' case if B is unknown.

\subsubsection{Rule 2 Extension: Addition of Further Children}
\begin{figure}[h]
\begin{center}
\begin{pspicture}(-2,-4)(6,4)
\psset{arrowscale=2}
\rput(2,0){\circlenode{a}{\makebox[1.5cm]{Alarm}}}
\rput(0,2){\circlenode{b}{\makebox[1.8cm]{Earthquake}}}
\rput(4,2){\circlenode{c}{\makebox[1.5cm]{Burglar}}}
\rput(2,-3){\circlenode{d}{\makebox[1.5cm]{police}}}
\ncline[arrows=->]{c}{a}
\ncline[arrows=->]{b}{a}
\ncline[arrows=->]{a}{d}
\end{pspicture}
\end{center}
\caption{Home Alarm Example.}
\label{fig:alarm}
\end{figure}

Rule 2 can be extended with the addition of children of the child. Figure \ref{fig:alarm} shows an example were an alarm can be set off by either an earthquake or a burglar and the police are called when the alarm goes off. As with the bagpipes example the presence of an earthquake and a burglar become dependent given the alarm going of. This is because if we know the alarm has been activated knowledge about a burglar reduces the liklyhood of there having been an earthquake. If however only the presence of the police is known the same dependency is formed as the police imply that the alarm has been activated.

\begin{figure}[h]
\begin{center}
\begin{pspicture}(-1,-3)(5,3)
\psset{arrowscale=2} 
\rput(0,2){\circlenode{a}{\makebox[1cm]{$A$}}}
\pscircle*[linecolor=green](2,0){.6cm}
\rput(2,0){\circlenode{b}{\makebox[1cm]{$B$}}}
\rput(4,2){\circlenode{c}{\makebox[1cm]{$C$}}}
\pscircle*[linecolor=green](2,-2){.6cm}
\rput(2,-2){\circlenode{d}{\makebox[1cm]{$D$}}}
\ncline[arrows=->]{a}{b}
\ncline[arrows=->]{c}{b}
\ncline[arrows=->]{b}{d}
\end{pspicture}
\end{center}
\caption{Path is \textbf{NOT BLOCKED} given either B or D.}
\label{fig:rule2 extension}
\end{figure}

The extension of rule 2 is therefore that if a child of the child is known the path is also unblocked. With reference to Figure \ref{fig:rule2 extension} the path is only blocked if B and any children of B are unknown.

\subsubsection{Rule 3: One parent, Two Children}
\begin{figure}[h]
\begin{center}
\begin{pspicture}(-1,-1)(5,3)
\psset{arrowscale=2} 
\rput(0,0){\circlenode{a}{\makebox[1cm]{$A$}}}
\rput(2,2){\circlenode{b}{\makebox[1cm]{$B$}}}
\rput(4,0){\circlenode{c}{\makebox[1cm]{$C$}}}
\ncline[arrows=->]{b}{a}
\ncline[arrows=->]{b}{c}
\end{pspicture}
\end{center} 
\caption{Rule 3, Anybot Example.}
\label{fig:anybot}
\end{figure}

Figure \ref{fig:anybot} shows a Bayes' net representation of the uses of an Anybot in an office. An Anybot can be used to aid in teleconferenced meetings and can also be used as a racing vehicle. If we don't know that there is an Anybot and are told that there have been races the probability of teleconference meetings is increased. This is because knowledge about races increases the chance of there being an Anybot for use in meetings. If however we know there is an Anybot in the office the fact that people are racing it dosn't change the likelihood of there being any teleconference meetings.

\begin{figure}[h]
\begin{center}
\begin{pspicture}(-1,-1)(5,3)
\psset{arrowscale=2} 
\rput(0,0){\circlenode{a}{\makebox[1cm]{$A$}}}
\pscircle*[linecolor=red](2,2){.6cm}
\rput(2,2){\circlenode{b}{\makebox[1cm]{$B$}}}
\rput(4,0){\circlenode{c}{\makebox[1cm]{$C$}}}
\ncline[arrows=->]{b}{a}
\ncline[arrows=->]{b}{c}
\end{pspicture}
\end{center} 
\caption{One parent, Two Children case is \textbf{BLOCKED} given B.}
\label{fig:rule3}
\end{figure}

Rule 3 is therefore that in a 'one parent, two children' case, as shown in Figure \ref{fig:rule3}, A is independent from C given B. This means that there is a blockage on a path passing through this case if the parent, B, is known.

\subsubsection{Example: Localization}
\begin{figure}[h]
\begin{center}
\begin{pspicture}(-1,-1)(5,5)
\psset{arrowscale=2}
\pscircle*[linecolor=red](4,2){.6cm}
\pscircle*[linecolor=red](4,0){.6cm}
\rput(2,4){\circlenode{a}{\makebox[1cm]{$u_2$}}}
\rput(0,2){\circlenode{b}{\makebox[1cm]{$x_1$}}}
\rput(4,2){\circlenode{c}{\makebox[1cm]{$x_2$}}}
\rput(0,0){\circlenode{d}{\makebox[1cm]{$z_1$}}}
\rput(4,0){\circlenode{e}{\makebox[1cm]{$z_2$}}}
\ncline[arrows=->]{b}{a}
\ncline[arrows=->]{a}{c}
\ncline[arrows=->]{b}{d}
\ncline[arrows=->]{c}{e}
\ncline[arrows=->]{b}{c}
\end{pspicture}
\end{center}
\caption{A Remote Controled Car.}
\label{fig:remote}
\end{figure}

Figure \ref{fig:remote} shows a simple remote controlled car scenario with a human driver sending inputs based on the car's actual state. The derivation of Bayes Filter in "Probabilistic Robotics" assumes that $x_{t-1}$ is independant of $u_t$. To test that this is the case for the remote control example the two paths between $x_1$ and $u_2$ need to be tested. The path via $x_2$ is a case of rule 2 where both $x_3$ and $z_3$ are unknown and so is blocked, however the direct path cannot be blocked. Therefore there does exist a dependancy and the assumption is incorrect.

\begin{figure}[h]
\begin{center}
\begin{pspicture}(-1,-1)(5,5)
\psset{arrowscale=2}
\pscircle*[linecolor=red](4,2){.6cm}
\pscircle*[linecolor=red](4,0){.6cm}
\pscircle*[linecolor=red](0,0){.6cm}
\rput(2,4){\circlenode{a}{\makebox[1cm]{$u_2$}}}
\rput(0,2){\circlenode{b}{\makebox[1cm]{$x_1$}}}
\rput(4,2){\circlenode{c}{\makebox[1cm]{$x_2$}}}
\rput(0,0){\circlenode{d}{\makebox[1cm]{$z_1$}}}
\rput(4,0){\circlenode{e}{\makebox[1cm]{$z_2$}}}
\ncline[arrows=->]{d}{a}
\ncline[arrows=->]{a}{c}
\ncline[arrows=->]{b}{d}
\ncline[arrows=->]{c}{e}
\ncline[arrows=->]{b}{c}
\end{pspicture}
\end{center}
\caption{A Remote Controled Car.}
\label{fig:localization}
\end{figure}

If the scenario is modified such that the input is now based on the previous observation and not a human who knows the actual state the Bayes' net looks like Figure \ref{fig:localization}. In this case the path via $x_2$ is still blocked and the path via $z_1$ is a case of rule 1 where $z_1$ is known and therfore blocked. All paths are blocked and the assumption that $x_{t-1}$ is independant from $u_t$ is valid.

\subsubsection{Example: Landmark Based Navigation}
\begin{figure}[h]
\begin{center}
\begin{pspicture}(-1,-1)(7,9)
\psset{arrowscale=2}
\pscircle*[linecolor=green](0,6){.6cm}
\pscircle*[linecolor=green](0,8){.6cm}
\pscircle*[linecolor=green](2,8){.6cm}
\pscircle*[linecolor=green](2,6){.6cm}
\rput(0,8){\circlenode{a}{\makebox[1cm]{$x_0$}}}
\rput(2,8){\circlenode{b}{\makebox[1cm]{$x_1$}}}
\rput(4,8){\circlenode{c}{\makebox[1cm]{$x_2$}}}
\rput(6,8){\circlenode{k}{\makebox[1cm]{$x_3$}}}
\rput(0,6){\circlenode{d}{\makebox[1cm]{$z_0$}}}
\rput(2,6){\circlenode{e}{\makebox[1cm]{$z_1$}}}
\rput(4,6){\circlenode{f}{\makebox[1cm]{$z_2$}}}
\rput(6,6){\circlenode{j}{\makebox[1cm]{$z_3$}}}
\rput(0,4){\circlenode{g}{\makebox[1cm]{$l_1$}}}
\rput(0,2){\circlenode{h}{\makebox[1cm]{$l_2$}}}
\rput(0,0){\circlenode{i}{\makebox[1cm]{$l_3$}}}
\ncline[arrows=->]{a}{b}
\ncline[arrows=->]{b}{c}
\ncline[arrows=->]{c}{k}
\ncline[arrows=->]{a}{d}
\ncline[arrows=->]{b}{e}
\ncline[arrows=->]{c}{f}
\ncline[arrows=->]{g}{d}
\ncline[arrows=->]{g}{f}
\ncline[arrows=->]{h}{e}
\ncline[arrows=->]{i}{j}
\ncline[arrows=->]{k}{j}
\end{pspicture}
\end{center}
\caption{A bayesian network representation of a localisation scenario.}
\label{fig:landmark}
\end{figure}

Figure \ref{fig:landmark} shows a bayesian network representation of a localisation scenario with internal states $x_i$, observations $z_i$ and landmarks $l_i$. If we pose the case that we see all the observations, $z_0,z_1,z_2,...$, are the landmarks conditionally independent of each other? To take one case, is $l_1\perp l_2 | Z$? 

The converging arrows at $z_0$ are an example of rule 2 and the path remains unblocked as $z_0$ is known. Looking now at $x_0$, rule 3 can be used to show there is no blockage as $x_0$ is not known. The path extends through $x_1$ to $z_1$, a rule 1 case where $x_1$ is not known leaving the path unblocked. Finally $z_1$ to $l_2$ is another unblocked rule 2 case. Thus, $l_1$ and $l_2$ are not conditionally independent given $z_0$ and $z_1$.  

The existence of conditional dependencies between landmarks introduces significant computational complexity due to high dimensionality. In this case if the values of X can be observed the dependency between $l_1$ and $l_2$, and all the landmarks, is removed. Using a particle filter, samples of X can be taken making each landmark independent and allowing for sperate filters to be run for each landmark, greatly reducing the dimensionality of the problem.



\newpage
\section{Gibbs Field}
A Gibbs Field is a collection of nodes that have undirected edges between them, this can be seen in Figure \ref{fig:undirected}. There is no causal link along edges rather it shows that the connected nodes are related in some way, they 'move together'. As with a Bayes' net less connections means more structure.

\begin{figure}[h]
\begin{center}
\begin{pspicture}(-1,-1)(5,3)
\psset{arrowscale=2}
\rput(0,2){\circlenode{a}{\makebox[1cm]{$x_0$}}}
\rput(0,0){\circlenode{b}{\makebox[1cm]{$x_1$}}}
\rput(2,2){\circlenode{c}{\makebox[1cm]{$x_2$}}}
\rput(4,2){\circlenode{d}{\makebox[1cm]{$x_3$}}}
\rput(4,0){\circlenode{e}{\makebox[1cm]{$x_4$}}}
\ncline[arrows=-]{a}{b}
\ncline[arrows=-]{a}{c}
\ncline[arrows=-]{b}{c}
\ncline[arrows=-]{c}{e}
\ncline[arrows=-]{c}{d}
\ncline[arrows=-]{e}{d}
\end{pspicture}
\end{center}
\caption{A Gibbs Field with nodes $x_0,x_1,x_2,x_3,x_4$.}
\label{fig:undirected}
\end{figure}

A clique is a fully connected subset of the the graph, i.e. all nodes in a clique must be connected to all other nodes in the clique. In Figure \ref{fig:undirected} $x_0$, $x_1$, and $x_2$ form a clique and $x_2$, $x_3$, and $x_4$ also form a clique. These two cliques are known as maximal cliques because they are not part of any larger clique, however they are not the only cliques. The full set includes pairs of connected nodes, e.g. $x_0$ and $x_1$ and individual nodes. It is only nessasry to pay attention to maximal cliques as characteristics of smaller cliques can be absorbed into the larger maximal cliques.

The joint probability distribution can be represented by the product of a set of clique potential functions $\phi$ (see Equation \ref{eq:dist}). 

\begin{equation}
\label{eq:dist}
P(\vec{x}) = \frac{1}{Z}\prod_{i \in cliques}\phi_{i}(X_{i})
\end{equation}


The first clique has functions representing the probability distribution of the set of three variables $x_0, x_1, x_2$: $\phi_i(x_0,x_1,x_2)$, similarly there exists functions for the other maximal clique, $\phi_i(x_2,x_3,x_4)$. Each potential function $\phi_i$ must be positive and unlike probability distribution functions they do not need to sum to 1. Because the potential functions are not normalized a normalization constant, Z (see Equation \ref{eq:Z}) is required in Equation \ref{eq:dist} to create a valid probability distribution. 

\begin{equation}
\label{eq:Z}
Z = \sum_x \prod_{i \in cliques} \phi_{i}(x_{i})
\end{equation}

The potential functions can also be thought of as energy functions, $f_i(X_i)$, with a probability function as shown in Equation \ref{eq:energy}. The energy assigned by the functions $f_i(X_i)$ is an indicator of the likelihood of the corresponding relationships within the clique. Higher energies lead to a lower probability and vis-versa. 

\begin{equation}
\label{eq:energy}
P(\vec{x}) = \frac{1}{Z}e^{-\displaystyle\sum_{i \in cliques}f_i(X_i)}
\end{equation} 

%%%%%%%%%%%%%%%%%%%%%% end lecture 6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}