stat946f11
Editor Sign Up
Sign up for your presentation
paper summaries
Assignments
Introduction
Motivation
Graphical probabilistic models provide a concise representation of various probabilistic distributions that are found in many real world applications. Some interesting areas include medical diagnosis, computer vision, language, analyzing gene expression data, etc. A problem related to medical diagnosis is, "detecting and quantifying the causes of a disease". This question can be addressed through the graphical representation of relationships between various random variables (both observed and hidden). This is an efficient way of representing a joint probability distribution.
Graphical models are excellent tools to burden the computational load of probabilistic models. Suppose we want to model a binary image. If we have 256 by 256 image then our distribution function has
Notation
We will begin with short section about the notation used in these notes. Capital letters will be used to denote random variables and lower case letters denote observations for those random variables:
random variables observations of the random variables
The joint probability mass function can be written as:
or as shorthand, we can write this as
Example
Let
Also let
Graphical Models
Graphical models provide a compact representation of the joint distribution where V vertices (nodes) represent random variables and edges E represent the dependency between the variables. There are two forms of graphical models (Directed and Undirected graphical model). Directed graphical (Figure 1) models consist of arcs and nodes where arcs indicate that the parent is a explanatory variable for the child. Undirected graphical models (Figure 2) are based on the assumptions that two nodes or two set of nodes are conditionally independent given their neighbour1.
Similiar types of analysis predate the area of Probablistic Graphical Models and it's terminology. Bayesian Network and Belief Network are preceeding terms used to a describe directed acyclical graphical model. Similarly Markov Random Field (MRF) and Markov Network are preceeding terms used to decribe a undirected graphical model. Probablistic Graphical Models have united some of the theory from these older theories and allow for more generalized distributions than were possible in the previous methods.
We will use graphs in this course to represent the relationship between different random variables. {{
Template:namespace detect
| type = style | image = | imageright = | style = | textstyle = | text = This article may require cleanup to meet Wikicoursenote's quality standards. The specific problem is: It is worth noting that both Bayesian networks and Markov networks existed before introduction of graphical models but graphical models helps us to provide a unified theory for both cases and more generalized distributions.. Please improve this article if you can. (October 2011) | small = | smallimage = | smallimageright = | smalltext = }}
Directed graphical models (Bayesian networks)
In the case of directed graphs, the direction of the arrow indicates "causation". This assumption makes these networks useful for the cases that we want to model causality. So these models are more useful for applications such as computational biology and bioinformatics, where we study effect (cause) of some variables on another variable. For example:
In this case we must assume that our directed graphs are acyclic. An example of an acyclic graphical model from medicine is shown in Figure 2a.
Exposure to ionizing radiation (such as CT scans, X-rays, etc) and also to environment might lead to gene mutations that eventually give rise to cancer. Figure 2a can be called as a causation graph.
If our causation graph contains a cycle then it would mean that for example:
causes causes causes , again.
Clearly, this would confuse the order of the events. An example of a graph with a cycle can be seen in Figure 3. Such a graph could not be used to represent causation. The graph in Figure 4 does not have cycle and we can say that the node
In directed acyclic graphical models each vertex represents a random variable; a random variable associated with one vertex is distinct from the random variables associated with other vertices. Consider the following example that uses boolean random variables. It is important to note that the variables need not be boolean and can indeed be discrete over a range or even continuous.
Speaking about random variables, we can now refer to the relationship between random variables in terms of dependence. Therefore, the direction of the arrow indicates "conditional dependence". For example:
Note if we do not have any conditional independence, the corresponding graph will be complete, i.e., all possible edges will be present. Whereas if we have full independence our graph will have no edge. Between these two extreme cases there exist a large class. Graphical models are more useful when the graph be sparse, i.e., only a small number of edges exist. The topology of this graph is important and later we will see some examples that we can use graph theory tools to solve some probabilistic problems. On the other hand this representation makes it easier to model causality between variables in real world phenomena.
Example
In this example we will consider the possible causes for wet grass.
The wet grass could be caused by rain, or a sprinkler. Rain can be caused by clouds. On the other hand one can not say that clouds cause the use of a sprinkler. However, the causation exists because the presence of clouds does affect whether or not a sprinkler will be used. If there are more clouds there is a smaller probability that one will rely on a sprinkler to water the grass. As we can see from this example the relationship between two variables can also act like a negative correlation. The corresponding graphical model is shown in Figure 5.
This directed graph shows the relation between the 4 random variables. If we have
the joint probability
This all seems very simple at first but then we must consider the fact that in the discrete case the joint probability function grows exponentially with the number of variables. If we consider the wet grass example once more we can see that we need to define
Example:
Now consider an example where there are not 4 such random variables but 400. The interaction table would become too large to manage. In fact, it would require
To solve the intractability problem we need to consider the way those relationships are represented in the graph. Let us define the following parameters. For each vertex
: is the set of parents of- ex.
\ (the parent of )
- ex.
: is the joint p.d.f. of and for which it is true that: is nonnegative for all
Claim: There is a family of probability functions
To show the power of this claim we can prove the equation (
We want to show that
Consider factors
since we had already set
Let us consider another example with a different directed graph.
Example:
Consider the simple directed graph in Figure 6.

Assume that we would like to calculate the following:
We can also make use of Bayes' Rule here:
We also need
Thus,
Theorem 1.
.
In our simple graph, the joint probability can be written as
Instead, had we used the chain rule we would have obtained a far more complex equation:
The Markov Property, or Memoryless Property is when the variable
By simply applying the Markov Property to the chain-rule formula we would also have obtained the same result.
Now let us consider the joint probability of the following six-node example found in Figure 7.

If we use Theorem 1 it can be seen that the joint probability density function for Figure 7 can be written as follows:
Once again, we can apply the Chain Rule and then the Markov Property and arrive at the same result.
Independence
Marginal independence
We can say that
Conditional independence
We can say that
Note: Both equations are equivalent. Aside: Before we move on further, we first define the following terms:
- I is defined as an ordering for the nodes in graph C.
- For each
, is defined as a set of all nodes that appear earlier than i excluding its parents .
Let us consider the example of the six node figure given above (Figure 7). We can define
We can then easily compute
while
We would be interested in finding the conditional independence between random variables in this graph. We know
To illustrate why this is true we can take a simple example. Show that:
Proof: first, we know
then
The other conditional independences can be proven through a similar process.
Sampling
Even if using graphical models helps a lot facilitate obtaining the joint probability, exact inference is not always feasible. "Exact inference is feasible in small to medium-sized networks only. Exact inference consumes such a long time in large networks. Therefore, we resort to approximate inference techniques which are much faster and usually give pretty good results". <ref>Weng-Keen Wong, "Bayesian Networks: A Tutorial", School of Electrical Engineering and Computer Science, Oregon State University, 2005. Available: [1]</ref> In sampling, random samples are generated and values of interest are computed from samples, not original work.
As an input you have a Bayesian network with set of nodes
Some sampling algorithms:
- Forward Sampling
- Likelihood weighting
- Gibbs Sampling (MCMC)
- Blocking
- Rao-Blackwellised
- Importance Sampling
Bayes Ball
The Bayes Ball algorithm can be used to determine if two random variables represented in a graph are independent. The algorithm can show that either two nodes in a graph are independent OR that they are not necessarily independent. The Bayes Ball algorithm can not show that two nodes are dependent. In other word it provides some rules which enables us to do this task using the graph without the need to use the probability distributions. The algorithm will be discussed further in later parts of this section.
Canonical Graphs
In order to understand the Bayes Ball algorithm we need to first introduce 3 canonical graphs. Since our graphs are acyclic, we can represent them using these 3 canonical graphs.
Markov Chain (also called serial connection)
In the following graph (Figure 8 X is independent of Z given Y.
We say that:

We can prove this independence:
Where
Markov chains are an important class of distributions with applications in communications, information theory and image processing. They are suitable to model memory in phenomenon. For example suppose we want to study the frequency of appearance of English letters in a text. Most likely when "q" appears, the next letter will be "u", this shows dependency between these letters. Markov chains are suitable model this kind of relations.

Markov chains play a significant role in biological applications. It is widely used in the study of carcinogenesis (initiation of cancer formation). A gene has to undergo several mutations before it becomes cancerous, which can be addressed through Markov chains. An example is given in Figure 8a which shows only two gene mutations.
Hidden Cause (diverging connection)
In the Hidden Cause case we can say that X is independent of Z given Y. In this case Y is the hidden cause and if it is known then Z and X are considered independent.
We say that:

The proof of the independence:
The Hidden Cause case is best illustrated with an example:
In Figure 10 it can be seen that both "Shoe Size" and "Grey Hair" are dependant on the age of a person. The variables of "Shoe size" and "Grey hair" are dependent in some sense, if there is no "Age" in the picture. Without the age information we must conclude that those with a large shoe size also have a greater chance of having gray hair. However, when "Age" is observed, there is no dependence between "Shoe size" and "Grey hair" because we can deduce both based only on the "Age" variable.
Explaining-Away (converging connection)
Finally, we look at the third type of canonical graph:
Explaining-Away Graphs. This type of graph arises when a
phenomena has multiple explanations. Here, the conditional
independence statement is actually a statement of marginal
independence:

In these types of scenarios, variables X and Z are independent. However, once the third variable Y is observed, X and Z become dependent (Fig. 11).
To clarify these concepts, suppose Bob and Mary are supposed to meet for a noontime lunch. Consider the following events:
If Mary is late, then she could have been kidnapped by aliens. Alternatively, Bob may have forgotten to adjust his watch for daylight savings time, making him early. Clearly, both of these events are independent. Now, consider the following probabilities:
We expect
- If we do not observe late, then aliens
( ) - If we do observe late, then aliens
( )
Bayes Ball Algorithm
Goal: We wish to determine whether a given conditional
statement such as
The algorithm is as follows:
- Shade nodes,
, that are conditioned on, i.e. they have been observed. - Assuming that the initial position of the ball is
: - If the ball cannot reach
, then the nodes and must be conditionally independent. - If the ball can reach
, then the nodes and are not necessarily independent.
The biggest challenge in the Bayes Ball Algorithm is to determine what happens to a ball going from node X to node Z as it passes through node Y. The ball could continue its route to Z or it could be blocked. It is important to note that the balls are allowed to travel in any direction, independent of the direction of the edges in the graph.
We use the canonical graphs previously studied to determine the route of a ball traveling through a graph. Using these three graphs, we establish the Bayes ball rules which can be extended for more graphical models.
Markov Chain (serial connection)

A ball traveling from X to Z or from Z to X will be blocked at node Y if this node is shaded. Alternatively, if Y is unshaded, the ball will pass through.
In (Fig. 12(a)), X and Z are conditionally
independent (
Hidden Cause (diverging connection)

A ball traveling through Y will be blocked at Y if it is shaded. If Y is unshaded, then the ball passes through.
(Fig. 13(a)) demonstrates that X and Z are conditionally independent when Y is shaded.
Explaining-Away (converging connection)
Unlike the last two cases in which the Bayes ball rule was intuitively understandable, in this case a ball traveling through Y is blocked when Y is UNSHADED!. If Y is shaded, then the ball passes through. Hence, X and Z are conditionally independent when Y is unshaded.

Bayes Ball Examples
Example 1
In this first example, we wish to identify the behavior of leaves in the graphical models using two-nodes graphs. Let a ball be going from X to Y in two-node graphs. To employ the Bayes ball method mentioned above, we have to implicitly add one extra node to the two-node structure since we introduced the Bayes rules for three nodes configuration. We add the third node exactly symmetric to node X with respect to node Y. For example in (Fig. 15) (a) we can think of a hidden node in the right hand side of node Y with a hidden arrow from the hidden node to Y. Then, we are able to utilize the Bayes ball method considering the fact that a ball thrown from X cannot reach Y, and thus it will be blocked. On the contrary, following the same rule in (Fig. 15) (b) turns out that if there was a hidden node in right hand side of Y, a ball could pass from X to that hidden node according to explaining-away structure. Of course, there is no real node and in this case we conventionally say that the ball will be bounced back to node X.

Finally, for the last two graphs, we used the rules of the Hidden Cause Canonical Graph (Fig. 13). In (c), the ball passes through Y while in (d), the ball is blocked at Y.
Example 2
Suppose your home is equipped with an alarm system. There are two possible causes for the alarm to ring:
- Your house is being burglarized
- There is an earthquake
Hence, we define the following events:
The burglary and earthquake events are independent
if the alarm does not ring. However, if the alarm does ring, then
the burglary and the earthquake events are not
necessarily independent. Also, if the alarm rings then it is
more possible that a police report will be issued.
We can use the Bayes Ball Algorithm to deduce conditional
independence properties from the graph. Firstly, consider figure
(16(a)) and assume we are trying to determine
whether there is conditional independence between the
burglary and earthquake events. In figure
(
Nonetheless, this does not prove that the burglary and
earthquake events are independent. Indeed,
(Fig. 16(b)) disproves this as we have found an
alternate path from burglary to earthquake passing
through report. It follows that
Example 3
Referring to figure (Fig. 17), we wish to determine whether the following conditional probabilities are true:

To determine if the conditional probability Eq.
After shading nodes
Example 4

Consider figure (Fig. 18). Using the Bayes Ball Algorithm we wish to determine if each of the following statements are valid:
To disprove Eq.
Similarly, we can show that there does not exist a path between
Finally, (Fig. 19(c)) shows that there is a
route from
Theorem 2.
Define
Let
Let
Then
Example 5
Given the following Bayesian network (Fig.19 ): Determine whether the following statements are true or false?
a.)
Ans. True
b.)
Ans. True
c.)
Ans. False
Undirected Graphical Model


Generally, the graphical model is divided into two major classes, directed graphs and undirected graphs. Directed graphs and its characteristics was described previously. In this section we discuss undirected graphical model which is also known as Markov random fields. In some applications there are relations between variables but these relation are bilateral and we don't encounter causality. For example consider a natural image. In natural images the value of a pixel has correlations with neighboring pixel values but this is bilateral and not a causality relations.
Markov random fields are suitable to model such processes and have found applications in fields such as vision and image processing.We can define an undirected graphical model with a graph
Conditional independence


For directed graphs Bayes ball method was defined to determine the conditional independence properties of a given graph. We can also employ the Bayes ball algorithm to examine the conditional independency of undirected graphs. Here the Bayes ball rule is simpler and more intuitive.
Considering (Fig.21a) , a ball can be thrown either from x to z or from z to x if y is not observed. In other words, if y is not observed (Fig.21b) a ball thrown from x can reach z and vice versa. On the contrary, given a shaded y, the node can block the ball and make x and z conditionally independent. With this definition one can declare that in an undirected graph, a node is conditionally independent of non-neighbors given neighbors. Technically speaking,
Question
Is it possible to convert undirected models to directed models or vice versa?
In order to answer this question, consider (Fig.22 ) which illustrates an undirected graph with four nodes -

It is simple to see there is no directed graph satisfying both conditional independence properties. Recalling that directed graphs are acyclic, converting undirected graphs to directed graphs result in at least one node in which the arrows are inward-pointing(a v structure). Without loss of generality we can assume that node

Parameterization
Having undirected graphical models, we would like to obtain "local" parameterization like what we did in the case of directed graphical models. For directed graphical models, "local" had the interpretation of a set of node and its parents,
It can be shown that definition of local functions based only a node and its corresponding edges (similar to directed graphical models) is not tractable and we need to follow a different approach. Before defining the "local" functions, we have to introduce a new terminology in graph theory called clique. Clique is a subset of fully connected nodes in a graph G. Every node in the clique C is directly connected to every other node in C. In addition, maximal clique is a clique where if any other node from the graph G is added to it then the new set is no longer a clique. Consider the undirected graph shown in (Fig. 24), we can list all the cliques as follow:
-
According to the definition,
where in aforementioned example
where
As a matter of fact, normalization factor,
As was mentioned above, sum-product of the potential functions determines the joint probability over all nodes. Because of the fact that potential functions are arbitrarily defined, assuming exponential functions for
the joint probability is given by:
-
There is a lot of information contained in the joint probability distribution
Tasks:
- Marginalization
Given
Given
- Conditioning
Given
- Evaluation
Evaluate the probability for a certain configuration.
- Completion
Compute the most probable configuration. In other words, which of the
- Simulation
Generate a random configuration for
- Learning
We would like to find parameters for
Exact Algorithms:
To compute the probabilistic inference or the conditional probability of a variable
- Elimination
- Sum-Product
- Max-Product
- Junction Tree
Elimination Algorithm
In this section we will see how we could overcome the problem of probabilistic inference on graphical models. In other words, we discuss the problem of computing conditional and marginal probabilities in graphical models.
Elimination Algorithm on Directed Graphs<ref name="Pool">[3]</ref>
First we assume that E and F are disjoint subsets of the node indices of a graphical model, i.e.
which can be further marginalized to yield
and then the desired conditional probability is given by:
Example
Let assume that we are interested in
where to simplify the notations we define
Therefore, the conditional probability is given by:
At the beginning of our computation we had the assumption which says
We can define an algorithm to make inference on directed graphs using elimination techniques. Let E and F be an evidence set and a query node, respectively. We first choose an elimination ordering I such that F appears last in this ordering. The following figure shows the steps required to perform the elimination algorithm for probabilistic inference on directed graphs:
ELIMINATE (G,E,F)
INITIALIZE (G,F)
EVIDENCE(E)
UPDATE(G)
NORMALIZE(F)
INITIALIZE(G,F)
Choose an ordering [math]\displaystyle{ I }[/math] such that [math]\displaystyle{ F }[/math] appear last
- For each node [math]\displaystyle{ X_i }[/math] in [math]\displaystyle{ V }[/math]
- Place [math]\displaystyle{ p(x_i|x_{\pi_i}) }[/math] on the active list
- End
EVIDENCE(E)
- For each [math]\displaystyle{ i }[/math] in [math]\displaystyle{ E }[/math]
- Place [math]\displaystyle{ \delta(x_i|\overline{x_i}) }[/math] on the active list
- End
Update(G)
- For each [math]\displaystyle{ i }[/math] in [math]\displaystyle{ I }[/math]
- Find all potentials from the active list that reference [math]\displaystyle{ x_i }[/math] and remove them from the active list
- Let [math]\displaystyle{ \phi_i(x_Ti) }[/math] denote the product of these potentials
- Let [math]\displaystyle{ m_i(x_Si)=\sum_{x_i}\phi_i(x_Ti) }[/math]
- Place [math]\displaystyle{ m_i(x_Si) }[/math] on the active list
- End
Normalize(F)
- [math]\displaystyle{ p(x_F|\overline{x_E}) }[/math] ← [math]\displaystyle{ \phi_F(x_F)/\sum_{x_F}\phi_F(x_F) }[/math]
Example:
For the graph in figure 21

We must now create an active list. There are two rules that must be followed in order to create this list.
- For i
place in active list. - For i
{E} place in active list.
Here, our active list is:
We first eliminate node
Likewise, we can also eliminate
Elimination Algorithm on Undirected Graphs
The first task is to find the maximal cliques and their associated potential functions.
maximal clique:
potential functions:
The
The general rule for elimination in an undirected graph is that we can remove a node as long as we connect all of the parents of that node together. Effectively, we form a clique out of the parents of that node.
The algorithm used to eliminate nodes in an undirected graph is:
UndirectedGraphElimination(G,l)
- For each node [math]\displaystyle{ X_i }[/math] in [math]\displaystyle{ I }[/math]
- Connect all of the remaining neighbours of [math]\displaystyle{ X_i }[/math]
- Remove [math]\displaystyle{ X_i }[/math] from the graph
- End
Example:
For the graph G in figure 24
when we remove x1, G becomes as in figure 25
while if we remove x2, G becomes as in figure 26
An interesting thing to point out is that the order of the elimination matters a great deal. Consider the two results. If we remove one node the graph complexity is slightly reduced. But if we try to remove another node the complexity is significantly increased. The reason why we even care about the complexity of the graph is because the complexity of a graph denotes the number of calculations that are required to answer questions about that graph. If we had a huge graph with thousands of nodes the order of the node removal would be key in the complexity of the algorithm. Unfortunately, there is no efficient algorithm that can produce the optimal node removal order such that the elimination algorithm would run quickly. If we remove one of the leaf first, then the largest clique is two and computational complexity is of order
Moralization
So far we have shown how to use elimination to successively remove nodes from an undirected graph. We know that this is useful in the process of marginalization. We can now turn to the question of what will happen when we have a directed graph. It would be nice if we could somehow reduce the directed graph to an undirected form and then apply the previous elimination algorithm. This reduction is called moralization and the graph that is produced is called a moral graph.
To moralize a graph we first need to connect the parents of each node together. This makes sense intuitively because the parents of a node need to be considered together in the undirected graph and this is only done if they form a type of clique. By connecting them together we create this clique.
After the parents are connected together we can just drop the orientation on the edges in the directed graph. By removing the directions we force the graph to become undirected.
The previous elimination algorithm can now be applied to the new moral graph. We can do this by assuming that the probability functions in directed graph
Example:
I =
When we moralize the directed graph in figure 27, we obtain the
undirected graph in figure 28.
Elimination Algorithm on Trees
Definition of a tree:
A tree is an undirected graph in which any two vertices are connected by exactly one simple path. In other words, any connected graph without cycles is a tree.
If we have a directed graph then we must moralize it first. If the moral graph is a tree then the directed graph is also considered a tree.
Belief Propagation Algorithm (Sum Product Algorithm)
One of the main disadvantages to the elimination algorithm is that the ordering of the nodes defines the number of calculations that are required to produce a result. The optimal ordering is difficult to calculate and without a decent ordering the algorithm may become very slow. In response to this we can introduce the sum product algorithm. It has one major advantage over the elimination algorithm: it is faster. The sum product algorithm has the same complexity when it has to compute the probability of one node as it does to compute the probability of all the nodes in the graph. Unfortunately, the sum product algorithm also has one disadvantage. Unlike the elimination algorithm it can not be used on any graph. The sum product algorithm works only on trees.
For undirected graphs if there is only one path between any two pair of nodes then that graph is a tree (Fig.29). If we have a directed graph then we must moralize it first. If the moral graph is a tree then the directed graph is also considered a tree (Fig.30).


For the undirected graph
We know that in general we can not convert a directed graph into an undirected graph. There is however an exception to this rule when it comes to trees. In the case of a directed tree there is an algorithm that allows us to convert it to an undirected tree with the same properties.
Take the above example (Fig.30) of a directed tree. We can write the joint probability distribution function as:
If we want to convert this graph to the undirected form shown in (Fig.
- If
is the root then: . - If
is NOT the root then: . - If
= then: .
\end{thinlist} So now we can rewrite the above equation for (Fig.30) as:
Elimination Algorithm on a Tree<ref name="Pool"/>

We will derive the Sum-Product algorithm from the point of view
of the Eliminate algorithm. To marginalize
where,
which is essentially (potential of the node)
The term "
In general,
Note: It is important to know that BP algorithm gives us the exact solution only if the graph is a tree, however experiments have shown that BP leads to acceptable approximate answer even when the graphs has some loops.
Elimination To Sum Product Algorithm<ref name="Pool"/>

The Sum-Product algorithm allows us to compute all marginals in the tree by passing messages inward from the leaves of the tree to an (arbitrary) root, and then passing it outward from the root to the leaves, again using the above equation at each step. The net effect is that a single message will flow in both directions along each edge. (See Fig.32) Once all such messages have been computed using the above equation, we can compute desired marginals. One of the major advantages of this algorithm is that messages can be reused which reduces the computational cost heavily.
As shown in Fig.32, to compute the marginal of
Suppose that we want to compute the marginal of

Since the messages can be "reused", marginals over all possible elimination orderings can be computed by computing all possible messages which is small in numbers compared to the number of possible elimination orderings.
The Sum-Product algorithm is not only based on the above equation, but also Message-Passing Protocol. Message-Passing Protocol tells us that a node can send a message to a neighboring node when (and only when) it has received messages from all of its other neighbors.
For Directed Graph
Previously we stated that:
Using the above equation (
Now we denote:
Since the sets, F and E, add up to
We are interested in finding the conditional probability. We
substitute previous results, (
For Undirected Graphs
We denote
Max-Product
Because multiplication distributes over max as well as sum:
Formally, both the sum-product and max-product are commutative semirings.
We would like to find the Maximum probability that can be achieved by some set of random variables given a set of configurations. The algorithm is similar to the sum product except we replace the sum with max.
Example:
Consider the graph in Figure.33.
Maximum configuration
We would also like to find the value of the
In many cases we want to use the log of this expression because the numbers tend to be very high. Also, it is important to note that this also works in the continuous case where we replace the summation sign with an integral.
Parameter Learning
The goal of graphical models is to build a useful representation of the input data to understand and design learning algorithm. Thereby, graphical model provide a representation of joint probability distribution over nodes (random variables). One of the most important features of a graphical model is representing the conditional independence between the graph nodes. This is achieved using local functions which are gathered to compose factorizations. Such factorizations, in turn, represent the joint probability distributions and hence, the conditional independence lying in such distributions. However that doesn’t mean the graphical model represent all the necessary independence assumptions.
Basic Statistical Problems
In statistics there are a number of different 'standard' problems that always appear in one form or another. They are as follows:
- Regression
- Classification
- Clustering
- Density Estimation
Regression
In regression we have a set of data points
Once the relationship has been determined we can give a functional value to the following expression. In this way we can determine the value (or distribution) of y if we have the value for x.
Classification
In classification we also have a set of data points which each contain set features

We would like to obtain the probability distribution of the following equation where c is the class and x and y are the data points. In simple terms we would like to find the probability that this point is in class c when we know that the values of x and Y are x and y.
Clustering
Clustering is unsupervised learning method that assign different a set of data point into a group or cluster based on the similarity between the data points. Clustering is somehow like classification only that we do not know the groups before we gather and examine the data. We would like to find the probability distribution of the following equation without knowing the value of c.
Density Estimation
Density Estimation is the problem of modeling a probability density function p(x), given a finite number of data points drawn from that density function.
We can use graphs to represent the four types of statistical problems that have been introduced so far. The first graph (Fig.36(a)) can be used to represent either the Regression or the Classification problem because both the X and the Y variables are known. The second graph (Fig.36(b)) we see that the value of the Y variable is unknown and so we can tell that this graph represents the Clustering and Density Estimation situation.

Likelihood Function
Recall that the probability model
where
where
Since
Symbolically, we can interpret this as follows:
where we see that in the Bayesian approach the likelihood can be viewed as a data-dependent operator that transforms between the prior probability and the posterior probability.
Maximum likelihood
The idea of estimating the maximum is to find the optimum values for the parameters by maximizing a likelihood function form the training data. Suppose in particular that we force the Bayesian to choose a
particular value of
(i) the mean of the posterior (expectation):
is called Bayes estimate.
OR
(ii) the mode of posterior:
Note that MAP is Maximum a posterior.
When the prior probabilities,
When the prior is not taken to be uniform, the MAP estimate will be the maximization over probability distributions(the fact that the logarithm is a monotonic function implies that it does not alter the optimizing value).
Thus, one has:
as an alternative expression for the MAP estimate.
Here,
Example : Bernoulli trials
Consider the simple experiment where a biased coin is tossed four times. Suppose now that we also have some data
e.g.
where the conditional probability is
We would now like to use the ML technique.Since all of the variables are iid then there are no dependencies between the variables and so we have no edges from one node to another.
How do we find the joint probability distribution function for these variables? Well since they are all independent we can just multiply the marginal probabilities and we get the joint probability.
This is in fact the likelihood that we want to work with. Now let us try to maximise it:
Take the derivative and set it to zero:
Where:
NH = number of all the observed of heads
NT = number of all the observed tails
Hence, [math]\displaystyle{ NT + NH = n }[/math]
And now we can solve for
Example : Multinomial trials
Recall from the previous example that a Bernoulli trial has only two outcomes (e.g. Head/Tail, Failure/Success,…). A Multinomial trial is a multivariate generalization of the Bernoulli trial with K number of possible outcomes, where K > 2. Let
and
Consider the example of rolling a die M times and recording the number of times each of the six die's faces observed. Let
Let
Take the derivatives and set it to zero:
Example: Univariate Normal
Now let us assume that the observed values come from normal distribution.
\includegraphics{images/fig4Feb6.eps}
\newline
Our new model looks like:
Now to find the likelihood we once again multiply the independent marginal probabilities to obtain the joint probability and the likelihood function.
Now, since our parameter theta is in fact a set of two parameters,
we must estimate each of the parameters separately.
Discriminative vs Generative Models

(beginning of Oct. 18)
If we call the evidence/features variable

Given
Discriminative approach used in classification is displayed in terms of a graph in Figure 36ii. However, in discriminative models the dependencies between various random variables are not explicitly defined. We need to estimate the conditional probability, i.e.
Sometimes, it becomes very hard to compute
Markov Models
Markov models, introduced by Andrey (Andrei) Andreyevich Markov as a way of modeling Russian poetry, are known as a good way of modeling those processes which progress over time or space. Basically, a Markov model can be formulated as follows:
Which can be interpreted by the dependence of the current state of a variable on its last
Maximum Entropy Markov model is a type of Markov model, which makes the current state of a variable dependant on some global variables, besides the local dependencies. As an example, we can define the sequence of words in a context as a local variable, as the appearance of each word depends mostly on the words that have come before (n-grams). However, the role of POS (part of speech tagging) can not be denied, as it affect the sequence of words very clearly. In this example, POS are global dependencies, whereas last words in a row are those of local.
Markov Chain
"The simplest Markov model is the Markov chain. It models the state of a system with a random variable that changes through time. In this context, the Markov property suggests that the distribution for this variable depends only on the distribution of the previous state." <ref>[4]</ref> It is worth to note that alternatively Markov property can be explained as:"Given the current state the previous and future states are independent.".
Hidden Markov Models (HMM)
Markov models fail to address a scenario, in which, a series of states cannot be observed except they are probabilistic function of those hidden states. Markov models are extended in these scenarios where observation is a probability function of state. An example of a HMM is the formation of DNA sequence. There is a hidden process that generates amino acids depending on some probabilities to determine an exact sequence. Main questions that can be answered with HMM are the following:
- How can one estimate the probability of occurrence of an observation sequence?
- How can we choose the state sequence such that the joint probability of the observation sequence is maximized?
- How can we describe an observation sequence through the model parameters?

An example of HMM of oder 1 is displayed in Figure 37. Most common example is in the study of gene analysis or gene sequencing, and the joint probability is given by

HMM of order 2 is displayed in Figure 38. Joint probability is given by
A Hidden Markov Model (HMM) is a directed graphical model with two layers of nodes. The hidden layer of nodes represents a set of unobserved discrete random variables with some state space as the support. Isolated the first layer represents as a discrete time Markov Chain. These random variables are sequentially connected and which can often represent a temporal dependancy. In this model we do not observe the states (nodes in layer 1) we instead observe features that may be dependant on the states; this set of features represents the second observed layer of nodes. Thus for each node in layer 1 we have a corresponding dependant node in layer 2 which represents the observed features. Please see the Figure 39 for a visual depiction of the graphical structure.
In other words, in HMM, it's guaranteed that, given the present state, the future state is independent of the past. The future state depends only on the present state.

The nodes in the first and second layers are denoted by
The parameters that need to be estimated are
Defining some notation:
Note that we will be using a homogenous descrete time Markov Chain with finite state space for the first layer.
For the HMM our data comes from the output layer:
We can use
We can also define:
Now, if we take Y to be multinomial we get:
where
The random variable Y does not have to be multinomial, this is just an example.
We can write the joint pdf using the structure of the HMM model graphical structure.
Substituting our representations for the 3 probabilities:
We can go on to the E-Step with this new joint pdf. In the E-Step we need to find the expectation of the missing data given the observed data and the initial values of the parameters. Suppose that we only sample once so
Then we take the expectation for the E-Step:
If we continue with our multinomial example then we would get:
So now we need to calculate
Let
Let
We could use the sum product algorithm to calculate these equations but in this case we will introduce a new algorithm that is called the
The - Algorithm
We have from before the expectation:
As usual we take the derivative with respect to
For
Notice here that all of these parameters have been solved in terms of
Now due to the Markovian Memoryless property.
Define
Once we have
To calculate
For
Where we begin with:
Then for
Where we now begin from the other end:
Once both
HMM's are widely used in speech recognition applications as their temporal nature is ideal for such applications.
Graph Structure
Up to this point, we have covered many topics about graphical models, assuming that the graph structure is given. However, finding an optimal structure for a graphical model is a challenging problem all by itself. In this section, we assume that the graphical model that we are looking for is expressible in a form of tree. And to remind ourselves of the concept of tree, an undirected graph will be a tree, if there is one and only one path between each pair of nodes. For the case of directed graphs, however, on top of the mentioned condition, we also need to check if all the nodes have at most one parent - which is in other words no explaining away kinds of structures.
Firstly, let us show you how it does not affect the joint distribution function, if a graph is directed or undirected, as long as it is tree. Here is how one can write down the joint ditribution of the graph of Fig. XX.
Now, if we change the direction of the connecting edge between
which can be simply re-written as:
which is the same as the first function. We will depend on this very simplistic observation and leave the proof to the enthusiast reader.
Maximum Likelihood Tree
We want to compute the tree that maximizes the likelihood for a given set of data. Optimality of a tree structure can be discussed in terms of likelihood of the set of variables. By doing so, we can define a fully connected, weighted graph by setting the edge weights to the likelihood of the occurrence of the connecting nodes/random variables and then by running the maximum weight spanning tree. Here is how it works.
We have defined the joint distribution as follows:
Where
Maximizing the joint probability distribution over the given set of data samples
And by taking the logarithm of
The first term in the above equation does not convey anything about the topology or the structure of the tree as it is defined over single nodes. As much as the optimization of the tree structure is concerned, the probability of the single nodes may not play any role in the optimization, so we can define the cost function for our optimization problem as such:
Where the sub r is for reduced. By replacing the probability functions with the frequency of occurence of each state, we will have:
Where we have assumed that
This is how it has been figured out how to define weights for the edges of a fully connected graph. Now, it is required to run the maximum weight spanning tree on the resulting graph to find the optimal structure for the tree. It is important to note that before developing graphical models this problem has been solved in graph theory. Here our problem was completely a probabilistic problem but using graphical models we could find an equivalent graph theory problem. This show how graphical models can help us to use powerful graph theory tools to solve probabilistic problems.
Latent Variable Models
(beginning of Oct. 20) Assuming that we have thoroughly observed, or even identified all of the random variables of a model can be a very naive assumption, as one can think of many instances of contrary cases. To make a model as rich as possible -there is always a trade-off between richness and complexity, so we do not like to inject unnecessary complexity to our model either- the concept of latent variables has been introduced to the graphical models.
First let's define latent variables. "Latent variables are variables that are not directly observed but are rather inferred (through a mathematical model) from other variables that are observed (directly measured). Mathematical models that aim to explain observed variables in terms of latent variables are called latent variable models."<ref>[5]</ref>
Depending on the position of an unobserved variable,
The use of latent variables makes a model harder to analyze and to learn. The use of log-likelihood used to make the target function easier to obtain, as the log of product will change to sum of logs, but this will not be the case, when one introduces latent variables to a model, as the resulting joint probability function comes with a sum, which makes the effect of log on product impossible.
As an example of latent variables, one can think of a mixture density model. There are different models come together to build the final model, but it takes one more random variable to say which one of those models to use at the presence of each new sample point. This will affect both the learning and recalling phases.
EM Algorithm
Oct. 25th
Introduction
In last section the graphical models with latent variables were discussed. It was mentioned that, for example, if fitting typical distributions on a data set is too complex, one may think of modeling the data set using a mixture of famous distribution such as Gaussian. Therefore, a hidden variable is needed to determine weight of each Gaussian model. Parameter learning in graphical models with latent variables is more complicated in comparison with the models with no latent variable.\
Consider Fig.40 which depicts a simple graphical model with two nodes. As the convention, unobserved variable

For simplicity, we assume there are two classes generating the data set
On the contrary, if
EM Method
EM (Expectation-Maximization) algorithm is "an iterative method for finding maximum likelihood or maximum a posterior (MAP) estimates of parameters in statistical models, where the model depends on unobserved latent variables."<ref name="Em">[6]</ref>
There are two applications of the EM algorithm. The first is when the data has missing variables. The second occurs when obtaining the maximum likelihood estimate is very complicated and hence introducing a new variable while assuming that its value is unknown (hidden) considerably simplifies computations.<ref>Jeff A. Bilmes, "A Gentle Tutorial of the EM Algorithm and its Application to Parameter Estimation for Gaussian Mixture and Hidden Markov Models", 1998</ref>
"The EM iteration alternates between performing an expectation (E) step, which computes the expectation of the log-likelihood evaluated using the current estimate for the parameters, and a maximization (M) step, which computes parameters maximizing the expected log-likelihood found on the E step. These parameter-estimates are then used to determine the distribution of the latent variables in the next E step."<ref name="Em"/> Consider a probabilistic model in which we collectively denote all of the observed variables by X and all of the hidden variables by Z resulting in a simple graphical model with two nodes (Fig. 40). The joint distribution
which is called "complete log likelihood". In the above equation the x values represent data as before and the Z values represent missing data (sometimes called latent data) at that point. Now the question here is how do we calculate the values of the parameters
To simplify the problem we define the following type of likelihood:
which is called "incomplete log likelihood". We can rewrite the incomplete likelihood in terms of the complete likelihood. This equation is in fact the discrete case but to convert to the continuous case all we have to do is turn the summation into an integral.
Since the z has not been observed that means that
Jensen's Inequality
In order to properly derive the formula for the EM algorithm we need to first introduce the following theorem.
For any concave function f:
This can be shown intuitively through a graph. In the (Fig. 41) point A is the point on the function f and point B is the value represented by the right side of the inequality. On the graph one can see why point A will be smaller than point B in a convex graph.
For us it is important that the log function is concave , and thus:
The function
In the first step we assume
E-Step
M-Step
M-Step Explanation
Since the second part of the equation is only a constant with respect to
E-Step Explanation
In this step we are trying to find an estimate for
Claim: It can be shown that to maximize the auxiliary function one should set
Recall that
The EM algorithm is a two-stage iterative optimization technique for finding
maximum likelihood solutions. Suppose that the current value of the parameter vector is
Alternative steps for the EM algorithms
From the above results we can find an alternative representation for the EM algorithm reproducing it to:
E-Step
Find
M-Step
Maximise
The EM Algorithm is probably best understood through examples.
EM Algorithm Example
Suppose we have the two independent and identically distributed random variables:
In our case
We take our derivative:
And now we can try the same problem with the EM Algorithm.
E-Step
M-Step
Now we pick an initial value for
And as we can see after a number of steps the value converges to the correct answer of 0.2. In the next section we will discuss a more complex model where it would be difficult to solve the problem without the EM Algorithm.
Mixture Models
In this section we discuss what will happen if the random variables are not identically distributed. The data will now sometimes be sampled from one distribution and sometimes from another.
Mixture of Gaussian
Given
We would like to find:
We have no missing data here so we can try to find the parameter estimates using the ML method.
And then we need to take the log to find
It is actually easier to apply the EM algorithm. The only thing is that the EM algorithm works with missing data and here we have all of our data. The solution is to introduce a latent variable z. We are basically introducing missing data to make the calculation easier to compute.
Now we have a data set that includes our latent variable
We can calculate the joint pdf by:
Let,
and
We can write the joint pdf as:
From the joint pdf we can get the likelihood function as:
Then take the log and find the log likelihood:
In the E-step we need to find the expectation of
For now we can assume that
In M-step, we have to update our data by assuming the expectation is fixed
Taking partial derivatives of the complete log likelihood with respect to the parameters and set them equal to zero, we get our estimated parameters at (t+1).
We can verify that the results of the estimated parameters all make sense by considering what we know about the ML estimates from the standard Gaussian. But we are not done yet. We still need to compute
We can now combine the two steps and we get the expectation
Using the above results for the estimated parameters in the M-step we can evaluate the parameters at (t+2),(t+3)...until they converge and we get our estimated value for each of the parameters.
The mixture model can be summarized as:
- In each step, a state will be selected according to
. - Given a state, a data vector is drawn from
. - The value of each state is independent from the previous state.
A good example of a mixture model can be seen in this example with two coins. Assume that there are two different coins that are not fair. Suppose that the probabilities for each coin are as shown in the table.
\begin{tabular}{|c|c|c|}
\hline & H & T
coin1 & 0.3 & 0.7
coin2 & 0.1 & 0.9
\hline
\end{tabular}
We can choose one coin at random and toss it in the air to see the outcome. Then we place the con back in the pocket with the other one and once again select one coin at random to toss. The resulting outcome of: HHTH \dots HTTHT is a mixture model. In this model the probability depends on which coin was used to make the toss and the probability with which we select each coin. For example, if we were to select coin1 most of the time then we would see more Heads than if we were to choose coin2 most of the time.
Alternative Algorithms
There has been different algorithms proposed, besides the EM algorithm, which try to fulfill the same objective as EM algorithm does. The objective is to make an inference, based on the given joint distribution. It involves approximating marginal distribution of a subset of variables, where there might exist a number of latent variable. One of those algorithms which is a deterministic algorithm just like EM, is variational Bayesian method. This algorithm can be seen as a variety of EM algorithm, which applies to the maximum a posterior (MAP), instead of class-conditional. <ref>[7]</ref>
Another approach which is, unlike the two previous ones, a randomized algorithm is the Gibbs Sampling algorithm. The basic idea behind this algorithm is that it can be more convenient to start generating samples of a distribution in order to find a marginal distribution, rather than getting involved in some troublesome optimization problems. The random nature of this algorithms leads to different answers each time that one runs the algorithm, given the same problem and the same initial solution. Gibbs sampling can be thought of as a special case of Markov Chain Monte Carlo algorithm.<ref>[8]</ref>
Conditional random fields
(Nov 3rd lecture)
Motivation
Hidden Markov models (HMMs) are widely used in computation biology to analyze genome sequences. These models are described by a joint probability distribution to the observed and label sequences. The joint distribution should be defined over all possible observation sequences; which is a complex process in many applications. This lead to the introduction of conditional random fields (CRF), which is a statistical framework used to build various probabilistic models to analyze gene sequence data. One of the main advantages over HMM's is to relax the conditions on independencies over several random variables. For a given observed sequence, CRF's estimates the probabilities for a possible label sequence. and also allows multiple interacting features. "CRF's are usually used for labelling or parsing of sequential data, such as natural language text and are also used in computer vision" <ref>[9]</ref>.
Conditional distribution of CRF
CRF is an undirected graphical model that defines a distribution over labels for a given observation sequence. Let

If
where

An example is displayed in figure 42, which denotes Markov chain. The graph consists of only random variables
Joint distribution can be defined in terms of exponential terms as follows:
Since, it is hard to account for all possible realizations of
Notice that the normalization constant
or, it can be rewritten as follows:
In the above equation
Replacing the normalization factor with the exponential term, we obtain:
The summation over
- It is mainly used in classification given by:
- We don't need to model distribution over inputs.
If
Parameter estimation
Questions that can be posed are the following:
- What is the possible label sequence for a given observation sequence?
- What are the parameters to maximize the conditional distribution?
Let
Notice that log-likelihood function is concave and the parameter
where,
Markov logic networks
A new technique developed by the artificial intelligence community is to combine first order logic with probability theory, called as Markov logic network (MLN). One of the main reasons to arrive at this method is to represent large amounts of data in a compact and precise manner. First order logic is a set of formulas, and a weight is attached to each of these formulas. Each formula is made up of predicates, constants, variables and functions. Predicates are used to represent various relationships between objects in the specified domain. A first order knowledge base (KB) is a set of formulas using first order logic.
Some of the main applications of Markov logic networks are tasks in statistical relational learning, like collective classification, link prediction, link-based clustering, social network modeling and object identification. <ref>Matthew Richardson, Pedro Domingos, "Markov Logic Networks", Department of Computer Science and Engineering, University of Washington. Available: [10] </ref>
It is quite evident that KB can take only boolean values, which can be thought of a hard constraint. The main purpose of MLN is to soften these constraints. Each formula is given a weight denoting the strength of that constraint in the domain. Hence higher the weight implies that constraint is strong. Markov networks and Bayesian networks can also be represented by MLN.
Definition: MLN is a set of pairs
One common example is the following:
- Smoking causes cancer
- Friends have similar smoking habits
Step1: We write the above two statements in terms of formulas using logical operators as follows:
Step2:
We associate weights to each of the above formulas, say
Suppose A and B (represent persons) are any two constants, then the above set of formulas are represented in terms of an Markov ground network as follows:

Each node resembles an ground atom, and an edge between a pair of atoms. Several questions can be answered from the ground network designed in Figure 44 such as: if A is a friend of B and B does not smoke, then What is the probability that A has cancer? MLN are frame works to address Markov networks. Probability distribution of a world is given by:
where,

Here is another example:
- Smoking causes cancer
- If there are two friends and one among them has smoking habit, then there is a chance that other friend might also get cancer (assuming the biological system is weak and inhaling might lead to mutations)
The above sentences can be written in terms of formulas as follows:
Appendix: Graph Drawing Tools
Graphviz
"Graphviz is open source graph visualization software. Graph visualization is a way of representing structural information as diagrams of abstract graphs and networks. It has important applications in networking, bioinformatics, software engineering, database and web design, machine learning, and in visual interfaces for other technical domains." <ref>http://www.graphviz.org/</ref>
There is a wiki extension developed, called Wikitex, which makes it possible to make use of this package in wiki pages. Here is an example.
AISee
AISee is a commercial graph visualization software. The free trial version has almost all the features of the full version except that it should not be used for commercial purposes.
TikZ
"TikZ and PGF are TeX packages for creating graphics programmatically. TikZ is build on top of PGF and allows you to create sophisticated graphics in a rather intuitive and easy manner." <ref> http://www.texample.net/tikz/ </ref>
Xfig
"Xfig" is an open source drawing software used to create objects of various geometry. It can be installed on both windows and unix based machines. Website
References
<references />