% Table of Contents
% %%%%% % Jan 4 Introduction / Motivation % %%%%%
% %%%%% % Jan 6 % %%%%% ---++ Introduction ---+++ Notation
We will begin with short section about the notation used in these notes. \newline Capital letters will be used to denote random variables and lower case letters denote observations for those random variables:
- X_1,\ X_2,\ \dots,\ X_$ random variables
- x_1,\ x_2,\ \dots,\ x_$ observations of the random variables
The joint _probability mass function_ can be written as: $$ P( X_1 = x_1, X_2 = x_2, \dots, X_n = x_n )$$ or as shorthand, we can write this as $p( x_1, x_2, \dots, x_n )$. In these notes both types of notation will be used. We can also define a set of random variables $X_Q$ where Q represents a set of subscripts.
Let $A = \1,4\$, so $X_A = \X_1, X_4\$;\ \ $A$ is the set of indices for the r.v. $X_A$.
Also let $B = \2\,\ X_B = \X_2\$ so we can write $$ P( X_A | X_B ) = P( X_1 = x_1, X_4 = x_4 | X_2 = x_2 ).$$
---+++ Graphical Models
Graphs can be represented as a pair of verticies and edges: $G = (V, E).$
- $V$ is the set of nodes (vertices).
- $E$ is the set of edges.
If the edges have a direction associated with them then we consider the graph to be directed as in Figure \refig:dirGrap, otherwise the graph is undirected as in Figure \refig:undirGrap.
% Directed and Undirected Graphs [ht] c 2.5i
\includegraphicimages/directed.p \captioA Directed Graph \labefig:dirGrap
\includegraphicimages/undirected.p \captioAn Undirected Graph \labefig:undirGrap
We will use graphs in this course to represent the relationship between different random variables.
---++++ Directed graphical models
In the case of directed graphs, the direction of the arrow indicates "causation". For example:
$A \longrightarrow B$: \ $A$ "causes" $B$
In this case we must assume that our directed graphs are _acyclic_ . If our causation graph contains a cycle then it would mean that for example:
- A causes B
- B causes C
- C causes A again.
Clearly, this would confuse the order of the events. An example of a graph with a cycle can be seen in Fugure \refig:CyclicGrap. Such a graph could not be used to represent causation. The graph in Figure \refig:AcyclicGrap does not have cycle and we can say that the node $X_1$ causes, or affects, $X_2$ and $X_3$ while they in turn cause $X_4$.
[ht] c 2.5i
\hspac0.2i\includegraphicimages/cyclic.p \captioA Cyclic Graph \labefig:CyclicGrap
\psfrah3E[cc][cc$X_1 \psfraA18[cc][cc$X_2 \psfraapq[cc][cc$X_3 \psfraJrh[cc][cc$X_4 \includegraphicimages/acyclic.p
\captioAn Acyclic Graph \labefig:AcyclicGrap
We will consider a 1-1 map between our graph's vertices and a set of random variables. 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.
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 \refig:wetGrassExampl. [ht]
\includegraphicimages/wetgrass.p \captioThe Wet Grass Example \labefig:wetGrassExampl $V = \ C, R, S, W \$
This directed graph shows the relation between the 4 random variables. If we have the joint probability $P(C,R,S,W)$, then we can answer many queries about this system.
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 $2^4 = 16$ different probabilities for this simple example. The table bellow that conatains all of the probabilities and their corresponding boolean values for each random variable is called an _interaction table_ .
& c|c|c|c| \hspac1e & $C$ & $R$ & $S$ & $W$ \\\hline & 0 & 0 & 0 & 0
& 0 & 0 & 0 & 1
& 0 & 0 & 1 & 0
& . & . & . & .
& . & . & . & .
& . & . & . & .
& 1 & 1 & 1 & 1
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 $240$ rows! The purpose of the graph is to help avoid this intractability by considering only the variables that are directly related. In the wet grass example Sprinkler (S) and Rain (R) are not directly related.
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 $i \in V$,
- $\pi_i$: is the set of parents of $i$
- ex. $\pi_R = C$ \ (the parent of $R = C$)
- $f_i(x_i, x\pi_)$: is the joint p.d.f. of $i$ and $\pi_i$ for which it is true that:
- $f_i$ is nonnegative for all $i$
- $\displaystyle\sumx_ f_i(x_i, x\pi_) = 1$
- Claim:* There is a family of probability functions $\displaystyle P(X_V) = \prodi=^n f_i(x_i, x\pi_)$ where this function is nonnegative, and
\labeeqn:WetGras \displaystyle\sumx_\sumx_\cdots\sumx_ P(X_V) = 1
To show the power of this claim we can prove the equation (\reeqn:WetGras) for our wet grass example:
P(X_V) & = & P(C,R,S,W)
& = & f(C) f(R,C) f(S,C) f(W,S,R)
We want to show that
\displaystyle\sum_C\sum_R\sum_S\sum_W P(C,R,S,W) & = & \displaystyle\sum_C\sum_R\sum_S\sum_W f(C) f(R,C) f(S,C) f(W,S,R)
& = & 1.
Consider factors $f(C)$, $f(R,C)$, $f(S,C)$: they do not depend on $W$, so we can write this all as
& & \sum_C\sum_R\sum_S f(C) f(R,C) f(S,C) \cancelt1\sum_W f(W,S,R
& = & \sum_C\sum_R f(C) f(R,C) \cancelt1\sum_S f(S,C
& = & \cancelt1\sum_C f(C \cancelt1\sum_R f(R,C
& = & 1
since we had already set $\displaystyle \sumx_ f_i(x_i, x\pi_) = 1$.
Let us consider another example with a different directed graph.
Consider the simple directed graph in Figure \refig:Simple4NodeGrap: [!ht]
\psfrapvI[cc][cc$X_1 \psfraNy4[cc][cc$X_2 \psfraRzs[cc][cc$X_3 \psfraELr[cc][cc$X_4 \includegraphicimages/1234.p \captioSimple 4 Node Graph \labefig:Simple4NodeGrap
Assume that we would like to calculate the following: $ p(x_3|x_2) $. We know that we can write the joint probability as: $$ p(x_1,x_2,x_3,x_4) = f(x_1) f(x_2,x_1) f(x_3,x_2) f(x_4,x_3) $$
We can also make use of Bayes' Rule here: $p(x_3|x_2) = \fra\displaystyle p(x_2,x_3)\displaystyle p(x_2$
p(x_2,x_3) & = & \sumx_ \sumx_ p(x_1,x_2,x_3,x_4) \hspac1i \hbo(marginalization
& = & \sumx_ \sumx_ f(x_1) f(x_2,x_1) f(x_3,x_2) f(x_4,x_3)
& = & \sumx_ f(x_1) f(x_2,x_1) f(x_3,x_2) \cancelt1\sumx_ f(x_4,x_3
& = & f(x_3,x_2) \sumx_ f(x_1) f(x_2,x_1).
We also need
p(x_2) & = & \sumx_\sumx_\sumx_ f(x_1) f(x_2,x_1) f(x_3,x_2) f(x_4,x_3)
& = & \sumx_\sumx_ f(x_1) f(x_2,x_1) f(x_3,x_2)
& = & \sumx_ f(x_1) f(x_2,x_1).
p(x_3|x_2) & = & \fra\displaystyle f(x_3,x_2) \sumx_ f(x_1) f(x_2,x_1)\displaystyle \sumx_ f(x_1) f(x_2,x_1
& = & f(x_3,x_2).
\labethm:condPro $$f_i(x_i,x\pi_) = p(x_i|x\pi_).$$ $$\displaystyle \therefore \ P(X_V) = \prodi=^n p(x_i|x\pi_)$$.
In our simple graph, the joint probability can be written as $$p(x_1,x_2,x_3,x_4) = p(x_1)p(x_2|x_1) p(x_3|x_2) p(x_4|x_3).$$
Instead, had we used the chain rule we would have obtained a far more complex equation: $$p(x_1,x_2,x_3,x_4) = p(x_1) p(x_2|x_1)p(x_3|x_2,x_1) p(x_4|x_3,x_2,x_1).$$
The _Markov Property_ , or _Memoryless Property_ is when the variable $X_i$ is only affected by $X_j$ and so the random varible $X_i$ given $X_j$ is independent of every other random variable. In our example the history of $x_4$ is completely determined by $x_3$.
By simply applying the Markov Property to the chain-rule formula we would also have obtained the same result.
% %%%%% % Jan 9 % %%%%% Now let us consider the joint probability of the following six-node example found in Figure \refig:SixNodeExampl. [ht]
\epsfxsize=1.9in \epsfysize=1.9in \epsfboimages/ClassicExample1.ep \captioSix Node Example \labefig:SixNodeExampl
If we use Theorem \rethm:condPro it can be seen that the joint probability density function for Figure \refig:SixNodeExampl can be written as follows: \fontsiz10 $$ P(X_1,X_2,X_3,X_4,X_5,X_6) = P(X_1)P(X_2|X_1)P(X_3|X_1)P(X_4|X_2)P(X_5|X_3)P(X_6|X_5,X_2) $$
Once again, we can apply the Chain Rule and then the Markov Property and arrive at the same result.
&& = P(X_1)P(X_2|X_1)P(X_3|X_2,X_1)P(X_4|X_3,X_2,X_1)P(X_5|X_4,X_3,X_2,X_1)P(X_6|X_5,X_4,X_3,X_2,X_1)
&& = P(X_1)P(X_2|X_1)P(X_3|X_1)P(X_4|X_2)P(X_5|X_3)P(X_6|X_5,X_2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ---+++ Independence %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
---++++ Marginal independence We can say that $X_A$ is marginally independant of $X_B$ if:
X_A \perp X_B : & &
P(X_A,X_B) & = & P(X_A)P(X_B)
P(X_A|X_B) & = & P(X_A)
---++++ Conditional independence We can say that $X_A$ is conditionally independant of $X_B$ given $X_C$ if:
X_A \perp X_B | X_C : & &
P(X_A,X_B | X_C) & = & P(X_A|X_C)P(X_B|X_C)
P(X_A|X_B,X_C) & = & P(X_A|X_C)
- 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 $i \in V$, $V_i$ is defined as a set of all nodes that appear earlier than i excluding $\pi_i$.
Let us consider the example of the six node figure given above (Figure \refig:SixNodeExampl). We can define $I$ as follows:
$$I = \1,2,3,4,5,6\ $$
We can then easily compute $V_i$ for say $i=3,6$.
$ V_3 = \2\, V_6 = \1,3,4\$
We would be interested in finding the conditional independence between random variables in this graph. We know $X_i \perp Xv_ | X\pi_$ for each $i$. So:
$X_1 \perp \phi | \phi$,
$X_2 \perp \phi | X_1$,
$X_3 \perp X_2 | X_1$,
$X_4 \perp \X_1,X_3\ | X_2$,
$X_5 \perp \X_1,X_2,X_4\ | X_3$,
$X_6 \perp \X_1,X_3,X_4\ | \X_2,X_5\$
To illustrate why this is true we can take a simple example. Show that: $$P(X_4|X_1,X_2,X_3) = P(X_4|X_2)$$
\fontsiz10 Proof: first, we know $$ P(X_1,X_2,X_3,X_4,X_5,X_6) = P(X_1)P(X_2|X_1)P(X_3|X_1)P(X_4|X_2)P(X_5|X_3)P(X_6|X_5,X_2)$$ \fontsiz12 then
P(X_4|X_1,X_2,X_3) & = & \fraP(X_1,X_2,X_3,X_4)P(X_1,X_2,X_3\\
& = & \fra\displaystyle \sumX_ \sumX_ P(X_1,X_2,X_3,X_4,X_5,X_6)\displaystyle \sumX_ \sumX_ \sumX_P(X_1,X_2,X_3,X_4,X_5,X_6
& = & \fraP(X_1)P(X_2|X_1)P(X_3|X_1)P(X_4|X_2)P(X_1)P(X_2|X_1)P(X_3|X_1
& = & P(X_4|X_2)
The other conditional independences can be proven through a similar process.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ---++ 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 independant. The Bayes Ball algorithm can not show that two nodes are dependant. 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.
---++++ Markov Chain In the following graph (Figure \refig:Marko) X is independent of Z given Y.
We say that: $X$ $\perp$ $Z$ $|$ $Y$
\epsfysize=0.72in \epsfboimages/Markov.ep \captioMarkov Chai \labefig:Marko
We can prove this independance:
P(Z|X,Y) & = & \fraP(X,Y,Z)P(X,Y\\
& = & \fraP(X)P(Y|X)P(Z|Y)P(X)P(Y|X
& = & P(Z|Y)
P(X,Y) & = & \displaystyle \sum_Z P(X,Y,Z)
& = & \displaystyle \sum_Z P(X)P(Y|X)P(Z|Y)
& = & P(X)P(Y | X) \displaystyle \sum_Z P(Z|Y) \\ & = & P(X)P(Y | X)
---++++ Hidden Cause In the Hidden Cause case we can say that X is idependant 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: $X$ $\perp$ $Z$ $|$ $Y$
\epsfysize=0.82in \epsfboimages/Hidden.ep \captioHidden Cause Grap \labefig:Hidde
The proof of the independence:
P(Z|X,Y) & = & \fraP(X,Y,Z)P(X,Y\\
& = & \fraP(X)P(Y|X)P(Z|Y)P(X)P(Y|X
& = & P(Z|Y)
The Hidden Cause case is best illustrated with an example:
\epsfifigure=images/plot44.ep \captioHidden Cause Exampl \labefig:HiddenExampl
In Figure \refig:HiddenExampl 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.
% %%%%% % Jan 11 % %%%%%
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: $X \amalg Z$.
\epsfxsize=1.5in \epsfysize=2.0in \epsfboimages/ExplainingAway.ep \captioThe missing edge between node X and node Z implies that there is a marginal independence between the two: $X \amalg Z \labefig:ExplainingAwa
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. \refig:ExplainingAwa).
To clarify these concepts, suppose Bob and Mary are supposed to meet for a noontime lunch. Consider the following events:
\[ late =\left\l
1, & if Mary is late
0, & otherwise \right.
\[ aliens =\left\l
1, & if aliens kidnapped Mary
0, & otherwise \right.
\[ watch =\left\l
1, & if Bob's watch is incorrect
0, & otherwise \right.
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:
% \nonumber to remove numbering (before each equation)
\labeeq:probP( late = 1 )
\labeeq:probP( aliens = 1 ~|~ late = 1 )
\labeeq:probP( aliens = 1 ~|~ late = 1, watch = 0 )
We expect $P( late = 1 ) < P( aliens = 1 ~|~ late = 1 )$ since $P( aliens = 1 ~|~ late = 1 )$ does not provide any information regarding Bob's watch. Similarly, we expect $P( aliens = 1 ~|~ late = 1 ) < P( aliens = 1 ~|~ late = 1, watch = 0 )$. Since $Eq.\reeq:prob \neq Eq.\reeq:prob$, _aliens_ and _watch_ are not independent given _late_ . To summarize,
* If we do not observe _late_ , then $aliens ~\amalg~ watch$ ($X ~\amalg~ Z$) * If we do observe _late_ , then $aliens ~\cance\amal~ watch ~|~ late$ ($X ~\cance\amal~ Z ~|~ Y$)
---+++ Bayes Ball Algorithm
\underlinGoal We wish to determine whether a given conditional statement such as $X ~\amalg~ X ~|~ X$ is true given a directed graph.
The algorithm is as follows:
- Shade nodes, $X$, that are conditioned on.
- The initial position of the ball is $X$.
- If the ball cannot reach $X$, then the nodes $X$ and
$X$ must be conditionally independent.
- If the ball can reach $X$, then the nodes $X$ and
$X$ 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 base rules which can be extended upon for more general graphs.
---++++ Markov Chain
\epsfxsize=5.0in \epsfysize=1.3in \epsfboimages/BB_Markov.ep \captio(a) When the middle node is shaded, the ball is blocked. (b) When the middle ball is not shaded, the ball passes through Y \labefig:BB_Marko
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. \refig:BB_Marko(a)), X and Z are conditionally independent ( $X ~\amalg~ Z ~|~ Y$ ) while in (Fig.\refig:BB_Marko(b)) X and Z are not necessarily independent.
---++++ Hidden Cause
\epsfxsize=5.0in \epsfysize=1.2in \epsfboimages/BB_Hidden.ep \captio(a) When the middle node is shaded, the ball is blocked. (b) When the middle ball is not shaded, the ball passes through Y \labefig:BB_Hidde
A ball traveling through Y will be blocked at Y if it is shaded. If Y is unshaded, then the ball passes through.
(Fig. \refig:BB_Hidde(a)) demonstrates that X and Z are conditionally independent when Y is shaded.
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.
\epsfxsize=5.0in \epsfysize=1.15in \epsfboimages/BB_ExplainingAway.ep \captio(a) When the middle node is shaded, the ball passes through Y. (b) When the middle ball is unshaded, the ball is blocked \labefig:BB_ExplainingAwa
---+++ Bayes Ball Examples ---++++ Example 1 In this first example, we wish to identify the behavior of a ball going from X to Y in two-node graphs.
\epsfxsize=4.0in \epsfysize=2.3in \epsfboimages/TwoNodesExamples.ep \captio(a)The ball is blocked at Y. (b)The ball passes through Y . (c)The ball passes through Y. (d) The ball is blocked at Y \labefig:TwoNodesExample
The four graphs in (Fig. \refig:TwoNodesExample) show different scenarios. In (a), the ball is blocked at Y. In (b) the ball passes through Y. In both of these cases, we use the rules of the _Explaining Away Canonical Graph_ (refer to Fig.\refig:BB_ExplainingAwa). Finally, for the last two graphs, we used the rules of the \empHidden Cause Canonical Grap (Fig. \refig:BB_Hidde). 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:
\[ burglary =\left\l
1, & if your house is being burglarized
0, & if your house is not being burglarized \right.
\[ earthquake =\left\l
1, & if there is an earthquake
0, & if there is no earthquake \right.
\[ alarm =\left\l
1, & if your alarm is ringing
0, & if your alarm is off \right.
\[ report =\left\l
1, & if a police report has been written
0, & if no police report has been written \right.
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 possible for a police report to be issued.
We can use the _Bayes Ball Algorithm_ to deduce conditional independence properties from the graph. Firstly, consider figure (\refig:AlarmExample(a)) and assume we are trying to determine whether there is conditional independence between the _burglary_ and _earthquake_ events. In figure (\refig:AlarmExample(a)), a ball starting at the _burglary_ event is blocked at the _alarm_ node.
\epsfxsize=4.0in \epsfysize=3in \epsfboimages/AlarmExample1.ep \captioIf we only consider the events _burglary_ , _earthquake_ , and _alarm_ , we find that a ball traveling from _burglary_ to _earthquake_ would be blocked at the _alarm_ node. However, if we also consider the _report_ node, we can find a path between _burglary_ and _earthquake_ \labefig:AlarmExample
Nonetheless, this does not prove that the _burglary_ and _earthquake_ events are independent. Indeed, (Fig. \refig:AlarmExample(b)) disproves this as we have found an alternate path from _burglary_ to _earthquake_ passing through _report_ . It follows that $burglary ~\cance\amal~ earthquake ~|~ report$
---++++ Example 3
Referring to figure (Fig. \refig:LineExample), we wish to determine whether the following conditional probabilities are true:
% \nonumber to remove numbering (before each equation)
\labeeq:cX ~\amalg~ X ~|~ X
\labeeq:cX ~\amalg~ X ~|~ \X,X\
\epsfxsize=3.0in \epsfysize=0.74in \epsfboimages/LineExample1.ep \captioSimple Markov Chain grap\labefig:LineExample
To determine if the conditional probability Eq.\reeq:c is true, we shade node $X$. This blocks balls traveling from $X$ to $X$ and proves that Eq.\reeq:c is valid.
After shading nodes $X$ and $X$ and applying the _Bayes Balls Algorithm_ , we find that the ball travelling from $X$ to $X$ is blocked at $X$. Similarily, a ball going from $X$ to $X$ is blocked at $X$. This proves that Eq.\reeq:c also holds.
---++++ Example 4
\epsfxsize=2.0in \epsfysize=1.5in \epsfboimages/ClassicExample1.ep \captioDirected grap\labefig:ClassicExample
Consider figure (Fig. \refig:ClassicExample). Using the \empBayes Ball Algorith we wish to determine if each of the following statements are valid:
% \nonumber to remove numbering (before each equation)
\labeeq:cX ~\amalg~ \X,X\ ~|~ X
\labeeq:cX ~\amalg~ X ~|~ \X,X\
\labeeq:cX ~\amalg~ X ~|~ \X,X\
\epsfxsize=6in \epsfysize=2in \epsfboimages/ClassicExample2.ep \captioa) A ball cannot pass through $X$ or $X$.
b) A ball cannot pass through $X$ or $X$. c) A ball can pass from $X$ to $X$.\labefig:ClassicExample
To disprove Eq.\reeq:c, we must find a path from $X$ to $X$ and $X$ when $X$ is shaded (Refer to Fig.\refig:ClassicExample(a)). Since there is no route from $X$ to $X$ and $X$ we conclude that Eq.\reeq:c is true.
Similarly, we can show that there does not exist a path between $X$ and $X$ when $X$ and $X$ are shaded (Refer to Fig.\refig:ClassicExample(b)). Hence, Eq.\reeq:c is true.
Finally, (Fig. \refig:ClassicExample(c)) shows that there is a route from $X$ to $X$ when $X$ and $X$ are shaded. This proves that the statement \reeq:c is false.
$$ $$ Define $p(x) = \prodi=np(x ~|~ x\pi$ to be the factorization as a multiplication of some local probability of a directed graph.
Let $D = \ p(x) = \prodi=np(x ~|~ x\pi\$
Let $D = \ p(x):$satisfy all conditional independence statements associated with a graph $\$.
Then $D = D$.
% %%%%% % Jan 13 % %%%%%
---+++ Undirected Graphical Models In the previous sections we discussed the Bayes Ball algorithm and the way we can use it to determine if there exists a conditional independence between two nodes in the graph. This algorithm can be easily modified to allow us to determine the same information in an undirected graph. An undirected graph that provides information about the relationships between different random variables can also be called a "Markov Random Field".
As before we must define a set of canonical graphs. The nice thing is that for undirected graphs there is really only one type of canonical graph:
\epsfxsize=1.5in \epsfysize=0.5in \epsfboimages/UnDirGraphCanon.ep \captioThe only way to connect 3 nodes in an undirected graph\labefig:UnDirGraphCano
In the first figure (Fig. \refig:UnDirGraphCase) we have no information about the node Y and so we can not say if the nodes X and Z are independent since the ball can pass from one to the other. On the other hand, in (Fig. \refig:UnDirGraphCase) the value of Y is known and so the ball can not pass from X to Z or from Z to X. In this case we can say the X and Z are independent given Y. $$X \amalg Z | Y$$ [ht]
\epsfxsize=1.5in \epsfysize=0.5in \epsfboimages/UnDirGraphCase1.ep \captioThe ball can pass through the middle node\labefig:UnDirGraphCase
\epsfxsize=1.5in \epsfysize=0.5in \epsfboimages/UnDirGraphCase2.ep \captioThe ball can not pass through the middle node\labefig:UnDirGraphCase
Now that we have a type of Bayes Ball algorithm for both directed and undirected graphs we can ask ourselves the question: Is there an algorithm or method that we can use to convert between directed and undirected graphs?
In general: *NO* .
In fact, not only does there not exist a method for conversion but some graphs do not have an equivalent and may exist only in the undirected or directed form. Take the following undirected graph (Fig. \refig:UnDirGraphUnconver). We can see that the radom variables that are represented in this graph have the following properties: $$X \amalg Y | \lbrace W, Z \rbrace$$ $$W \amalg Z | \lbrace X, Y \rbrace$$
\epsfxsize=2in \epsfysize=3in \epsfboimages/UnDirGraphUnconvert.ep \captioThere is no directed equivalent to this graph\labefig:UnDirGraphUnconver
Now try building a directed graph with the same properties taking into consideration that directed graphs cannot contain a cycle. Under this restriction it is in fact impossible to find an equivalent directed graph that satisfies all of the above properties. Similarly, consider the following directed graph (Fig. \refig:DirGraphUnconver). It can not be represented by any undirected graph with 3 nodes.
\epsfxsize=1.5in \epsfysize=1.5in \epsfboimages/DirGraphUnconvert.ep \captioThere is no undirected equivalent to this graph\labefig:DirGraphUnconver
When we want to graph the relationships between a set of random variables it is important to consider both graph types since some relationships can only be graphed on a certain type of graph. We must therefore conclude that undirected graphs are just as important as the directed ones. For the directed graphs we have an expression for $P(x_V)$. We should try to develop a similar statement for the undirected graphs.
In order to develop the expression we need to introduce more terminology.
* Clique - 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. * Maximal Clique - A clique where if any other node from the graph G is added to it then the new set is no longer a clique.
Let C = Set of all Maximal Cliques.
Let $\psic_$ = A non-negative real valued function.
Now associate one $\psic_$ with each clique $c_i$ then, $$ P(x) = \fra1Z(\Psi \prodc_i \epsilon \psic_ (xc_) $$ Where, $$ Z(\Psi) = \sumx_ \prodc_i \epsilon \psic_ (xc_) $$
% %%%%% % Jan 16 % %%%%%
---++ Graphical Algorithms
In the previous chapter there were two kinds of graphical models that were used to represent dependencies between variables. One is a directed graphical model while the other is an undirected graphical model. In the case of directed graphs we can define the joint probability distribution based on a product of conditional probabilities where each node is conditioned on the value(s) of its parent(s). In the case of the undirected graphs we can define the joint probability distribution based on the normalized product of $ \psi $ functions based on the nodes that form maximal cliques in the graph. A maximal clique is a clique where we can not add an additional node such that the clique remains fully connected.
In the previous chapter we also developed the following two expressions for $P(x_V)$:
---++++ For Directed Graphs:
\[ P(x_V) = \prodi= P(x_i | x\pi_) \]
---++++ For Undirected Graphs:
\[ P(x) = \fra1Z(\Psi \prodc_i \epsilon \psic_ (xc_) \]
---++++ Theorem: Hammersley - Clifford
If we allow $ U_1 $ to represent the set of all the decompositions of $ P(x) $ based on a certain graphical representation and we allow $ U_2 $ to represent all possible conditional probabilities of those nodes then we will find that the sets $ U_1 $ and $ U_2 $ are in fact the same set.
\[ U = \left \ P(x) = \fra1Z(\psi \prodc_i \epsilon \psic_ (xc_) \right \ \] \[ U = \left \ P(x) | P(x) \mbo satisfies all conditional probabilitie \right \ \]
Then: $ U = U $
There is a lot of information contained in the joint probability distribution $ P(x) $. We have defined 6 tasks (listed bellow) that we would like to accomplish with various algorithms for a given disribution $ P(x) $. These algorithms may each be able to perform a subset of the tasks listed bellow.
* Marginalization Given $ P(x) $ find $ P(x) $ \underlinex Given $ P(x_1, x_2, ... , x_6) $ find $ P(x_2, x_6) $ * Conditioning Given $ P(x_V) $ find $P(x_A|x_B) = \fraP(x_A, x_B)P(x_B$ . * Evaluation Evaluate the probability for a certain configuration. * Completion Compute the most probable configuration. In other words, which of the $ P(x_A|x_B) $ is the largest for a specific combinations of $ A $ and $ B $. * Simulation Generate a random configuration for $ P(x_V) $ . * Learning We would like to find parameters for $ P(x_V) $ .
---+++ Exact Algorithms:
We will be looking at three exact algorithms. An exact algorithm is an algorithm that will find the exact answer to one of the above tasks. The main disadvantage to the exact algorithms approach is that for large graphs which have a large number of nodes these algorithms take a long time to produce a result. When this occurs we can use inexact algorithms to more efficiently find a useful estimate.
* Elimination * Sum-Product * Junction Tree
---+++ General Inference:
Let us first define a set of nodes called Evidence Nodes. We will denote evidence nodes with $x_E$. These nodes represent the random varibles about which we have information. Similarily, let us define the set of nodes $x_F$ as Query Nodes. These are the set of nodes for which we seek information. By Bayes Theorem we know that: \[ P(x_F|x_E) = \fraP(x_F,x_E)P(x_E \]
Let $ G(V, \epsilon) $ be a graph with vertices $ V $ and edges $ \epsilon $
The group of nodes $V$ is made up of the evidence nodes $E$, the query nodes $F$ and the nodes that are neither query nor evidence nodes $R$. We can just call $R$ the remainder nodes. All of these sets are mutually exclusive therefore,
$ V = E \cup F \cup R $ and $ R = V \slash (E \cup F) $
$P(x_F, x_E) = \sum P(x_V) = \sum P(x_E, x_F, x_R)$
Consider once again the example from Figure \refig:ClassicExample. Suppose we want to calculate $P(x_1|\ba_6) $. Where $\ba_6$ refers to a fixed value of $x_6$.
If we represent the joint probabilities normally we have, \[ P(x_1, x_2, ..., x_5) = \sumx_P(x_1, x_2, ..., x_6) \] which represents a table of probabilities of size $2^6$. In general this table is of size $k^n$ where $k$ is the number of values each variable can take on and $n$ is the number of vertices. In a computer algorithm this is exponential: $O(k^n)$
We can reduce the complexity if we represent the probabilities in factored form.
P(x_1, x_2, ..., x_5) &= \sumx_ P(x_1)P(x_2|x_1)P(x_3|x_1)P(x_4|x_2)P(x_5|x_3)P(x_6|x_2, x_5)
&= P(x_1)P(x_2|x_1)P(x_3|x_1)P(x_4|x_2)P(x_5|x_3) \sumx_ P(x_6|x_2, x_5)
Where the computational complexity is only $O(nk^r)$ where $r$ is the number of parents of a node. In our case the table has been reduced to $2^3$ from $2^6$.
Let $ m_i(xs_)$ be the expression that arises when we perform $\sumx_ P(x_i|xs_)$ where $xs_$ represents a set of variables other than $x_i$.
For instance, in our example we can say that $m_6(x_1, x_2) = \sumx_ P(x_6|x_1, x_2)$ .
We know that according to Bayes Theorem we can calculate $ P(x_1, \ba_6) $ and $ P(\ba_6) $ separately in order to find the desired conditional probability. \[ P(x_1|\ba_6) = \fraP(x_1, \ba_6)P(\ba_6 \]
Let us begin by calculating $ P(x_1, \ba_6) $ .
P(x_1|\ba_6) &= \sumx_\sumx_\sumx_\sumx_P(x_1)P(x_2|x_1)P(x_3|x_1)P(x_4|x_2)P(x_5|x_3)P(\ba_6|x_2, x_5)
&= P(x_1)\sumx_P(x_2|x_1)\sumx_P(x_3|x_1)\sumx_P(x_4|x_2)\sumx_P(x_5|x_3)P(\ba_6|x_2, x_5)
&= P(x_1)\sumx_P(x_2|x_1)\sumx_P(x_3|x_1)\sumx_P(x_4|x_2)m_5(x_2, x_3, \ba_6)
&= P(x_1)\sumx_P(x_2|x_1)\sumx_P(x_3|x_1)m_5(x_2, x_3, \ba_6)\sumx_P(x_4|x_2)
&= P(x_1)\sumx_P(x_2|x_1)\sumx_P(x_3|x_1)m_5(x_2, x_3, \ba_6)m_4(x_2)
&= P(x_1)\sumx_P(x_2|x_1)m_4(x_2)m_3(x_1, x_2, \ba_6)
And then we can use the above result to calculate the next desired probability. : $ P(\ba_6) = \sumx_P(x_1|\ba_6) $.
Finally, by using the above two results we can calculate $ P(x_1|\ba_6) = \fraP(x_1, \ba_6)P(\ba_6 $.
% %%%%% % Jan 18 % %%%%%
---+++ Evaluation Define _$X_i$_ as an evidence node whose observed value is $\overlinx_$. To show that _$X_i$_ is fixed at the value $\overlinx_$, we define an evidence potential $\delt(x_i,\overlinx_$ whose value is 1 if $x_i$ = $\overlinx_$ and 0 otherwise.
So $$ g(\overlinx_) =\sumx_ig(x_i)\delt(x_i,\overlinx_$$
When we have more than one variable such as p(F$|\overlin$), the total evidence potential is: $$ \delt(x_i,\overlinx_= \prodi\in \delt(x_i,\overlinx_ $$
---+++ Elimination and Directed Graphs Given a graph G =(V,_E_ ), an evidence set E, and a query node F, we first choose an elimination ordering I such that F appears last in this ordering.
For the graph in (Fig. \refig:ClassicExample): $G =(V,_E_ )$. Consider once again that node $x_1$ is the query node and $x_6$ is the evidence node.
$I = \left\6,5,4,3,2,1\right\$ (1 should be the last node, ordering is crucial)
We must now crete an active list. There are two rules that must be followed in order to create this list.
- For i$\i$ put $p(x_i|x\pi_)$ in active list.
- For i$\in put $p(x_i|\overlinx_)$ in active list.
Here, our active list is: $$ p(x_1), p(x_2|x_1), p(x_3|x_1), p(x_3|x_2), p(x_5|x_3),\underbracp(x_6|x_2, x_5)\delt(\overlinx_,x_6\phi_6(x_2,x_5, x_6), \sumx6\phi_=m(x2,x5) $$
We first eliminate node $X_6$. We place $m(x_2,x_5)$ on the active list, having removed $X_6$. We now eliminate $X_5$.
$$ \underbracp(x_5|x_3)*m_6(x_2,x_5m_5(x_2,x_3 $$
Likewise, we can also eliminate $X_4, X_3, X_2$(which yields the unnormalized conditional probability $p(x_1|\overlinx_)$ and $X_1$. Then it yields $m_1 = \sumx_1\phi_1(x_1$ which is the normalization factor, $p(\overlinx_)$.
---++++ Elimination and Undirected Graphs We would also like to do this elimination on undirected graphs such as G'.
\centering \epsfxsize=2in \epsfysize=2in \includegraphicimages/graph.ep \captioundirected graph G \labefig:Undirected
The first task is to find the maximal cliques and their associated potential functions.
maximal clique: $\left\x_1, x_2\right\$, $\left\x_1, x_3\right\$, $\left\x_2, x_4\right\$, $\left\x_3, x_5\right\$, $\left\x_2,x_5,x_6\right\$
potential functions: $\varph(x_1,x_2,\varph(x_1,x_3,\varph(x_2,x_4, \varph(x_3,x_5$ and $\varph(x_2,x_3,x_6$
$$ p(x_1|\overlinx_)=p(x_1,\overlinx_)/p(\overlinx_)\cdots\cdots\cdots\cdots\cdots(*) $$
$$ p(x_1,x_6)=\fra1\sumx_2,x_3,x_4,x_5,x_\varph(x_1,x_2\varph(x_1,x_3\varph(x_2,x_4\varph(x_3,x_5\varph(x_2,x_3,x_6\delt(x_6,\overlinx_ $$
The $\fra1$ looks crucial, but in fact it has no effect because for (*) both the numerator and the denominator have the $\fra1$ term. So in this case we can just cancel it.
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.
- Example: *
For the graph G in (Fig. \refig:Ex1La)
when we remove x1, G becomes (Fig. \refig:Ex2La)
if we remove x2, G becomes (Fig. \refig:Ex3La)
cc 1.8i \centering \epsfxsize=1.7in \epsfysize=1.7in \epsfboimages/ex.ep \capti \labefig:Ex1La
1.8i \centering \epsfxsize=1.7in \epsfysize=1.7in \epsfboimages/ex2.ep \capti \labefig:Ex2La
1.8i \centering \epsfxsize=1.7in \epsfysize=1.7in \epsfboimages/ex3.ep \capti \labefig:Ex3La
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. (Fig. \refig:Ex2La). But if we try to remove another node the complexity is significantly increased. (Fig. \refig:Ex3La). 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.
---+++ 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 $ P(x_i|\pix_) $ are the same as the mass functions from the undirected graph. $ \psic_(cx_) $
I = $\left\x_6,x_5,x_4,x_3,x_2,x_1\right\$
When we moralize the directed graph (Fig. \refig:Moral), then it becomes the undirected graph (Fig. \refig:Moral).
cc 3i \centering \epsfxsize=2.9in \epsfysize=2.9in \epsfboimages/moral.ep \captioOriginal Directed Grap \labefig:Moral
3i \centering \epsfxsize=2.9in \epsfysize=2.9in \epsfboimages/moral3.ep \captioMoral Undirected Grap \labefig:Moral
% %%%%% % Jan 20 JUST NOTES ABOUT MATLAB % %%%%%
% %%%%% % Jan 23 % %%%%%
---+++ 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. \refig:UnDirTre). 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. \refig:DirTre).
c 3i \centering \epsfxsize=2.9in \epsfysize=2.9in \epsfboimages/UnDirTree.ep \captioUndirected Tre \labefig:UnDirTre
3i \centering \epsfxsize=2.9in \epsfysize=2.9in \epsfboimages/DirTree.ep \captioDirected Tre \labefig:DirTre
For the undirected graph $G(v, \varepsilon)$ (Fig. \refig:UnDirTre) we can write the joint probability distribution function in the following way. $$ P(x_v) = \fra1Z(\psi\prodi \varepsilon \psi(x_i)\prodi,j \varepsilon \varepsilo\psi(x_i, x_j)$$
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. \refig:DirTre) of a directed tree. We can write the joint probability distribution function as: $$ P(x_v) = P(x_1)P(x_2|x_1)P(x_3|x_1)P(x_4|x_2)P(x_5|x_2) $$ If we want to convert this graph to the undirected form shown in (Fig. \refig:UnDirTre) then we can use the following set of rules.
- If $\gamma$ is the root then: $ \psi(x_\gamma) = P(x_\gamma) $.
- If $\gamma$ is NOT the root then: $ \psi(x_\gamma) = 1 $.
- If $\left\lbrace i \right\rbrace$ = $\pi_j$ then: $ \psi(x_i, x_j) = P(x_j | x_i) $.
So now we can rewrite the above equation for (Fig. \refig:DirTre) as: $$ P(x_v) = \fra1Z(\psi\psi(x_1)...\psi(x_5)\psi(x_1, x_2)\psi(x_1, x_3)\psi(x_2, x_4)\psi(x_2, x_5) $$ $$ = \fra1Z(\psiP(x_1)P(x_2|x_1)P(x_3|x_1)P(x_4|x_2)P(x_5|x_2) $$
% %%%%% % Jan 25 % %%%%%
---++++ Elimination Algorithm on a Tree
[ht] \center \includegraphics[width=0.4\columnwidth, keepaspectratioimages/fig1.ep \captio Message-passing in Elimination Algorithm \labefig:TreeStdE
We will derive \textsSum-Produc algorithm from the point of view of the \textsEliminat algorithm. To marginalize $x_1$ in (Fig. \refig:TreeStdE),
& &\mbo \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $m_5(x_3)
&=&p(x_1)\sumx_p(x_2|x_1)\underbrac\sumx_p(x_3|x_2)m_5(x_3\underbrac\sumx_p(x_4|x_2 \\ & &\mbo \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $m_3(x_2)$\ \ \ \ \ \ \ \ \ \ \ $m_4(x_2)
& & \mbo \ \ \ \ \ \ \ \ \ \ \ \ \ \ $m_2(x_1)
where,\[m_5(x_3)=\sumx_p(x_5|x_3)=\psi(x_5)\psi(x_5,x_3)=\mathbm5(x_3\] \[m_4(x_2)=\sumx_p(x_4|x_2)=\psi(x_4)\psi(x_4,x_2)=\mathbm4(x_2\] \[m_3(x_2)=\sumx_p(x_3|x_2)=\psi(x_3)\psi(x_3,x_2)m_5(x_3)=\mathbm3(x_2, \] which is essentially (potential of the node)$\times$(potential of the edge)$\times$(message from the child).
The term "$mj(x_i)$" represents the intermediate factor between the eliminated variable, _j_ , and the remaining neighbor of the variable, _i_ . Thus, in the above case, we will use $m5(x_3)$ to denote $m_5(x_3)$, $m4(x_2)$ to denote $m_4(x_2)$, and $m3(x_2)$ to denote $m_3(x_2)$. We refer to the intermediate factor $mj(x_i)$ as a "message" that _j_ sends to _i_ . (Fig. \refig:TreeStdE)
mj=\sumx_ \left(\ \psi(x_j)\psi(x_j,x_i)\prodk\i\mathca(j)\backslash mk \right)\ \labeequ:MsgEquatio
\subsubsectionElimination To Sum Product Algorith
[ht] \center \includegraphics[width=0.4\columnwidth, keepaspectratioimages/fig2.ep \captio All of the messages needed to compute all singleton marginals \labefig:SumProdE
The \textsSum-Produc 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 (\reequ:MsgEquatio) at each step. The net effect is that a single message will flow in both directions along each edge. (See Figure \refig:SumProdE) Once all such messages have been computed using (\reequ:MsgEquatio), we can compute desired marginals.
As shown in Figure \refig:SumProdE, to compute the marginal of $X_1$ using elimination, we eliminate $X_5$, which involves computing a message $m5(x_3)$, then eliminate $X_4$ and $X_3$ which involves messages $m3(x_2)$ and $m4(x_2)$. We subsequently eliminate $X_2$, which creates a message $m2(x_1)$.
Suppose that we want to compute the marginal of $X_2$. As shown in Figure \refig:MsgsForme, we first eliminate $X_5$, which creates $m5(x_3)$, and then eliminate $X_3$, $X_4$, and $X_1$, passing messages $m3(x_2)$, $m4(x_2)$ and $m1(x_2)$ to $X_2$.
[ht] \center \includegraphics[width=0.4\columnwidth, keepaspectratioimages/fig3.ep \captio The messages formed when computing the marginal of $X_2$ \labefig:MsgsForme
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 \textsSum-Produc algorithm is not only based on equation
(\reequ:MsgEquatio), but also _Message-Passing Protocol_ .
- Message-Passing Protocol* tells us that \textia node can
send a message to a neighboring node when (and only when) it has received messages from all of its other neighbor.
---++++ For Directed Graph
Previously we stated that:
Using the above equation (\reeqn:Margina), we find the marginal of $\ba_E$.
Now we denote:
p^E(x_v) = p(x_v) \delta (x_E,\ba_E) \labeeqn:Dir
Since the sets, _F_ and _E_ , add up to $\mathca$, $p(x_v)$ is equal to $p(x_F,x_E)$. Thus we can substitute the equation (\reeqn:Dir) into (\reeqn:Margina) and (\reeqn:Dir), and they become:
\labeeqn:Dir p(\ba_E) = \sumx_p^E(x_v) \labeeqn:Dir1
We are interested in finding the conditional probability. We substitute previous results, (\reeqn:Dir) and (\reeqn:Dir1) into the conditional probability equation.
$p^E(x_v)$ is an unnormalized version of conditional probability, $p(x_F|\ba_E)$.
---++++ For Undirected Graphs
We denote $\psi^E$ to be: \[\left\l l
$\psi^E(x_i) = \psi(x_i)\delta(x_i,\ba_i)$,& & if $i\i$
$\psi^E(x_i) = \psi(x_i)$,& & otherwise
% %%%%% % Jan 27 % %%%%%
---+++ Max-Product 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.
\centering \includegraphicimages/suks.ep \captioMax Product Example \labefig:MaxProdE \labeimg:suks.ep
\maxx_1P(x_i & = & \maxx_\maxx_\maxx_\maxx_\maxx_5P(x_1)P(x_2|x_1)P(x_3|x_2)P(x_4|x_2)P(x_5|x_3 \\ & = & \maxx_1P(x_1\maxx_2P(x_2|x_1\maxx_3P(x_3|x_4\maxx_4P(x_4|x_2\maxx_5P(x_5|x_3
Consider the graph in Figure \refig:MaxProdE. $$ mma5(x_5)=\maxx_5\psiE(x_5\ps(x_3,x_5 $$ $$ mma3(x_3)=\maxx_3\psiE(x_3\ps(x_3,x_5mma5, $$
---+++ Maximum configuration We would also like to find the value of the $x_i$s which produces the largest value for the given expression. To do this we replace the max from the previous section with argmax.
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.
---++ 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:
- Density Estimation
---+++ Regression In regression we have a set of data points $ (x_i, y_i) $ for $ i = 1...n $ and we would like to determine the way that the variables x and y are related. In certain cases such as (Fig. \reimg:regression.ep) we try to fit a line (or other type of function) through the points in such a way that it describes the relationship between the two variables.
\centering \includegraphicimages/regression.ep \captioRegressio \labeimg:regression.ep
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. \[P(y|x)=\fraP(y,x)P(x = \fraP(y,x)\intyP(y,x)d\]
---+++ Classification In classification we also have a set of points $ (x_i, y_i) $ for $ i = 1...n $ but we would like to use the x and y values to determine if a certain point belongs in group A or in group B. Consider the example in (Fig. \reimg:Classification.ep) where two sets of points have been divided into the set + and the set - by a line. The purpose of classification is to find this line and then place any new points into one group or the other.
\centering \epsfxsize=2.9in \epsfysize=2.9in \epsfboimages/Classification.ep \captioClassify Points into Two Set \labeimg:Classification.ep
We would like to obtain the probability distribution of to 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. $$ P(c|x,y)=\fraP(c,x,y)P(x,y = \fraP(c,x,y)\sumcP(c,x,y $$
---+++ Clustering Clustering is somewhat 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 y. $$ P(y|x)=\fraP(y,x)P(x\ \ y\ unknown $$
We can use graphs to represent the three types of statistical problems that have been introduced so far. The first graph (Fig. \refig:RegClas 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. \refig:Clusterin) we see that the value of the Y variable is unknown and so we can tell that this graph represents the Clustering situation.
c 3i \centering \epsfxsize=2.9in \epsfysize=2.9in \epsfboimages/RegClass.ep \captioRegression or Classificatio \labefig:RegClas
3i \centering \epsfxsize=2.9in \epsfysize=2.9in \epsfboimages/Clustering.ep \captioClusterin \labefig:Clusterin
- Classification example: Naive Bayes classifier*
First define a set of boolean random variables $X_i$ and $Y$ for $i = 1...n$. $$Y=\left\1,0\right\, X_i =\left\1,0\right\ $$ Then we will say that a certain pattern of Xs can either be classified as a 1 or a 0. The result of this classification will be represented by the variable Y. The graphical representation is shown in (Fig. \reimg:classifi.ep). One important thing to note here is that the two diagrams represent the same graph. The one on the right uses plate notation to simplify the representation of the graph for variables that are indexed. Such plate notation will also be used later in these notes.
cc $ \stackrex\underbrac<01110>$ & $ \rightarrow $ & $\stackreY$
$ <01110> $ & $ \rightarrow $ & $0$
\centering \includegraphicimages/classifi.ep \captioTwo Types of Graphical Representatio \labeimg:classifi.ep
We are interested in finding the following: $$ P(y|x_1 .....x_n)=\fraP(x_1....x_n|y)P(y)P(x_1.....x_n = \fraP(x_1....x_n,y)P(x_1.....x_n = \fraP(y)\prodi=1,2,..,nP(x_i|yP(x_1.....x_n $$ The classification is very intuitive in this case. We will calculate the probability that we are in class 1 and we will calculate the probability that we are in class 0. The higher probability will decide the class. For example if we have a higher probability of being in class 1 then we will place this set of Xs in class 1.
$ \wideha=1 $ & $ \Leftrightarrow $ & $ P(y=1|x_1.....x_n) > P(y=0|x_1.....x_n) $
$ \wideha=1 $ & $ \Leftrightarrow $ & $ \fraP(y=1|x_1.....x_n)P(y=0|x_1.....x_n >1 $ \\ & $\Leftrightarrow$ & $ \lo\fraP(y=1)P(y=0 + \sumi=1..n\lo\fraP(x_i|y=1)P(x_i|y=0>0 $
Now if we define the following: \\ $P(y=1) =p$
We can continue with the above simplification and we arrive at the solution:
$\wideha=1$ & $\Leftrightarrow$ & $x_i\lo\fraPiPi+ (1-x_i)\lo\fra(1-Pi)(1-Pi > 0$
& $\Leftrightarrow$ & $ =x_i\underbrac\lo\fraPi(1-Pi)Pi(1-Pislop + \underbrac \lo\fra(1-Pi)(1-Piintercep $
% %%%%% % Jan 30 % %%%%%
%%% NOTE: %% This seems like a familiar example but it does not seem like it belongs here. %% so I have commented it out. When I figure out where it goes I can move it there. %%%
---++ Example from last class John is not a professional trader. However he trades in the copper market. Copper stock increase if demand for copper is more than supply, and decrease if supply is more than demand. Given supply and demand, the price of copper stock is not completely determined because some unknown factors such as prediction of political stability of countries, which supply copper or news about potential new use of copper, may impact the market.
If copper stock increases and John makes a right strategy, he will win; otherwise he will lose. Since John is not a professional trader sometimes he uses a bad trade strategy and in spite of increase of stock price he loses.
S: A discrete variable which represents increasing or decreasing in copper supply.
D: A discrete variable which represents increasing or decreasing in copper demand.
C: A discrete variable which represents increasing or decreasing in stack price.
P: A discrete variable that shows whether John wins or loses in his trade.
J: A discrete variable which is 1 when John makes a right choice in his trade strategy and 0 otherwise.
[!ht] \centering \includegraphics[width=0.65\columnwidth, keepaspectratioimages/graphJan30.ep \captio \labefig
p(S=1)=0.6, p(D=1)=0.7, p(J=1)=0.4
\hline % after \\: \hline or \clincol1-col \clincol3-col ... S D & p(c=1)
\hline 1 1 & 0.5
\hline 1 0 & 0.1
\hline 0 1 & 0.85
\hline 0 0 & 0.5
\hline % after \\: \hline or \clincol1-col \clincol3-col ... J C & p(p=1)
\hline 1 1 & 0.85
\hline 1 0 & 0.5
\hline 0 1 & 0.2
\hline 0 0 & 0.1
\[ p(S,D,C,J,P) = p(S)p(D)p(J)p(C|S,D)p(P|J,C) \]
%%%% %% END COMMENT %%%%
---+++ Bayesian and Frequentist Statistics There are two approaches of parameter estimation: the Bayesian and the Frequentist. This section focuses on the distinctions between these two approaches. We begin with a simple example,
Consider the following table of 1s and 2s. We would like to teach the computer to distinguish between the two sets of numbers so that when a person writes down a number the computer can use a statistical tool to decide if the written digit is a 1 or a 2.
\hline $\theta$ & _1_ & 2
\hline X & _1_ & 2
\hline X & 1 & _2_
\hline X & _1_ & _2_
The question that arises is: Given a written number what is the probability that that number belongs to the group of ones and what is the probability that that number belongs to the group of twos. In the Frequentist approach we use $p(x|\theta)$. We view the model $p(x|\theta)$ as a conditional probability distribution. Here, $\theta$ is known and X is unknown. However, Bayesian approach views X as known and $\theta$ as unknown, which gives
p(\theta|x) = \fracp(x|\theta)p(\theta)p(x
Where $p(\theta|x)$ is the _posterior probability_ , $p(x|\theta)$ is _likelihood_ , and $p(\theta)$ is the _prior probability_ of the parameter. There are some important assumptions about this equation. First, we view $\theta$ as a random variable. This is characteristic of the Bayesian approach, which is that all unknown quantities are treated as random variables. Second, we view the data x as a quantity to be conditioned on. Our inference is conditional on the event $\lbrace X=x \rbrace$. Third, in order to calculate $p(\theta|x)$ we need $p(\theta)$. Finally, note that Bayes rule yields a distribution over $\theta$, not a single estimate of $\theta$.
The Frequentist approach tries to avoid the use of prior probabilities. The goal of Frequentist methodology is to develop an "objective" statistical theory, in which two statisticians employing the methodology must necessarily draw the same conclusions from a particular set of data.
Consider a coin-tossing experiment as an example. The model is the Bernoulli distribution, $p(x|\theta) = \theta^x(1-\theta)1- $. Bayesian approach requires us to assign a prior probability to $\theta$ before observing the outcome from tossing the coin. Different conclusions may be obtained from the experiment if different priors are assigned to $\theta$. The Frequentist statistician wishes to avoid such "subjectivity". From another point of view, a Frequentist may claim that $\theta$ is a fixed property of the coin, and that it makes no sense to assign probability to it. A Bayesian would believe that $p(\theta|x)$ represents the _statistician's uncertainty_ about the value of $\theta$. Bayesian statistics views the posterior probability and the prior probability alike as subjective.
---+++ Maximum Likelihood Estimator There is one particular estimator that is widely used in Frequentist statistics, namely the _maximum likelihood estimator_ . Recall that the probability model $p(x|\theta)$ has the intuitive interpretation of assigning probability to X for each fixed value of $\theta$. In the Bayesian approach this intuition is formalized by treating $p(x|\theta)$ as a conditional probability distribution. In the Frequentist approach, however, we treat $p(x|\theta)$ as a function of $\theta$ for fixed x, and refer to $p(x|\theta)$ as the likelihood function. \[ \ha\thetM=argmax\thetp(x|\theta) \] where $p(x|\theta)$ is the likelihood L($\theta, x$) \[ \ha\thetM=argmax\thetlog(p(x|\theta)) \] where $log(p(x|\theta))$ is the log likelihood $l(\theta, x)$
% %%%%% % Feb 1 % %%%%%
Since $p(x)$ in the denominator of Bayes Rule is independent of $\theta$ we can consider it as a constant and we can draw the conclusion that:
p(\theta|x) \propto p(x|\theta)p(\theta)
Symbolically, we can interpret this as follows:
Posterior \propto likelihood \times prior
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.
---+++ Connection between Bayesian and Frequentist Statistics
Suppose in particular that we force the Bayesian to choose a particular value of $\theta$; that is, to remove the posterior distribution $p(\theta|x)$ to a point estimate. Various possibilities present themselves; in particular one could choose the mean of the posterior distribution or perhaps the mode.
(i) the mean of the posterior (expectation):
\ha\thetBaye=\int \theta p(\theta|x)\,d\theta
is called \textsBayes estimat.
(ii) the mode of posterior:
Note that MAP is \textsMaximum a posterio.
$$ MAP -------> \hat\thetaM$$ When the prior probabilities, $p(\theta)$ is taken to be uniform on $\theta$, the MAP estimate reduces to the maximum likelihood estimate, $\ha\thetM$.
$$ MAP = argmax\thet p(x|\theta) p(\theta) $$
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:
\ha\thetMA=argmax\thet \ log p(x|\theta) + log p(\theta) \
as an alternative expression for the MAP estimate.
Here, $log (p(x|\theta))$ is log likelihood and the "penalty" is the additive term $log(p(\theta))$. Penalized log likelihoods are widely used in Frequentist statistics to improve on maximum likelihood estimates in small sample settings.
% %%%%% % Feb 3 Guest Lecture % %%%%%
% %%%%% % Feb 6 % %%%%%
---++++ Information for an Event Consider that we have a given event E. The event has a probability P(E). As the probability of that event decreases we say that we have more information about that event. We calculate the information as: $$ Information = log (\fra1P(E) = - log (P(E)) $$
---++++ Binomial Example
- Probability Example:*
Consider the set of observations $x = (x_1, x_2, \cdots, x_n)$ which are iid, where $x_1, x_2, \cdots, x_n$ are the different observations of $X$. We can also say that this random variable is parameterized by a $\theta$ such that: $$P(X|\theta) \equiv P\thet(x)$$ In our example we will use the following model: $$ P(x_i = 1) = \theta $$ $$ P(x_i = 0) = 1 - \theta $$ $$ P(x|\theta) = \thetax_(1-\theta)(1-x_i $$ where $$ x_i = \0, 1\ $$
Suppose now that we also have some data $D$:
e.g. $D = \left\lbrace 1,1,0,1,0,0,0,1,1,1,1,\cdots,0,1,0 \right\rbrace $
We want to use this data to estimate $\theta$.
We would now like to use the ML technique. To do this we can construct the following graphical model:
Shade the random variables that we have already observed
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. $$L(\theta;x) = \prodi=^n P(x_i|\theta)$$ This is in fact the likelihood that we want to work with. Now let us try to maximise it:
l(\theta;x) & = & log(\prodi=^n P(x_i|\theta))
& = & \sumi=^n log(P(x_i|\theta)
& = & \sumi=^n log(\thetax_(1-\theta)1-x_)
& = & \sumi=^n x_ilog(\theta) + \sumi=^n (1-x_i)log(1-\theta)
Take the derivative and set it to zero:
$$ \fra\partial l\partial\thet = 0 $$ $$ \fra\partial l\partial\thet = \sumi=\frax_i\thet - \sumi=\fra1-x_i1-\thet = 0 $$ $$ \Rightarrow \fra\sumi=x_i\thet = \fra\sumi=(1-x_i)1-\thet $$ $$ \fraH\thet = \fraT1-\thet $$
H = \# of all $x_i = 1$, e.g. \# of heads
T = \# of all $x_i = 0$, e.g. \# of tails
Hence, $T + H = n$
And now we can solve for $\theta$:
\theta & = & \fra(1-\theta)H
\theta + \theta\fraH & = & \fraH
\theta(\fraT+H) & = & \fraH
\theta & = & \fra\fraH\fran = \fraH
---++++ Univariate Normal Now let us assume that the observed values come from normal distribution.
\includegraphicimages/fig4Feb6.ep \newline Our new model looks like: $$P(x_i|\theta) = \fra1\sqr2\p\sigme-\fra1(\frax_i-\mu\sigm) $$ Now to find the likelihood we once again multiply the independent marginal probabilities to obtain the joint probability and the likelihood function. $$ L(\theta;x) = \prodi=\fra1\sqr2\p\sigme-\fra1(\frax_i-\mu\sigm)$$ $$ \max\thetl(\theta;x) = \max\thet\sumi=(-\fra1(\frax_i-\mu\sigm)+log\fra1\sqr2\p\sigm $$ Now, since our parameter theta is in fact a set of two parameters, $$\theta = (\mu, \sigma)$$ we must estimate each of the parameters separately. $$\fra\partial\partial = \sumi= \left( \fra\mu - x_i\sigm \right) = 0 \Rightarrow \ha\m = \fra1\sumi=x_i$$ $$\fra\partial\partial \mu = -\fra12\sigma ^ \sum i=(x_i-\mu)^2 + \fran \fra1\sigma ^ = 0$$ $$ \Rightarrow \ha\sigm ^2 = \fra1\sumi=1(x_i - \ha\m)^2 $$
---++++ Bayesian Now we can take a look at the Bayesian approach to the same problem. Assume $\theta$ is a random variable, and we want to find $P(\theta | x)$. Also, assume $\theta$ is the mean and variance of a Gaussian distribution like in the previous example.
The graphical model is shown in Figure \refig:fig5Feb.
[!ht] \centering \includegraphicimages/fig5Feb6.eps \captioGraphical Model for Mean \labefig:fig5Feb
$$ P(\mu | x) = \fraP(x|\mu)P(\mu)P(x $$ We can begin with the estimation of $\mu$. If we assume $\mu$ as uniform, then we become a Frequentist and the result matches the one from the ML estimation. But, if we assume $\mu$ is normal, then we get an interesting result.
Assume $\mu$ as normal, then $$\mu \thicksim N(\mu , \tau)$$ $$P(x, \mu) = \prodi=P(x_i|\mu)P(\mu)$$ We want to find $P(\mu | x)$ and take expectation. $$P(\mu | x) = \fra1\sqr2\p\ha\sigme^(-\fra1)(\frax-\ha\m\ha\sigm)^2$$ Where $$\ha\m = \fra\fran\sigm\fran\sigma ^ + \fra1\tau ^ \ha + \fra\fra1\tau ^ \fran\sigma ^ + \fra1\tau ^\mu _0$$ is a linear combination of the sample mean and the mean of the prior. $$ \limx \rightarrow \inft\ha\m = \ha = \fra\sumi=x_i$$ $ P(\mu | x)$ shows a distribution of $\mu$, not just a single value. Also if we were to do the calculations for the sigma we would find the following result: $$ (\ha\sigm) = (\fran\sigma + \fra1\tau)-$$
% %%%%% % Feb 8 % %%%%%
---++++ ML Estimate for Completely Observed Graphical Models For a given graph G(V, E) each node represents a random variable. We can observe these variables and write down data for each one. If for example we had n nodes in the graph one observation would be $(x_1, x_2, ... , x_n)$. We can consider that these observations are independent and identically distributed. Note that $x_i$ is not necessarily independent from $x_j$.
- Directed Graph Example*
Consider the following directed graph (Fig. \reimg:DirGraphObs.ep).
\centering \epsfxsize=3in \epsfysize=3in \epsfboimages/DirGraphObs.ep \captioOur Directed Grap \labeimg:DirGraphObs.ep
We can assume that we have made a number of observations, say n, for each of the random variables in this graph.
- Observation* & *$X_1$* & *$X_2$* & *$X_3$* & *$X_4$*
1 & $x1$ & $x1$ & $x1$ & $x1$
2 & $x2$ & $x2$ & $x2$ & $x2$
3 & $x3$ & $x3$ & $x3$ & $x3$
& & ... & &
n & $xn$ & $xn$ & $xn$ & $xn$
Armed with this new information we would like to estimate $\theta = (\theta_1, \theta_2, \theta_3, \theta_4)$.
We know from before that we can write the joint distribution function as: $$ P(x|\theta) = P(x_1)P(x_2|x_1)P(x_3|x_1)P(x_4|x_2,x_3) $$ Which means that our likelihood function is: $$ L(\theta, x) = \prodi=1..P(xi|\theta_1)P(xi|xi, \theta_2)P(xi|xi, \theta_3)P(xi|xi, xi, \theta_4) $$ And our log likelihood is: $$ l(\theta, x) = \sumi=1..log(P(xi|\theta_1))+log(P(xi|xi, \theta_2)) + log(P(xi|xi, \theta_3)) + log(P(xi|xi, xi, \theta_4)) $$ To maximise $\theta$ we must maximise each of the $\theta_i$ individually. The good thing is that each of our parameters appears in a different term and so the maximization of each $\theta_i$ can be carried out independently of the others.
For discrete random variables we can use Bayes Rule. For example:
P(x_2=1|x_1=1) & = & \fraP(x_2=1,x_1=1)P(x_1=1 \\
& = & \fraNumber\ of\ times\ x_1\ and\ x_2\ are\ 1Number\ of\ times\ x_1\ is\
Intuitively, this means that we count the number of times that both of the variables satisfy their conditions and then divide by the number of times that only one of them satisfies the condition. Then we know what proportion of time the variables satisfy the conditions together. The proportion is in fact the $\theta_i$ we are looking for.
We can consider another example. We can try to find: $$ P(x_4|x_3, x_2) $$ ccc $x_3$ & $x_2$ & $P(x_4=0|x_3, x_2)$ & $P(x_4=1|x_3, x_2)$
0 & 0 & $\theta40$ & $1 - \theta40$
0 & 1 & $\theta40$ & $1 - \theta40$
1 & 0 & $\theta41$ & $1 - \theta41$
1 & 1 & $\theta41$ & $1 - \theta41$
For the exponential family of distributions there is a general formula for the ML estimates but it does not have a closed form solution. To get around this, one can use the Interactive Reweighted Least Squares (IRLS) method also called the Newton Raphson method to find these parameters.
In the case of the undirected model things get a little more complicated. The $\theta_i$s do not decouple and so they can not be calculated separately. To solve this we can use KL divergence which is a method that considers the distance between two distributions.
% %%%%% % Feb 10 % %%%%%
---++ EM Algorithm Let us once again consider the above example only this time the data that was supposed to be collected was not done so properly. Instead of having complete data about every random variable at every step some data points are missing.
- Observation* & *$X_1$* & *$X_2$* & *$X_3$* & *$X_4$*
1 & $x1$ & $x1$ & $Z1$ & $x1$
2 & $x2$ & $x2$ & $x2$ & $x2$
3 & $Z3$ & $x3$ & $x3$ & $x3$
4 & $Z4$ & $x4$ & $x4$ & $Z4$
& & ... & &
n & $xn$ & $xn$ & $xn$ & $xn$
In the above table 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 $\theta_i$ if we do not have all the data we need. We can use the Expectation Maximization (or EM) Algorithm to estimate the parameters for the model even though we do not have a complete data set.
One thing to note here is that in the case of missing values we now have multiple local maxima in the likelihood function and as a result the EM Algorithm does not always reach the global maximum. Instead it may find one of a number of local maxima. Multiple runs of the EM Algorithm with different starting values will possibly produce different results since it may reach a different local maxima.
Define the following types of likelihoods:
complete log likelihood = $ l_c(\theta; x, z) = log(P(x, z|\theta)) $.
incomplete log likelihood = $ l(\theta; x) = log(P(x | \theta)) $.
---+++ Derivation of EM
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. $$ l(\theta; x) = log(P(x | \theta)) = log(\sum_zP(x, z|\theta)) $$ Since the z has not been observed that means that $l_c$ is in fact a random quantity. In that case we can define the expectation of $l_c$ in terms of some arbitrary density function $q(z|x)$. $$ El_c(\theta, x, z_q] = \sum_z q(z|x)log(P(x, z|\theta)) $$
---++++ Jensen's Inequality In order to properly derive the formula for the EM algorithm we need to first introduce the following theorem.
For any *convex* function f: $$ f(\alpha x_1 + (1-\alpha)x_2) \leqslant \alpha f(x_1) + (1-\alpha)f(x_2) $$ This can be shown intuitively through a graph. In the (Fig. \reimg:JensenIneq.ep) 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.
\centering \epsfxsize=3in \epsfysize=3in \epsfboimages/JensenIneq.ep \captioJensen's Inequalit \labeimg:JensenIneq.ep
For us it is important that the log function is *concave* and so we must inverse the sign on the equation. Jensen's inequality is used in step (\reUseJense) of the EM derivation but for the concave log function.
l(\theta, x) & = & log(\sum_z P(x,z|\theta))
& = & log(\sum_z q(z|x) \fraP(x,z|\theta)q(z|x)
& \geqslant & \sum_z q(z|x)log(\fraP(x,z|\theta)q(z|x) \labeUseJense
& = & \mathfra(q;\theta)
The function $\mathfra(q;\theta)$ is called the axillary function and it is used in the EM algorithm. For the EM algorithm we have two steps that we repeat one after the other in order to get better estimates for $q(z|x)$ and $\theta$. As the steps are repeated the parmeters converge to a local maximum in the likelihood function.
$$ argmax \mathfra(q;\theta(t) = q(t+1 $$
$$ argmax\thet \mathfra(q(t+1;\theta) = \theta(t+1 $$
---++++ Notes About M-Step
\mathfra(q;\theta) & = & \sum_z q(z|x) log(\fraP(x,z|\theta)q(z|x)
& = & \sum_z q(z|x)log(P(x,z|\theta)) - \underbrac\sum_z q(z|x)log(q(z|x)_\texConstant with respect to $\theta
& = & E[ l_c(\theta;x, y) ]
Since the second part of the equation is only a constant with respect to $\theta$, in the M-step we only need to maximise the expectation of the complete likelihood. The complete likelihood is the only part that still depends on $\theta$.
---++++ Notes About E-Step In this step we are trying to find an estimate for $q(z|x)$. To do this we have to maximise $\mathfra(q;\theta(t)$.
\mathfra(q;\theta) & = & \sum_z q(z|x) log(\fraP(x,z|\theta)q(z|x)
It can be shown that $q(z|x) = P(z|x,\theta(t)$. So, replace $q(z|x)$ with $P(z|x,\theta(t)$.
\mathfra(q;\theta) & = & \sum_z P(z|x,\theta(t) log(\fraP(x,z|\theta)P(z|x,\theta(t)
& = & \sum_z P(z|x,\theta(t) log(\fraP(z|x,\theta(t)P(x|\theta(t)P(z|x,\theta(t)
& = & \sum_z P(z|x,\theta(t) log(P(x|\theta(t))
& = & log(P(x|\theta(t))
& = & l(\theta; x)
But $\mathfra(q;\theta(t)$ is the lower bound of $ l(\theta, x) $ so that means that $P(z|x,\theta(t)$ is in fact the maximum for $\mathfra$. We can therefore see that we only need to do the E-Step once and then we can use that result for each repetition of the M-Step.
% %%%%% % Feb 13 % %%%%%
From the above results we can find that we have an alternative representation for the EM algorithm. We can reduce it to:
Find $ E[l_c(\theta; x, z)]P(z|x, \theta $ only once.
Maximise $ E[l_c(\theta; x, z)]P(z|x, \theta $ with respect to $theta$.
The EM Algorithm is probably best understood through examples.
---++++ EM Algorithm Example
Suppose we have the two independent and identically distributed random variables: $$ Y_1, Y_2 \sim P(y|\theta) = \theta e-\theta $$ In our case $y_1 = 5$ has been observed but $y_2 = ?$ has not. Our task is to find an estimate for $\theta$. We will try to solve the problem first without the EM algorithm. Luckily this problem is simple enough to be solveable without the need for EM.
L(\theta; Data) & = & \theta e-5\thet
l(\theta; Data) & = & log(\theta)- 5\theta
We take our derivative:
& \fradld\thet & = 0
\Rightarrow & \fra1\thet-5 & = 0
\Rightarrow & \theta & = 0.2
And now we can try the same problem with the EM Algorithm.
L(\theta; Data) & = & \theta e-5\thet\theta e-y_2\thet
l(\theta; Data) & = & 2log(\theta) - 5\theta - y_2\theta
E-Step $$ E[l_c(\theta; Data)]P(y_2|y_1, \theta = 2log(\theta) - 5\theta - \fra\theta\theta(t$$ M-Step
& \fradl_cd\thet & = 0
\Rightarrow & \fra2\thet-5 - \fra1\theta(t & = 0
\Rightarrow & \theta(t+1 & = \fra2\theta(t5\theta(t+
Now we pick an initial value for $\theta$. Usually we want to pick something reasonable. In this case it does not matter that much and we can pick $\theta = 10$. Now we repeat the M-Step until the value converges.
\theta(1 & = & 10
\theta(2 & = & 0.392
\theta(3 & = & 0.2648
... & &
\theta(k & \simeq & 0.2
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.
% %%%%% % Feb 15 % %%%%% ---+++ 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 $P(x|\theta) = \alpha N(x;\mu_1,\sigma_1) + (1-\alpha)N(x;\mu_2,\sigma_2)$. We sample the data, $Data = \x_1,x_2...x_n\ $ and we know that $x_1,x_2...x_n$ are iid. from $P(x|\theta)$.
We would like to find: $$\theta = \\alpha,\mu_1,\sigma_1,\mu_2,\sigma_2\ $$
We have no missing data here so we can try to find the parameter estimates using the ML method. $$ L(\theta; Data) = \prod_i=1...n (\alpha N(x_i, \mu_1, \sigma_1) + (1 - \alpha) N(x_i, \mu_2, \sigma_2)) $$ And then we need to take the log to find $l(\theta, Data)$ and then we take the derivative for each parameter and then we set that derivative equal to zero. That sounds like a lot of work because the Gaussian is not a nice distribution to work with and we do have 5 parameters.
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. $$ z_i = 1 \tex with prob. \alpha $$ $$ z_i = 0 \tex with prob. (1-\alpha) $$ Now we have a data set that includes our latent variable $z_i$: $$ Data = \(x_1,z_1),(x_2,z_2)...(x_n,z_n)\ $$ We can calculate the joint pdf by: $$ P(x_i,z_i|\theta)=P(x_i|z_i,\theta)P(z_i|\theta) $$ Let, $$ P(x_i|z_i,\theta)= \left\l l $ \phi_1(x_i)=N(x;\mu_1,\sigma_1)$ & if & $ z_i = 1 $
$ \phi_2(x_i)=N(x;\mu_2,\sigma_2)$ & if & $ z_i = 0 $
Now we can write $$ P(x_i|z_i,\theta)=\phi_1(x_i)z_ \phi_2(x_i)1-z_ $$ and $$ P(z_i)=\alphaz_(1-\alpha)1-z_ $$ We can write the joint pdf as: $$ P(x_i,z_i|\theta)=\phi_1(x_i)z_\phi_2(x_i)1-z_\alphaz_(1-\alpha)1-z_ $$ From the joint pdf we can get the likelihood function as: $$ L(\theta;D)=\prodi=^n \phi_1(x_i)z_\phi_2(x_i)1-z_\alphaz_(1-\alpha)1-z_ $$ Then take the log and find the log likelihood: $$ l_c(\theta;D)=\sumi=^n z_i log\phi_1(x_i) + (1-z_i)log\phi_2(x_i) + z_ilog\alpha + (1-z_i)log(1-\alpha) $$ In the E-step we need to find the expectation of $l_c$ $$ E[l_c(\theta;D)] = \sumi=^n E[z_i]log\phi_1(x_i)+(1-E[z_i])log\phi_2(x_i)+E[z_i]log\alpha+(1-E[z_i])log(1-\alpha) $$ For now we can assume that $<z_i>$ is known and assign it a value, let $ <z_i>=w_i$
In M-step, we have to update our data by assuming the expectation is fixed $$ \theta(t+1 <-- argmax\thet E[l_c(\theta;D)] $$ 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).
\fradd\alph = 0 \Rightarrow & \sumi=^n \fraw_i\alph-\fra1-w_i1-\alph = 0 & \Rightarrow \alpha=\fra\sumi=^n w_i
\fradd\mu_ = 0 \Rightarrow & \sumi=^n w_i(x_i-\mu_1)=0 & \Rightarrow \mu_1=\fra\sumi=^n w_ix_i\sumi=^n w_
\fradd\mu_=0 \Rightarrow & \sumi=^n (1-w_i)(x_i-\mu_2)=0 & \Rightarrow \mu_2=\fra\sumi=^n (1-w_i)x_i\sumi=^n (1-w_i
\fradd\sigma_ = 0 \Rightarrow & \sumi=^n w_i(-\fra12\sigma_1+\fra(x_i-\mu_1)^22\sigma_1^)=0 & \Rightarrow \sigma_1=\fra\sumi=^n w_i(x_i-\mu_1)^2\sumi=^n w_
\fradd\sigma_ = 0 \Rightarrow & \sumi=^n (1-w_i)(-\fra12\sigma_2+\fra(x_i-\mu_2)^22\sigma_2^)=0 & \Rightarrow \sigma_2=\fra\sumi=^n (1-w_i)(x_i-\mu_2)^2\sumi=^n (1-w_i
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 $<z_i>=w_i$ in the E-step.
<z_i> & = & Ez_i|x_i,\theta(t(z_i)
& = & \sum_z z_i P(z_i|x_i,\theta(t)
& = & 1\times P(z_i=1|x_i,\theta(t) + 0\times P(z_i=0|x_i,\theta(t)
& = & P(z_i=1|x_i,\theta(t)
P(z_i=1|x_i,\theta(t) & = & \fraP(z_i=1,x_i|\theta(t)P(x_i|\theta(t
& = & \fracP(z_i=1,x_i|\theta(t)P(z_i=1,x_i|\theta(t) + P(z_i=0,x_i|\theta(t
& = & \fra\alpha(tN(x_i,\mu_1(t,\sigma_1(t) \alpha(tN(x_i,\mu_1(t,\sigma_1(t) +(1-\alpha(t)N(x_i,\mu_2(t,\sigma_2(t
We can now combine the two steps and we get the expectation $$E[z_i] =\fra\alpha(tN(x_i,\mu_1(t,\sigma_1(t) \alpha(tN(x_i,\mu_1(t,\sigma_1(t) +(1-\alpha(t)N(x_i,\mu_2(t,\sigma_2(t $$ 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.
% %%%%% % Feb 17 I don't have these notes at all so I rewrote what I could. Also, most of the notes here seemed to be duplicates of the ones from the lecture before and after. % %%%%%
The mixture model can be summarized as:
* In each step, a state will be selected according to $p(z)$. * Given a state, a data vector is drawn from $p(x|z)$. * 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.
\hline & H & T
coin1 & 0.3 & 0.7
coin2 & 0.1 & 0.9
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.
% %%%%% % Feb 20 % %%%%%
---++ Hidden Markov Models In a Hidden Markov Model (HMM) we consider that we have two levels of random variables. The first level is called the hidden layer because the random variables in that level cannot be observed. The second layer is the observed or output layer. We can sample from the output layer but not the hidden layer. The only information we know about the hidden layer is that it affects the output layer. The HMM model can be graphed as shown in Figure \refig:HM.
\centering \epsfxsize=6in \epsfysize=4in \epsfboimages/HMM.ep \captioHidden Markov Mode \labefig:HM
In the model the $q_i$s are the hidden layer and the $y_i$s are the output layer. The $y_i$s are shaded because they have been observed. The parameters that need to be estimated are $ \theta = (\pi, A, \eta)$. Where $\pi$ represents the starting state for $q_0$. In general $\pi_i$ represents the state that $q_i$ is in. The matrix $A$ is the transition matrix for the states $q_t$ and $qt+$ and shows the probability of changing states as we move from one step to the next. Finally, $\eta$ represents the parameter that decides the probability that $y_i$ will produce $y^*$ given that $q_i$ is in state $q^*$.
For the HMM our data comes from the output layer: $$ Data = (y0, y1, y2, ... , yT) \tex for i = 1...n $$ We can now write the joint pdf as: $$ P(q, y) = p(q_0)\prodt=T-P(qt-|q_t)\prodt=P(y_t|q_t) $$ We can use $ai$ to represent the i,j entry in the matrix A. We can then define: $$ P(qt-|q_t) = \prodi,j=^M (ai)q_i^t q_jt+ $$ We can also define: $$ p(q_0) = \prodi=^M (\pi_i)q_0^ $$ Now, if we take Y to be multinomial we get: $$ P(y_t|q_t) = \prodi,j=^M (\etai)y_t^i q_t^ $$ The random variable Y does not have to be multinomial, this is just an example. We can combine the first two of these definitions back into the joint pdf to produce: $$ P(q, y) = \prodi=^M (\pi_i)q_0^\prodt=T- \prodi,j=^M (ai)q_i^t q_jt+ \prodt=P(y_t|q_t) $$ 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 $n=1$. Take the log of our pdf and we get: $$ l_c(\theta, q, y) = \sumi=^Mq_0^log(\pi_i)\sumt=T- \sumi,j=^Mq_i^t q_jt+ log(ai) \sumt=log(P(y_t|q_t)) $$ Then we take the expectation for the E-Step: $$ E[l_c(\theta, q, y)] = \sumi=^M E[q_0^i]log(\pi_i)\sumt=T- \sumi,j=^M E[q_i^t q_jt+] log(ai) \sumt=E[log(P(y_t|q_t))] $$ If we continue with our multinomial example then we would get: $$ \sumt=E[log(P(y_t|q_t))] = \sumt=\sumi,j=^M E[q_t^j] y_t^i log(\etai) $$ So now we need to calculate $E[q_0^i]$ and $ E[q_i^t q_jt+] $ in order to find the expectation of the log likelihood. Let's define some variables to represent each of these quantities.
Let $ \gamma_0^i = E[q_0^i] = P(q_0^i=1|y, \theta(t) $.
Let $ \xit,t+i = E[q_i^t q_jt+] = P(q_t^iqt+^j|y, \theta(t) $ .
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 $\alpha$ - $\beta$ Algorithm.
% %%%%% % Feb 22 % %%%%%
---+++ The $\alpha$ - $\beta$ Algorithm We have from before the expectation: $$ E[l_c(\theta, q, y)] = \sumi=^M \gamma_0^i log(\pi_i)\sumt=T- \sumi,j=^M \xit,t+i log(ai) \sumt=E[log(P(y_t|q_t))] $$ As usual we take the derivative with respect to $\theta$ and then we set that equal to zero and solve. We obtain the following results (You can check these...) . Note that for $\eta$ we are using a specific $y*$ that is given.
\hat \pi_0 & = & \fra\gamma_0^i\sumk=^M \gamma_0^
\hat ai & = & \fra\sumt=T-\xit,t+i\sumk=^M\sumt=T-\xit,t+i
\hat \eta_i(y^*) & = & \fra\sumt|y_t=y^\gamma_t^i\sumt=^T\gamma_t^
For $\eta$ we can think of this intuitively. It represents the proportion of times that state i prodices $y^*$. For example we can think of the multinomial case for y where: $$ \hat \etai = \fra\sumt=^T\gamma_t^i y_t^j\sumt=^T\gamma_t^ $$ Notice here that all of these parameters have been solved in terms of $\gamma_t^i$ and $\xit,t+i$. If we were to be able to calculate those two parameters then we could calculate everything in this model. This is where the $\alpha$ - $\beta$ Algorithm comes in.
\gamma_t^i & = & P(q_t^i = 1|y)
& = & \fraP(y|q_t)P(q_t)P(y
Now due to the Markovian Memoryless property.
\gamma_t^i & = & \fraP(y_0...y_t|q_t)P(yt+...y_T|q_t)P(q_t)P(y
& = & \fraP(y_0...y_t|q_t)P(q_t)P(yt+...y_T|q_t)P(y
& = & \fraP(y_0...y_t, q_t)P(yt+...y_T|q_t)P(y
Define $\alpha$ and $\beta$ as follows: $$ \alpha(q_t) = P(y_0...y_t, q_t) $$ $$ \beta(q_t) = P(yt+...y_T|q_t) $$ Once we have $\alpha$ and $\beta$ then computing $P(y)$ is easy. $$ P(y) = \sumq_\alpha(q_t)\beta(q_t) $$ To calculate $\alpha$ and $\beta$ themselves we can use:
For $\alpha$: $$ \alpha(qt+) = \sumq_\alpha(q_t)aq_t,qt+P(yt+|qt+) $$ Where we begin with: $$ \alpha(q_0) = P(y_0, q_0) = P(y_0| q_0)\pi_0 $$ Then for $\beta$: $$ \beta(q_t) = \sumq_\beta(qt+)aq_t,qt+P(yt+|qt+) $$ Where we now begin from the other end: $$ \beta(q_T) = (1,1,.....1) = \texA Vector of One $$ Once both $\alpha$ and $\beta$ have been calculated we can use them to find: $$ \gamma_t^i = \fra\alpha(q_t)\beta(q_t)\sumq_\alpha(q_t)\beta(q_t $$ $$ \xit,t+i = \fra\alpha(q_t)P(yt+, qt+) \beta(qt+) aq_t,qt+P(y $$
% %%%%% % Feb 24 - READING DAY - NO NOTES. % %%%%%
% %%%%% % Feb 27 - Guest Lecture % %%%%%
% %%%%% % March 1 % %%%%%
---++ Sampling Methods A fundamental problem in statistics has always been to find the expectation of $f(x)$ with respect to $P(x)$. $$ E[f] = \int f(x)P(x) dx $$ In many cases this integral is quite difficult to compute directly and so certain methods have been developed in an attempt to estimate the value without the need to actually do the integration. One such method is the Monte Carlo method where the integral is estimated by a sum. $$ \hat f = \fra1\sumi=^n f(x_i) \tex where x_i \sim P(x) $$ We can also find the mean and standard deviation for the estimate. In fact, the mean is the correct mean for $f(x)$. $$ E[\hat f] = E[f] $$ $$ \sigma\hat = \fra\sigma\sqr $$ $$ \sigma^2 = E[(f-E[f])^2] $$ So the only setback is that we have to be able to sample from $P(x)$.
---+++ Sampling from Uniform Let us assume that we want to sample from UNIF(0, 1). How would we go about doing this? Sampling from a uniform distribution that is truly random is very difficult. We are only going to look at the way it is done on a computer. On a computer we have a function that looks something like $ D \equiv ax + b\ mod\ m $ for some constants a, b and m. The choice of a, b and m is very important for the simulation of random numbers to work. The computer is also provided with a seed which will become the first term of the sequence $seed = x_0$. The seed is usually chosen from the CPU clock. After that every 'random' number is generated by $D(x_i) = xi+$. If one were to know the seed and the constants a, b and m then the series of 'random' numbers could be predicted exactly. That is why we call random numbers that are generated by a computer *Pseudo Random Numbers* .
For the rest of this section we will assume that we know how to draw from a uniform distribution. It will provide us with the 'randomness' that is needed by each of our algorithms.
---+++ Inverse Method for Sampling This is a two step method:
Step 1: Draw $ u \sim UNIF(0,1) $.
Step 2: Compute $ x = F-(u) $ where $ F = \int^\infty-\inftP(u)d $.
Suppose that we want to draw a sample from $ P(x) = \theta e-\theta $ where $x>0$. We need to first find $F(x)$ and then $F-$. $$ F(x) = \int^x_0 \theta e-\theta du = 1 - e-\theta $$ $$ F-(x) = \fra-log(1-y)\thet $$ Now we can generate our random sample $i=1...n$ from $P(x)$ by: $$1)\ u_i \sim UNIF(0,1) $$ $$2)\ x_i = \fra-log(1-u_i)\thet $$ The $x_i$ are now a random sample from $P(x)$.
The major problem with this approach is that we have to find $F-$ and for many distributions, such as the Gaussian for instance, it is too difficult to find the inverse of $F(x)$. $$ F(x) = \int-\inft^x \fra12\pe\fra-u^2 $$ Here $F-(x)$ is too hard to compute.
---+++ Box-Muller This is a method for sampling from a Gaussian Distribution. This is a unique method and it only works for this particular distribution.
- Draw $x_1$ and $x_2$ from a UNIF(0, 1).
- Accept the above values only if $ x_1^2+x_2^2 \leq 1 $. Otherwise repeat the above step until this condition is met.
- Calculate $y_1$ and $y_2$:
$$ y_1 = x_1 \fra(-2log(x_1))0.x_1^2+x_2^ $$ $$ y_2 = x_2 \fra(-2log(x_2))0.x_1^2+x_2^ $$
- $y_1$ and $y_2$ are now independent and distributed N(0,1).
---+++ Rejection Sampling Suppose that we want to sample from $P(x)$ and we are not in the Gaussian case and we can not find $F-$. Suppose also that there exists a $q(x)$ that is easy to sample from. For instance the $UNIF(0,1)$ is easy to sample from. Then if there exists a $k$ such that $kq(x)\geq p(x)$ for all x then we can use rejection sampling.
\centering \epsfxsize=4in \epsfysize=4in \epsfboimages/RejectSample.ep \captioRejection Sampling Exampl \labefig:RejectSampl
To present the problem intuitively we can observe the graph (Fig. \refig:RejectSampl) where the top line represents $kq(x)$ and the bottom line represents $p(x)$. We have in our example two points $x_1$ and $x_2$. Consider first $x_1$. From the graph we can tell that values around $x_1$ will be sampled more often under $kq(x)$ than under $p(x)$ and since we are sampling from $kq(x)$ we expect to see many more samples in this region than we actually need. We therefore must reject most of the values drawn from around $x_1$ and only keep a few. If we now look at $x_2$ we see that the number of samples that are drawn from that region and the number we need are in fact much closer and we only have to reject a few of the values that are sampled from that area. So the question is: when we get an $x_i$ from $kq(x)$ how do we know if we should keep the value or if we should throw it away? In regions where $kq(x_i)$ is far from $p(x_i)$ we must reject many more values than in regions where $kq(x_i)$ is close to $p(x_i)$. This is how rejection sampling works.
- Draw $x_i$ from $q(x)$.
- Accept $x_i$ with probability $ \frap(x_i)kq(x_i$ and reject the value otherwise.
- The accepted values are now a random sample from your $P(x)$.
What we need to show is that $P(x_i|accept) \sim P(x_i)$. $$ P(x_i|accept) = \fraP(accept|x_i)q(x_i)P(accept $$ We know from the definition of the algorithm that $ P(accept|x_i) = \frap(x_i)kq(x_i $. $$ P(accept) = \int_x P(accept|x)q(x) = \int_x \frap(x)kq(xq(x) = \fra1\int_x p(x) = \fra1 $$ $$ P(x_i|accept) = \fra\frap(x_i)kq(x_iq(x_i)\fra1 = P(x_i)$$
We have proven that rejection sampling works. But this type of sampling has some disadvantages too. For one thing we can look at the acceptance rate $ P(accept) = \fra1 $. For a large k we are discarding many values and so this method is very inefficient. Also, there are distributions $P(x)$ where it would be difficult to find a suitable $q(x)$ or $k$ that would allow us to sample from $P(x)$.
% %%%%% % March 3 % %%%%%
- Example of Rejection Sampling:*
Suppose we want to sample from a $BETA(2, 1)$. $$ BETA(2,1) = \fra\Gamma(2+1)\Gamma(2)\Gamma(1x^1(1-x)^0 = 2x \tex for 0 \leq x \leq 1 $$ Now we must find a $k$ and a $q(x)$. We can use the $UNIF(0,1)$ as our $q(x)$ because it is easy to sample from. For the value of $k$ we must find the maximum value of $\fraP(x)q(x$. In this case: $$\max \fraP(x)q(x = 2 \Rightarrow k \geq 2 $$ So we will choose our $k=2$ for this example and now we can run the algorithm.
- Draw $x_i$ from $UNIF(0,1)$.
- Accept $x_i$ with probability $ \fra2x_i2* = x_i $ and reject the value otherwise.
- The accepted values are now a random sample from $BETA(2,1)$.
% %%%%% % March 6 % %%%%%
---+++ Importance Sampling We return once again to our problem of finding the expectation of $f(x)$. $$ E[f] = \int f(x)P(x)dx $$ which can be approximated by: $$ \fra1\sumi=^n f(x) \tex where x is drawn from P(x) $$ We can try to rewrite the first equation so that we sample from $q(x)$ and not $P(x)$. $$ E[f] = \int f(x) \fraP(x)q(xq(x) dx $$ which can be approximated by: $$ \fra1\sumi=^n f(x)\fraP(x)q(x \tex where x is drawn from q(x) $$ The algorithm is as follows:
- Draw $x_i$ from $q(x)$.
- Find the weight for $x_i$, $w_i = \fraP(x_i)q(x_i$.
- The set $w_ix_i$ can now be used to estimate $E[f]$.
The main disadvantage is that in many cases we can have the weight very close to zero and the sample itself will become almost useless. We need to have a $P(x)$ and a $q(x)$ that are very close for this algorithm to be more efficient. This technique does turn out to be unbiased but due to the problem of low weights the variance tends to be very high.
---+++ Greedy Importance Sampling This method, as the name indicates, is somewhat similar to the method in the previous section. The difference from the previous algorithm is that we need to find the maximum point in $P(x)$. The algorithm works as follows:
- Draw $xi$ from $q(x)$.
- Move from $xi$ towards the maximum point in $P(x)$ and sample along the way. The new sample set $xi,..., xi$ must have the property that $\sumj=^k wi = 1$ where $wi$ is the weight of the sample $xi$.
- The set $wixi$ can now be used to estimate $E[f]$.
This method is more difficult to compute but it is unbiased and has the advantage that it also has a low variance. In short this algorithm is more complex than the regular Importance Sampling but it has a lower variance.
---+++ Markov Chain Monte Carlo This is best explained with an example. Say that we have a series random variables that each have a boolean state. Between two states $s_i$ and $si+$ we have a set of transition probabilities.
* If $s_i=0$ then $si+=0$ with probability $\fra2$. * If $s_i=0$ then $si+=1$ with probability $\fra1$. * If $s_i=1$ then $si+=0$ with probability $\fra1$. * If $s_i=1$ then $si+=1$ with probability $\fra2$.
We can say that the initial value for $s_0 = 1$. From that we can deduce that:
* $P(s_1=1) = \fra2$ and $P(s_1=0) = \fra1$ * $P(s_2=1) = \fra5$ and $P(s_2=0) = \fra4$ * $P(s_3=1) = \fra142$ and $P(s_3=0) = \fra132$ * ... * $P(s_\infty=1) = \fra1$ and $P(s_\infty=0) = \fra1$
We can see that the probabilities converge to 0.5 each. This is called the equilibrium probability distribution for this particular MCMC. If we have a $P(x)$ we want to sample from but don't know how, there may be a way to make that $P(x)$ the equilibrium probability for a MCMC and then sample from the tail end of the chain to get our random samples.
% %%%%% % March 8 % %%%%%
---++++ Metropolis Algorithm We would like to sample from some $P(x)$ and this time use the metropolis algorithm, which is a type of MCMC, to do it. In order for this algorithm to work we first need a number of things.
- We need some staring value $x$. This value can come from anywhere.
- We need to find a value $y$ that comes from the function $T(x, y)$.
- We need the function $T$ to be symmetrical. $T(x,y)=T(y,x)$.
- We also need $T(x,y) = P(y|x)$.
Once we have all of these conditions we can run the algorithm to find our random sample.
- Get a staring value $x$.
- Find the $y$ value from the function $T(x, y)$.
- Accept $y$ with the probability $min(\fraP(x)P(y, 1)$.
- If the $y$ is accepted it becomes the new x value.
- After a large number of accepted values the series will converge.
- When the series has converged any new accepted values can be treated as random samples from $P(x)$.
The point at which the series converges is called the 'burn in point'. We must always burn in a series before we can use it to sample because we have to make sure that the series has converged. The number of values before the burn in point depends on the functions we are using since some converge faster than others.
We want to prove that the Metropolis Algorithm works. How do we know that $P(x)$ is in fact the equilibrium distribution for this MC? We have a condition called the detailed balance condition that is sufficient but not necessary when we want to prove that $P(x)$ is the equilibrium distribution.
$$ $$ If $ P(x)A(x, y) = P(y)A(y,x) $ and $A(x,y)$ is the transformation matrix for the MC then $P(x)$ is the equilibrium distribution. This is called the Detailed Balance Condition.
- Proof of Sufficiency for Detailed Balance Condition:*
Need to show: $$ \int_y P(y)A(x, y) = P(x) $$ $$ \int_y P(y)A(y, x) = \int_y P(x)A(x, y) = P(x) \int_y A(x, y) = P(x) $$ We need to show that Metropolis satisfies the detailed balance condition. We can define $A(x, y)$ as follows: $$ A(x, y) = T(x, y) min(\fraP(x)P(y, 1) $$ Then,
P(x)A(x, y) & = & P(x) T(x, y) min(1 , \fraP(x)P(y)
& = & min (P(x) T(x, y), P(y)T(x, y))
& = & min (P(x) T(y, x), P(y)T(y, x))
& = & P(y) T(y, x) min(\fraP(x)P(y, 1)
& = & P(y) A(y, x)
Therefore the detailed balance condition holds for the Metropolis Algorithm and we can say that $P(x)$ is the equilibrium distribution.
Suppose that we want to sample from a $ Poisson(\lambda) $. $$ P(x) = \fra\lambda^xxe-\lambd \tex for x = 0,1,2,3, ... $$ Now define $T(x,y) : y=x+\epsilon$ where $P(\epsilon=-1) = 0.5$ and $P(\epsilon=1) = 0.5$. This type of $T$ is called a random walk. We can select any $x(0$ from the range of x as a starting value. Then we can calculate a y value based on our $T$ function. We will accept the y value as our new $x(i$ with the probability $min(\fraP(x)P(y, 1)$. Once we have gathered many accepted values, say 10000, and the series has converged we can begin to sample from that point on in the series. That sample is now the random sample from a $ Poisson(\lambda) $.
% %%%%% % March 10 % %%%%%
---++++ Metropolis Hastings
As the name suggests the _Metropolis Hastings_ algorithm is related to the _Metropolis_ algorithm. It is a more generalized version of the _Metropolis_ algorithm where we no longer require the condition that the function $T(x, y)$ be symmetric. The algorithm can be outlined as:
- Get a staring value $x$. This value can be chosen at random.
- Find the $y$ value from the function $T(x, y)$. Note that $T(x, y)$ no longer has to be symmetric.
- Accept $y$ with the probability $min(\fraP(y)T(y, x)P(x)T(x, y, 1)$. Notice how the acceptance probability now contains the function $T(x, y)$.
- If the $y$ is accepted it becomes the new $x$ value.
- After a large number of accepted values the series will converge.
- When the series has converged any new accepted values can be treated as random samples from $P(x)$.
To prove that _Metropolis Hastings_ algorithm works we once again need to show that the Detailed Balance Condition holds.
If $T(x, y) = T(y, x)$ then this reduces to the _Metropolis_ algorithm which we have already proven. Otherwise,
A(x, y) & = & T(x,y) min(\fraP(y)T(y, x)P(x)T(x, y, 1)
P(x)A(x, y) & = & P(x)T(x,y) min(\fraP(y)T(y, x)P(x)T(x, y, 1)
& = & min(P(y)T(y, x), P(x)T(x,y))
& = & P(y)T(y, x) min(1, \fraP(x)T(x, y)P(y)T(y, x)
& = & P(y)A(y, x)
Which means that the Detailed Balance Condition holds and therefore $P(x)$ is the equilibrium.
---+++ Gibbs Sampling
Suppose we want to sample from the joint probability $P(x_1, x_2, x_3)$ but we cannot sample from it directly. We can however sample from the conditional distribution $P(x_1 | x_2, x_3)$. The process can be defined as follows:
- Start with a randomly chosen $x(0$ where $x(0=(x_1(0, x_2(0, x_3(0)$.
- Once we have an $x(t$ we can find an $x(t+1$ by sampling from the conditional probability distribution.
x_1(t+1 & = & P(x_1(t | x_2(t, x_3(t)
x_2(t+1 & = & P(x_2(t | x_1(t+1, x_3(t)
x_3(t+1 & = & P(x_3(t | x_1(t+1, x_2(t+1)
- We continue this process until the burn-in point, after which we are sampling from $ P(x) $.
This process may seem different from the previous methods but in fact _Gibbs Sampling_ is only a special case of _Metropolis Hastings_ . Suppose one would like to sample from $P(x)$ where $x=(x_1, x_2, x_3 \dots x_d) \varepsilon R^d $. Propose a $y- = (x_1, \dots, xq-, xq+, \dots, x_d)$ and a $y_q = x_q$. We can define the $T(x, y)$ function from the _Metropolis Hastings_ algorithm as $T(x,y) = P(y_q | y-) = P(y_q | x-)$. In _Gibbs Sampling_ we do not reject any of the values we sampled because our rejection probability is:
P(reject) & = & min(\fraP(y)T(y, x)P(x)T(x, y, 1)
& = & min(\fraP(y)P(x_q | x-)P(x)P(y_q | x-, 1)
& = & min(\fraP(y_q | x-)P(x-)P(x_q | x-)P(x_q | x-)P(x-)P(y_q | x-, 1)
& = & min (1,1) = 1
This quality makes _Gibbs Sampling_ quite popular because we use everything we sample.
Say that we want to sample from: $$ N \left[ \left( u_1
u_2 \right), \left(c \Sigma1 & \Sigma1
\Sigma2 & \Sigma2 \right) \right ] $$ And we know that we can find the parameters with:
\mu1, & = & \mu_1+\Sigma1\Sigma2-(x2,-\mu_2)
\Sigma1, & = & \Sigma1 - \Sigma12\Sigma2-\Sigma2
For this example suppose we want to sample from : $$ N \left[ \left( 0
0 \right), \left(c 1 & L
L & 1 \right) \right ] $$ Then we can calculate:
\mu1, & = & L x2,
\Sigma1, & = & 1 - L^2
The sampling process is then done with:
x_1(t+1 & = & N(Lx_2(t, 1-L^2)
x_2(t+1 & = & N(Lx_1(t+1, 1-L^2)
% %%%%% % March 13 % %%%%%
---+++ Independence Chains In the _Metropolis Hastings_ algorithm we used a $T(x, y)$ to get the next values in the sample. Suppose now that $T(x, y) = T(y)$. In other words, the function $T$ does not depend on $x$. The acceptance probability would now become $ min(1, \fraP(y)T(x)P(x)T(y) $.
---++++ Bayesian Inference In Bayesian Inference we would like to find $P(\theta | Data) $. Suppose we use the prior on $\theta$ as the transition function and then we apply _Metropolis Hastings_ . Our acceptance probability would become: $$ min \left( 1, \fraP(\theta(t+1|Data)P(\theta(t P(\theta(t|Data)P(\theta(t+1 \right) $$ Now, recall that using Bayes rule we can write $ P(\theta|Data) =\fra P(Data|\theta)P(\theta)P(Data $. We also know that $ P(Data|\theta) = Likelihood$. From that we can rewrite the above Bayes formula as $ P(\theta|Data) =\fra L(Data;\theta)P(\theta)P(Data $.
Therefore, to sample from the posterior in a Bayesian Inference we can simply propose a $\theta(t+1 $ from the prior and then we accept with probability:
AcceptanceProb & = & min \left( 1, \fraP(\theta(t+1|Data) P(\theta(tP(\theta(t|Data)P(\theta(t+1 \right)
& = & min \left( 1, \fraL(Data; \theta(t+1)P(\theta(t)P(\theta(t+1 L(Data; \theta(t)P(\theta(t+1)P(\theta(t \right)
& = & min \left( 1, \fraL(Data; \theta(t+1 L(Data; \theta(t \right)
We would like to sample from: $$ N(7, 0.25) \tex with probability \alpha $$ and from: $$ N(10, 0.25) \tex with probability (1-\alpha) $$ The problem is that we are missing the parameter $\alpha$. We do however know that $P(\alpha) = UNIF(0,1)$. The best way to sample from the above distribution is to start with a randomly chosen $\alpha(t$ and accept with probability $min \left( 1, \fraL(Data; \theta(t+1 L(Data; \theta(t \right) $. When we reject we simply use the previous value again. This method also requires a burn in time so we must wait before we can begin sampling.
% %%%%% % March 15 % %%%%%
---+++ Simulated Annealing Consider the general optimization problem $ min_x h(x) $ and the distribution $P(x)$. Instead of finding the minimum of $h(x)$ we can try to find the maximum of $P(x)\propto exp\left\lbrace \fra-h(x) \right\rbrace $. In this case $T$ is called the _temperature_ and it determines the shape of the distribution. As $T$ increases the distribution expands but as $T\rightarrow0$ then the $x_i$ that we sample from the $P(x)$ are very close to the global min.
- Note:* If $x$ is the minimum of $h(x)$ then $x$ is also the maximum of $P(x)$.
We can define the steps to the problem as:
- Start with a randomly chosen $x$ and set $T$ to a large value.
- Propose a $y \neq x$ from the function $T(x, y) = T(y, x)$.
- Accept the $y$ value with probability $min(1, \fraP(y)P(x)$.
- Decrease the value of $T$ and return to step 1.
But what exactly does $\fraP(x)P(y$ mean? We can estimate each of these probabilities with the $ exp\left\lbrace \fra-h(x) \right\rbrace $ expression we introduced earlier.
\fraP(y)P(x & = & \frae\fra-h(y)e\fra-h(x)
& = & e\frah(x) - h(y)
We are now left with two possible cases. If $h(y) < h(x) $ then $P(y) > P(x)$ which is desired and so we will always accept the new $y$. Otherwise, if $h(y) > h(x) $ we may not accept the new $y$ value and we can see that as $T \rightarrow 0$ then $e\frah(x) - h(y)$ will also go to zero and so the acceptance probability will go to zero.
For this method we can write down a rough algorithm:
Start with $x_0$ and consider a set $T_1 > T_2 > \dots > T_k$ of $K$ values.
for $k=1$ to $K$
\hspace20pfor $j=1$ to $N_k$
\hspace20pPropose a $y$ from $T(y, x)$.
\hspace20p$U = UNIF(0, 1)$
\hspace20pif $U \leq min(1, \fraP(y)P(xj-) $
\hspace30p$x_j = y$
\hspace30p$x_j = xj-$
endfor %%%% %% In my notes I have the following: %%%% %---++++ Traveling Salesman %In a graph $G$ we start from vertex $v$ and try to go through all other vertices and end up back at $v$ and have the minimum cost for the whole path. %% I commented it out because it does not seem related to anything we did before or after.
% %%%%% % March 17 % %%%%%
---+++ Bootstrap In data analysis we usually have an observed set of data $\left\lbrace x_1, x_2, \dots, x_n \right\rbrace $ from a probability distribution $P$ and we have an estimator $\ha\thet$ for our parameter of interest $\theta$. In general it would be useful to know the distribution of our $\ha\thet$. For instance, if the estimator has a larger variance then we know that it is not very accurate. The problem is that it is not always easy to determine the distribution of an estimator. Ideally we would like to be able to sample directly from $P$ and then for each sample of size $n$ we can calculate a $\ha\thet$. In this way a number of estimates for $\theta$ can be found and their distribution can be determined from the samples.
- For Example:*
\lbrace x_1(1, x_2(1, \dots, x_n(1 \rbrace & \Rightarrow & \ha\theta_
\lbrace x_1(2, x_2(2, \dots, x_n(2 \rbrace & \Rightarrow & \ha\theta_
\dots & &
\lbrace x_1(B, x_2(B, \dots, x_n(B \rbrace & \Rightarrow & \ha\theta_
Based on $ \lbrace \ha\theta_, \ha\theta_, \dots, \ha\theta_ \rbrace $ we can try to determine the distribution of $\ha\thet$.
However, this idea is unrealistic because we don't know $P$ and so we cannot sample from it. This is where the _Bootstrap_ idea comes in. Assume that we have a set of data $\left\lbrace x_1, x_2, \dots, x_n \right\rbrace $ from an unknown distribution $P$. To simulate sampling from $P$ we can resample with replacement from the set of $n$ data points. Every sample we get in this way we can use to estimate a different $\ha\thet$. We can use this method to find a collection of $\ha\theta_$ parameters from which we can:
- Find the expectation of $\ha\thet$.
$$ E(\ha\thet) = \fra1 \sumr=^B \ha\theta_ $$
- Find the variance of $\ha\thet$.
$$ Var(\ha\thet) = \fra1B-\sumr=^B(\ha\theta_ - E(\ha\thet))^2 $$
- Find a confidence interval.
$$ (\ha\thet - 2*S.E., \ha\thet + 2*S.E.) $$
- Find the bias.
$$ bias(\ha\thet) = \ha\thetorigina - E(\ha\thet) $$
- Bias correction.
$$ \ha\thet - bias $$
At first, this method seems strange. We are sampling from the sample itself and not the distribution. However, it has been shown that the _Bootstrap_ method does indeed work and can provide more useful information on top of what the raw data could have provided.
This kind of _Bootstrap_ is called the _Naive Bootstrap_ because the values are sampled one at a time independently and this destroys any kind of correlation in the initial distribution. The correct _Bootstrap_ method requires the selection of blocks of data in order to keep the correlation in the data. These blocks are sampled with replacement and may overlap.
% %%%%% % March 20 I do not have the notes for March 20. What was taught then? % %%%%%