\documentclass[12pt]{article}
%% newest 10/26
\usepackage{amsmath}
\usepackage{amssymb}

\usepackage{color}
\usepackage{graphicx}
\usepackage{epstopdf} 
\DeclareGraphicsExtensions{.pdf,.eps,.png,.jpg,.mps} 

\textheight 230mm
\topmargin 5mm
\textwidth 160mm
\oddsidemargin -2mm

\pagestyle{myheadings}
\markright{(Bayesian Decision Making)}

\newtheorem{formula}{Rule}
\newtheorem{example}{Example}
\newtheorem{exercise}{Exercise}
\newtheorem{algorithm}{Algorithm}
\newtheorem{definition}{Definition}


\makeatletter
\let\c@figure\c@table
\let\p@figure\p@table
\let\cl@figure\cl@table
\let\thefigure\thetable
\makeatother


\begin{document}
\thispagestyle{empty}

\title{{\bf Bayesian Decision Making} \\ 
        {\large for \\
        postgraduate \\
\author{Akira Imada \\
Brest State Technical University, Belarus \\
        \hspace*{1in}\\
        \hspace*{1in}\\
        (last modified on)}}}
\maketitle

\clearpage

\section*{Bibliography}
This lectures is partly based on the wonderful book:
\begin{itemize}
\setlength{\itemsep}{0pt}
\item  R. O. Duda, P. E. Hart and D. G. Stork (2000) "Pattern Classification." 2nd Edition, John Wiley \& Sons.
\end{itemize}
Also
\begin{itemize}
\setlength{\itemsep}{0pt}
\item  S. Theodoridis and K. Koutroumbas (1998) "Pattern Recognition" Academic Press.
\item K. B. Korb and A. E. Nicholson (2003) "Bayesian Artificial Intelligence." (Available from Internet without its reference list though.)
\item E.~Charniak (1991) "Bayesian Networks without Tears." AI MAGAZINE Vol. 12 No. 4, pp. 50-63. (Available from Internet.)
\end{itemize}

\noindent
are referred.

\clearpage
\section*{Index}

\clearpage
\begin{center}
{\Huge {\bf PART I}} \\ 
\bigskip 
{\Large {\bf BAYESIAN CLASSIFICATION}}
\end{center}

\vspace{.6in}

\begin{itemize}
\item[1.]  Assuming all distributions are Gaussian p.d.f. with known parameters.
\item[2.]  Assuming we know the form of distribution but don't know its parameters.
\item[3.]  Assuming we don't know the distribution of dataset given.
\end{itemize}


\clearpage
\section{An example to start with.}
In general, we need what {\it features} can be used for pattern classification purpose. This is, of course, one of big issues in pattern classification, but here we assume that we already know {\it features} which
efficiently can be used to classify our target patterns.\\

\subsection{Which do you like better female or male?}
I mean not human, but salmon. Well, we now assume, as an example, we want to classify salmons into female and male. The situation is, we have thousands of salmons and our task is to classify salmons into female and male only by observing one feature $x$ --- length of the salmon.


\subsection{If we only know prior probability.}
If we don't know any prior information except for how many we've had so far are female and male. Now we denote the class of female salmon as $\omega_1$ and the class of male salmon as $\omega_2$. Then above mentioned ``how many we've had so far are female and male'' are denoted as $P(\omega_1)$ and $P(\omega_2)$, respectively, and called {\it prior probability}.\\

\noindent
Note here $p(\cdot)$ denotes a probability and $P(\cdot)$ denotes a density distribution.\\

\noindent
In this case, all we should act is with the following rule.\\

\bigskip
\color{red}
\begin{formula}[Classification only with prior probability] \label{rule-1}
If $P(\omega_1) > P(\omega_2)$ then classify it to $\omega_1$ otherwise $\omega_2$.
\end{formula}
\color{black}

\noindent
This might seem to be a trivial reaction - not a clever strategy at all.

\subsection{If we also know posterior distribution of features.}
If we assume that we know further distribution of length $s$ in each of female and male salmon, that is, $p(x \vert \omega_1)$ and $p(x \vert \omega_2)$, then our task of classify salmons with an observation of $x$ is a little more sophisticated.\\

\noindent
Note here $p(\cdot)$ denotes a probability and $P(\cdot)$ denotes a density distribution.\\

\noindent
Instinctively, we might put the threshold $\theta$ as in Fig.~1. If both classes are equally important then we put it at the center of those two distribution functions. But sometimes we might put it in different way like in Fig.~2, if we take it into account that the risk of misclassify $x$ into $\omega_2$ while $x$ is $\omega_2$ is important\footnote{In the case of salmon, we tend to be happier if the one we bought a male salmon with cheaper price than female due to eggs, was mistakenly female.}.\\

\begin{figure}[bhtp]\label{fig:well-separate-gaussian}
 \begin{center}
\includegraphics[width=15cm,height=5cm]{two-gaussian-2.eps}
%% \epsfile{file=two-gaussian-2.eps,width=15cm,height=5cm}
 \end{center}
 \caption{An example of two distribution of the observation $x$ w.r.t. each class of $\omega_1$ and $\omega_2$. Here reader might image that distribution of length of female salmon and male salmon.}
\end{figure}

\begin{figure}[bhtp]
 \begin{center}
\includegraphics[width=15cm,height=5cm]{two-gaussian.eps}
 \end{center}
 \caption{Yet another example where two distributions are closer than the first example. Two threshold are shown, considering a risk of miss-classification.}
\end{figure}

\noindent
In the example of Fig.~\ref{fig:well-separate-gaussian},
you might imagine {\it a classification for human female and male by one feature -- frequency of her/his voice}. In this case $p(x \vert \omega_1)$ and $p(x \vert \omega_1)$ would be well separated and easy to classify.\\ 

\color{red}
\begin{formula}[Classification with posterior probability]\label{rule-2}
If $P(x \vert \omega_1) > P(x \vert \omega_2)$ then classify it to $\omega_1$ otherwise $\omega_2$.
\end{formula}
\color{black}

\clearpage
\section{Before moving on further}

\subsection{Example of Bayesian Rule}

$\bullet$ Example-1\\
\noindent
We have two bags of no difference from its outlook. One bag called R has 70 red balls and 30 blue balls. The other bag called B has 30 red balls and 70 blue balls. When we take one bag at random and pick up 12 balls, returning it to the bag at each time. The result was 8 red balls and 4 blue one. Then was the bag estimated to be R or B, and how probable the estimate is?\\

\noindent
$\bullet$ Example-2\\
\noindent
In a courtroom trial with a male defendant, CCTV evidence from a pub shows a crime being committed by an individual carrying a bottle, but it is unclear whether this is a male or a female. A witness reports seeing the defendant carrying a bottle around the time of the offense. Suppose that examination of the tape shows 60\% of customers were male, and 2\% of males and 1\% of females carried bottles at any given moment. How strong is the evidence against the defendant?\\

\noindent
$\bullet$ Example-3\\
\noindent
Suppose the AIDS positive is one in 100. Suppose the test has a false positive rate of 0.2 (that is, 20\% of people without HIV will test positive for HIV) and that it has a false negative rate of 0.1 (that is, 10\% of people with HIV will test negative). The laws of probability dictate from this last fact that the probability of a positive test given HIV is 90\%. Now suppose that you are such a person who has just tested positive. What is the probability that you have HIV?\\

\noindent
$\bullet$ Example-4\footnote{Taken from the book ``Bayesian Artificial Intelligence'' by
Kevin B. Korb \& Ann E. Nicholson (2004)}\\
\noindent
The legal system is replete with misapplication of probability and with incorrect claims of the irrelevance of probabilistic reasoning as well. In 1964 an interracial couple was convicted of robbery in Los Angeles, largely on the grounds that they matched a highly improbable profile, a profile which fit witness reports. In particular, the two robbers were reported to be A man with a mustache

\begin{itemize}
\setlength{\itemsep}{0pt}
\item[-] Who was black and had a beard
\item[-] And a woman with a pony tail
\item[-] Who was blonde
\item[-] The couple was interracial
\item[-] And were driving a yellow car
\end{itemize}

\noindent
The prosecution suggested that these characteristics had the following probabilities of being observed at random in the LA area.
\begin{itemize}
\setlength{\itemsep}{0pt}
\item[-] A man with a mustache 1/4
\item[-] Who was black and had a beard 1/10
\item[-] And a woman with a pony tail 1/10
\item[-] Who was blonde 1/3
\item[-] The couple was interracial 1/1000
\item[-] And were driving a yellow car 1/10\\
\end{itemize}

\noindent
$\bullet$ Example-5\\
\noindent
Three prisoners ({\bf A}, {\bf B}, and {\bf C}) are in a prison. {\bf A} knows the fact that the two out of the three are to be executed tomorrow, and the rest becomes free. {\bf A} thought either one of {\bf B} or {\bf C} is sure to be executed. Then, {\bf A} asked a guard ``even if you tell me which of {\bf B} and {\bf C} is executed, that will not give me any information as for me. So please tell it to me.'' The guard answers that {\bf C} will. $\Rightarrow$ data $D$ Now, {\bf A} knows one of {\bf A} or {\bf B} is sure to be free.


\subsection{Multidimensional Gaussian p.d.f.}
\subsubsection{1-D Gaussian}

\begin{displaymath} \nonumber
f(x) = \frac{1}{\sqrt{2\pi} \sigma}
\exp\{{-\frac{1}{2} \frac{(x-\mu)^2}{{\sigma}^2}}\}
\end{displaymath}

\color{blue}
\begin{exercise}
Create 100 points $x_i$which are distributed following 1-D Gaussian in which $\mu = 5$ and $\sigma = 2$.
\end{exercise}
\color{black}

\subsubsection{2-D Gaussian}

\begin{equation} \label{eq: gaussian-multi-d} \nonumber
f(\mbox{\bf x}) = 
\frac{1}{(2\pi)^{d/2} \vert \Sigma_i \vert ^{1/2}}
\exp\{- \frac{1}{2}(\mbox{\bf x} - \boldsymbol{\mu}_i)^t {\Sigma_i}^{-1} (\mbox{\bf x} - \boldsymbol{\mu}_i)\}
\end{equation}

\color{blue}
\begin{exercise}
Create 100 points $(x_i, y_i)$ which are distributed following 2-D Gaussian in which ...
$\mu_1 = (2.5, 2.5)$ and $\mu_2 = (7.5, 7.5)$ and 
\begin{eqnarray} \nonumber
\Sigma =
\left(
\begin{array}{cc}
0.2 &  0.4             \\
0.7 &  0.3
\end{array}
\right),
\end{eqnarray}
and
\begin{eqnarray} \nonumber
\Sigma =
\left(
\begin{array}{cc}
0.1 &  0.1             \\
0.1 &  0.1
\end{array}
\right).
\end{eqnarray}
\end{exercise}
\color{black}

\section{What will borders look like on what condition?}
Now that  we restrict our universe in two-dimensional space, we use a notation $(x,y)$ instead of $(x_1,x_2)$. So we now express $\mbox{\bf x} = (x, y)$. Furthermore, both of our two classes are assumed to follow the Gaussian p.d.f. whose $\mu$ are $\boldsymbol{\mu}_1 = (0,0)$ and $\boldsymbol{\mu}_2 = (1,0)$, and $\Sigma$ are

\begin{eqnarray}
\nonumber
\Sigma_1 =
\left(
\begin{array}{cc}
a_1 & 0             \\
0   & b_1
\end{array}
\right),
\hspace*{.2in}\Sigma_2 =
\left(
\begin{array}{cc}
a_2 & 0             \\
0   & b_2
\end{array}
\right)
\end{eqnarray}

\noindent
Under this simple condition, our inverse matrix is simply, 
$\vert \Sigma_1 \vert = a_1b_1$
and 
$\vert \Sigma_2 \vert = a_2b_2$. 
So, we now know
\begin{eqnarray}
\nonumber
\Sigma_1^{-1} = \frac{1}{a_1b_1}
\left(
\begin{array}{cc}
b_1 & 0             \\
0   & a_1
\end{array}
\right) =
\left( 
\begin{array}{cc}
1/a_1 & 0             \\
0   & 1/b_1
\end{array}
\right)
\end{eqnarray}
and in the same way
\begin{eqnarray}
\nonumber
\Sigma_2^{-1} = \frac{1}{a_2b_2}
\left(
\begin{array}{cc}
b_2 & 0             \\
0   & a_2
\end{array}
\right) =
\left( 
\begin{array}{cc}
1/a_2 & 0             \\
0   & 1/b_2
\end{array}
\right)
\end{eqnarray}

Now our Gaussian equation is more specifically

\begin{eqnarray}
\nonumber
p(\mbox{\bf x} \vert \omega_1) = 
\frac{1}{2\pi \sqrt{a_1b_1}}
\exp\{- \frac{1}{2}
(x \hspace{.1in} y)
\left( 
\begin{array}{cc}
1/a_1 & 0             \\
0   & 1/b_1
\end{array}
\right)
\left( 
\begin{array}{c}
x       \\
y
\end{array}
\right)\}
\end{eqnarray}
and 
\begin{eqnarray}
\nonumber
p(\mbox{\bf x} \vert \omega_2) = 
\frac{1}{2\pi \sqrt{a_2b_2}}
\exp\{- \frac{1}{2}
(x-1 \hspace{.1in} y)
\left( 
\begin{array}{cc}
1/a_2 & 0             \\
0   & 1/b_2
\end{array}
\right)
\left( 
\begin{array}{c}
x-1       \\
y
\end{array}
\right)\}.
\end{eqnarray}
Then we can define our discriminant function $g_i(\mbox{\bf x})$ ($i = 1, 2$) taking {logarithm based natural number $e$} as

\begin{eqnarray}
\nonumber
g_1(\mbox{\bf x}) = 
- \frac{1}{2}
(x \hspace{.1in} y)
\left( 
\begin{array}{cc}
1/a_1 & 0             \\
0   & 1/b_1
\end{array}
\right)
\left( 
\begin{array}{c}
x       \\
y
\end{array}
\right)
+ \ln (2\pi) + \frac{1}{2} \ln(a_1b_1)
\end{eqnarray}
and 
\begin{eqnarray}
\nonumber
g_2(\mbox{\bf x}) = 
- \frac{1}{2}
(x-1 \hspace{.1in} y)
\left( 
\begin{array}{cc}
1/a_2 & 0             \\
0   & 1/b_2
\end{array}
\right)
\left( 
\begin{array}{c}
x-1       \\
y
\end{array}
\right)
+ \ln (2\pi) + \frac{1}{2} \ln(a_2b_2)
\end{eqnarray}
Neglecting here the common term for both equation $\ln(2\pi)$, our new discriminant functions are

\begin{displaymath}
g_1(\mbox{\bf x}) = -\frac{1}{2}\{\frac{x^2}{a_1}+\frac{y^2}{b_1}\} + \frac{1}{2} \ln(a_1b_1)
\end{displaymath}

and

\begin{displaymath}
g_2(\mbox{\bf x}) = -\frac{1}{2}\{\frac{(x-1)^2}{a_2}+\frac{y^2}{b_2}\} + \frac{1}{2} \ln(a_2b_2)
\end{displaymath}

\clearpage
\noindent
Finally, we obtain the border equation from $g_1(\mbox{\bf x}) - g_2(\mbox{\bf x}) = 0$.

\begin{equation}\label{eq:two-d-gaussian-final}
(\frac{1}{a_1}-\frac{1}{a_2})x^2 + \frac{2}{a_2}x + (\frac{1}{b_1}-\frac{1}{b_2})y^2
= \frac{1}{a_2} + \ln \frac{a_1b_1}{a_2b_2}
\end{equation}

\noindent
We now know that the shape of the border will be either of the following five cases:
(i) straight line
(ii) circle;
(iii) ellipse;
(iv) parabola;
(v) hyperbola;
(Vi) two straight lines,
depending on how the points distribute, that is, depending on $a_1$, $b_1$, $b_1$ and $b_2$ in our situation above.



\subsection{Examples}
Let's try following calculations,

\begin{eqnarray}
\nonumber
(1) \hspace{.2in}\Sigma_1 =
\left(
\begin{array}{cc}
0.10 & 0             \\
0    & 0.10
\end{array}
\right),
\hspace{.5in}\Sigma_2 =
\left(
\begin{array}{cc}
0.10 & 0             \\
0    & 0.10
\end{array}
\right)
\end{eqnarray}

\begin{eqnarray}
\nonumber
(2) \hspace{.2in}\Sigma_1 =
\left(
\begin{array}{cc}
0.10 & 0             \\
0    & 0.10
\end{array}
\right),
\hspace{.5in}\Sigma_2 =
\left(
\begin{array}{cc}
0.20 & 0             \\
0    & 0.20
\end{array}
\right)
\end{eqnarray}

\begin{eqnarray}
\nonumber
(3) \hspace{.2in}\Sigma_1 =
\left(
\begin{array}{cc}
0.10 & 0             \\
0    & 0.15
\end{array}
\right),
\hspace{.5in}\Sigma_2 =
\left(
\begin{array}{cc}
0.20 & 0             \\
0    & 0.25
\end{array}
\right)
\end{eqnarray}

\begin{eqnarray}
\nonumber
(4) \hspace{.2in}\Sigma_1 =    %% In my PC this is not 4th but 5th.
\left(
\begin{array}{cc}
0.10 & 0             \\
0    & 0.15
\end{array}
\right),
\hspace{.5in}\Sigma_2 =
\left(
\begin{array}{cc}
0.15 & 0             \\
0    & 0.10
\end{array}
\right)
\end{eqnarray}

\begin{eqnarray}
\nonumber
(5) \hspace{.2in}\Sigma_1 =    %% In my PC this is not 5th but 7th.
\left(
\begin{array}{cc}
0.10 & 0             \\
0    & 0.20
\end{array}
\right),
\hspace{.5in}\Sigma_2 =
\left(
\begin{array}{cc}
0.10 & 0             \\
0    & 0.10
\end{array}
\right)
\end{eqnarray}


\noindent
The next example is somewhat tricky. I wanted an example in which the right-hand side of the equation (6) becomes zero and the left-hand side is a product of one-order equations of $x$ and $y$. As you might know, this is the case where border equation will be made up of two straight lines.

\begin{eqnarray}
\nonumber
(6) \hspace{.2in}\Sigma_1 =    %% In my PC this is not 5th but 7th.
\left(
\begin{array}{cc}
2e & 0             \\
0    & 0.5
\end{array}
\right),
\hspace{.5in}\Sigma_2 =
\left(
\begin{array}{cc}
1    &  0             \\
0    &  1
\end{array}
\right)
\end{eqnarray}

\noindent
My quick calculation tentatively results in as follows. See also the Figure below.
\begin{itemize}
\setlength{\itemsep}{0pt}
\item[(1)] $2x                              = 1              $
\item[(2)] $5 (x + 1)^2        + 5      y^2 = 10 - \ln4      $ 
\item[(3)] $5(x + 1)^2         + (8/3)  y^2 = 10 - \ln (10/3)$
\item[(4)] $5(x + 1)^2         - (10/3) y^2 = 10             $
\item[(5)] $20x                - 5      y^2 = 10 - \ln 2     $
\item[(6)] $(1 - 1/2e) x^2 - x -        y^2 = 0              $
\end{itemize}

\begin{figure}[bhtp] \label{fig:2d-ex}
 \begin{center}
\includegraphics[width=5cm,height=5cm]{two-d-example-1.eps}
\includegraphics[width=5cm,height=5cm]{two-d-example-2.eps}
\includegraphics[width=5cm,height=5cm]{two-d-example-3.eps}
\includegraphics[width=5cm,height=5cm]{two-d-example-6.eps}
\includegraphics[width=5cm,height=5cm]{two-d-example-5.eps}
\includegraphics[width=5cm,height=5cm]{two-d-example-4.eps}
 \end{center}
 \caption{A cloud of 100 points each extracted from a set of two classes and border of the two classes calculated on six different conditions. (Results of (5) and (6) are still fishy and under another trial.)}
\end{figure}



\clearpage
\subsection{3-D Gaussian case}\label{subsec}
\subsubsection*{$\bullet$ When all $\Sigma_i = \Sigma$}
\noindent
Here we study only one example. We assume two classes where $P(\omega_1) = P(\omega_1) = 1/2$. In each class, the patterns are distributed with Gaussian p.d.f both have the same covariance matrix
\begin{eqnarray}
\nonumber
\Sigma_i = \Sigma_j = \Sigma = 
\left(
\begin{array}{ccc}
 0.3 &  0.1 &  0.1      \\
 0.1 &  0.3 & -0.1      \\
 0.1 & -0.1 &  0.3
\end{array}
\right)
\end{eqnarray}

\noindent
and means of the distribution are $(0, 0, 0)^T$ and $(1, 1, 1)^T$. 
We now take a look at what our discriminant function

\begin{eqnarray}\label{eq:2-d-gaussian}
g_i(\mbox{\bf x})  
 &=& - \frac{1}{2} (\mbox{\bf x}- \boldsymbol{\mu}_i)^T
            \Sigma_i^{-1}(\mbox{\bf x}- \boldsymbol{\mu}_i)%% + \ln p(\omega_i) + c_i
\end{eqnarray}
\noindent
leads to? \\

\noindent 
Since we calculate (See APPENDIX for detail)

\begin{eqnarray}
\nonumber
\Sigma^{-1}
= \frac{1}{30}
\left(
\begin{array}{ccc}
 5  & -3 & -3       \\
-2  &  6 &  3       \\
-1  &  3 &  6
\end{array}
\right)
\end{eqnarray}

\noindent
Now our discriminant equation $g_1(\mbox{\bf x}) = g_2(\mbox{\bf x})$ is

\begin{eqnarray}
\nonumber
(x_1 x_2 x_3)
\left(
\begin{array}{ccc}
 5  & -3 & -3       \\
-2  &  6 &  3       \\
-1  &  3 &  6
\end{array}
\right)
\left(
\begin{array}{c}
x_1      \\
x_2      \\
x_3  
\end{array}
\right) = \hspace{1.5in}
\end{eqnarray}
\begin{eqnarray}
\nonumber
\hspace*{1.5in} 
((x_1-1) (x_2-1) (x_3-1))
\left(
\begin{array}{ccc}
 5  & -3 & -3       \\
-2  &  6 &  3       \\
-1  &  3 &  6
\end{array}
\right)
\left(
\begin{array}{c}
x_1-1 \\
x_2-1 \\
x_3-1
\end{array}
\right)
\end{eqnarray}

\noindent
Further calculation leads to

\begin{eqnarray}
\nonumber
((5x_1-2x_2-x_3)(-3x_1+6x_2+3x_3))
\left(
\begin{array}{c}
x_1      \\
x_2      \\
x_3  
\end{array}
\right)=
\end{eqnarray}
\begin{eqnarray}
\nonumber
%%((  (x_1-1)-2(x_2-1)- (x_3-1)) 
%%( -3(x_1-1)+6(x_2-1)+3(x_3-1))
%%( -3(x_1-1)+3(x_2-1)+6(x_3-1)
(( 5x_1-2x_2- x_3-2) 
 (-3x_1+6x_2+3x_3-6)
 (-3x_1+3x_2+6x_3-6))
\left(
\begin{array}{c}
x_1-1      \\
x_2-1      \\
x_3-1  
\end{array}
\right)
\end{eqnarray}

\noindent
All the 2nd-order terms are canceled and we obtain,

\begin{displaymath}
7x_1 + 13x_2 - 20x_3 = 14
\end{displaymath}

We now know that it is the plane which discriminates two of these classes $\omega_1$ and $\omega_2$.



\subsection{A Higher order Gaussian case}
The Equation 

\begin{eqnarray}
\nonumber
g_i(\mbox{\bf x}) 
 &=& \ln (p(\mbox{\bf x} \vert \omega_i) + \ln P(\omega_i))\\
\end{eqnarray}

\noindent
still holds, of course. Now let's recall that the Gaussian p.d.f. is

\begin{equation}
p(\mbox{\bf x} \vert \omega) = \frac{1}{{(2\pi)}^{d/2} {\vert {\Sigma} \vert}^{1/2}}
\exp \{-\frac{1}{2}(\mbox{\bf x}-\boldsymbol{\mu})^t \Sigma^{-1}(\mbox{\bf x}-\boldsymbol{\mu})\}
\end{equation}

\noindent
and as such

\begin{equation} \label{eq:discriminant-fn}
g_i(\mbox{\bf x}) 
= -\frac{1}{2}(\mbox{\bf x}- \boldsymbol{\mu}_i)^t \Sigma_i^{-1}(\mbox{\bf x}-\boldsymbol{\mu}_i)
- \frac{d}{2}\ln(2\pi)-\frac{1}{2}\vert \Sigma_i \vert + \ln P(\omega_i)
\end{equation}

\noindent
We know take a look at cases which simplify situation more or less.\\


\bigskip
\subsubsection*{$\bullet$ When $\Sigma_i = \sigma^2 I$}

\noindent
In this case, it's easy to guess samples fall in equal diameter hyper-shapers. Note, first of all
$\vert \Sigma_i \vert = \sigma^{2d}$ and $\Sigma_i^{-1} = (1/\sigma^2)I$.
So, we assume $g_i(\mbox{\bf x})$ here to be

\begin{equation}
g_i(\mbox{\bf x}) = - \frac{\| \mbox{\bf x} - \boldsymbol{\mu}_i \| ^2}{2\sigma^2} + \ln P(\omega_i)
\end{equation}
or, equivalently
\begin{equation}
g_i(\mbox{\bf x}) 
= - \frac{1}{2\sigma^2} 
({\mbox{\bf x}}^t {\mbox{\bf x}} - 2\boldsymbol{\mu}_i^t {\mbox{\bf x}} + \boldsymbol{\mu}_i^t\boldsymbol{\mu}_i)
+ \ln P(\omega_i)
\end{equation}
Neglecting the terms those no affecting to the relation
$g_i(\mbox{\bf x})-g_j(\mbox{\bf x})= 0$ our $g_i(\mbox{\bf x})$ is now
\begin{equation}
g_i(\mbox{\bf x}) 
= \frac{1}{\sigma^2}
\boldsymbol{\mu}_i^t {\mbox{\bf x}}
- \frac{1}{2\sigma_i^2} \boldsymbol{\mu}_i^t\boldsymbol{\mu}_i + \ln P(\omega_i)
\end{equation}
Then $g_i(\mbox{\bf x})-g_j(\mbox{\bf x})=0$ leads to

\begin{equation} \label{eq:discrimitnant}
\frac{1}{\sigma^2}
(\boldsymbol{\mu}_i - \boldsymbol{\mu}_i)^t {\mbox{\bf x}}
- \frac{1}{2\sigma_i^2} (\| \boldsymbol{\mu}_i \|^2 - \| \boldsymbol{\mu}_j \|^2) + \ln \frac{P(\omega_i)}{P(\omega_j)} = 0
\end{equation}


\noindent
If we carefully modify Eq. (\ref{eq:discrimitnant}) we will obtain
\begin{equation}\label{eq:100}
\mbox{\bf W}\cdot(\mbox{\bf x} - \mbox{\bf x}_0) = 0.
\end{equation}


\noindent
In this case our classification rule will be\\

\bigskip
\color{red}
\begin{formula}[Minimum Distance Classification]
Measure Euclidean distance $\| \mbox{\bf x} - \boldsymbol{\mu} \|$ for $\forall i$,
then classify $\mbox{\bf x}$ to the class whose mean is nearest to  $\mbox{\bf x}$.
\end{formula}
\color{black}


\bigskip
\color{blue}
\begin{exercise}
Derive the Eq. (\ref{eq:100}) specifying $\mbox{\bf W}$ and ${\mbox{\bf x}}_0$.
\end{exercise}
\color{black}

\bigskip
\noindent
Eq. (\ref{eq:100}) is the equation which can be interpret as
\begin{center}{\it
``A hyperplane through ${\mbox{\bf x}}_0$ perpendicular to ${\mbox{\bf W}}$.''
}\end{center}


\subsubsection*{$\bullet$ When all $\Sigma_i = \Sigma$}
\noindent
This condition implies that the patterns in each of both classes
distribute like hyper-ellipsoid. 
Now that our discriminant function is
\begin{displaymath}
g_i(\mbox{\bf x}) = -\frac{1}{2}(\mbox{\bf x}-\boldsymbol{\mu})^t \Sigma^{-1}(\mbox{\bf x}-\boldsymbol{\mu})
\end{displaymath}

\noindent
We again obtain

\begin{displaymath}
\mbox{\bf W}\cdot(\mbox{\bf x} - \mbox{\bf x}_0) = 0
\end{displaymath}

\noindent
where $\mbox{\bf W}$ and $\mbox{\bf x}_0$ are

\begin{equation}
\mbox{\bf W} = \Sigma^{-1}(\boldsymbol{\mu}_i - \boldsymbol{\mu}_j)
\end{equation}
and 
\begin{equation}
\mbox{\bf x}_0 = \frac{1}{2}(\boldsymbol{\mu}_i + \boldsymbol{\mu}_j)
- \frac{\ln P(\omega_i)/P(\omega_j)}
{(\boldsymbol{\mu}_i - \boldsymbol{\mu}_j)^t \Sigma^{-1} (\boldsymbol{\mu}_i - \boldsymbol{\mu}_j)}
\end{equation}

\noindent
Notice here that $\mbox{\bf W}$ is no more perpendicular to the  direction between 
$\boldsymbol{\mu}_i$ and $\boldsymbol{\mu}_j$.

\bigskip
\color{blue}
\begin{exercise}
Derive $\mbox{\bf w}$ and ${\mbox{\bf x}}_0$ above.
\end{exercise}
\color{black}

\bigskip
\noindent
So we modify the above rule to

\bigskip
\color{red}
\begin{formula}[Classification by Mahalanobis distance]
Assign {\bf x} to $\omega_i$ in which Mahalanobis distance from $\boldsymbol{\mu}_i$
is minimum for $\forall i$.
\end{formula}
\color{black}

\bigskip
\noindent
Yes! This {\it Mahalanobis distance} between {\bf a} and {\bf b}
is defined as 
\begin{equation}
(\mbox{\bf a} - \mbox{\bf b})^t \Sigma^{-1} (\mbox{\bf a}- \mbox{\bf b})
\end{equation}


\noindent
The final example in this sub-section is more general 2-dimensional case, but
(artificially) devised so that calculations won't become very complicated. 
We now assume $\boldsymbol{\mu}_1 = (0,0)$ and $\boldsymbol{\mu}_2 = (1,0)$, and we both classes share
the same $\Sigma$:
\begin{eqnarray}
\nonumber
(7) \hspace{.2in}\Sigma_1 =
\left(
\begin{array}{cc}
1.1 & 0.3             \\
0.3 & 1.9
\end{array}
\right),
\hspace{.5in}\Sigma_2 =
\left(
\begin{array}{cc}
1.1 & 0.3             \\
0.3 & 1.9
\end{array}
\right)
\end{eqnarray}


\bigskip
\subsubsection*{$\bullet$ When all $\Sigma_i$'s are arbitrary}
\noindent
When no such restriction as above to simplify situation, the discriminant function is

\begin{displaymath}
g_i(\mbox{\bf x}) = -\frac{1}{2}(\mbox{\bf x}-\boldsymbol{\mu})^t \Sigma_i^{-1}(\mbox{\bf x}-\boldsymbol{\mu})
-\frac{d}{2} \ln 2\pi - \frac{1}{2} \ln \vert \Sigma_i \vert + ln P(\omega_i)
\end{displaymath}

Only the term we can neglect now is $(d/2) \ln 2\pi$. We now apply the identity
\begin{displaymath}
(\mbox{\bf x} - \mbox{\bf y})^t A (\mbox{\bf x} - \mbox{\bf y})
= \mbox{\bf x}^t A \mbox{\bf x} - 2 (A \mbox{\bf y})^t\mbox{\bf x} 
+ \mbox{\bf y}^t A \mbox{\bf y}.
\end{displaymath}

Then, we get the following renewed discriminant function

\begin{equation}
g_i(\mbox{\bf x}) = \mbox{\bf x}^t W_i \mbox{\bf x} + \mbox{\bf w}_i^t \mbox{\bf x} + w_{i0}
\end{equation}

where

\begin{displaymath}
W_i = - \frac{1}{2} \Sigma_i^{-1}
\end{displaymath}

\begin{displaymath}
\mbox{\bf w}_i = \Sigma_i^{-1}\boldsymbol{\mu}_i
\end{displaymath}
\begin{displaymath}
w_{i0} = -\frac{1}{2} \boldsymbol{\mu}_i^t \Sigma_i^{-1} \boldsymbol{\mu}_i
- \frac{1}{2} \ln \vert \Sigma_i \vert + \ln P(\omega_i).
\end{displaymath}

\bigskip
\noindent
Hence, $g_i(\mbox{\bf x}) - g_j(\mbox{\bf x}) = 0$ leads us to 
a {\it hyper quadratic form}. Or, if you want,  we can express it as

\bigskip
\begin{displaymath}
(a_1 x_1 + a_2 x_2 + \cdots + a_n x_n)(b_1 x_1 + b_2 x_2 + \cdots + b_n x_n) = const.
\end{displaymath}

\bigskip
\noindent
Namely, the border is either of 
(i) Hyper-planes;
(ii) a pair of hyper-planes;
(iii) hyper-sphere;
(iv) hyper-ellipsoid;
(v) hyper paraboloid;
(vi) hyper-hyperboloid.




\clearpage
\section{Parameter Estimation}
Let's go back to one dimensional case, that is, p.d.f is defined on 1-D variable $x$. Now we assume p.d.f is not only Gaussian but also many others. Then the goal here is to know the form of $p(x \vert \omega_i)$ with its parameters included. We also assume that we know which of the p.d.f. among others for some reason to believe. What we don't know are the parameters of the density function.\\

\noindent
We now name a few of such p.d.f.s other than Gaussian p.d.f. all of which need to be specified by some parameters.\\

\begin{itemize}
\setlength{\itemsep}{0pt}
\item Discrete $x$
   \begin{itemize}
   \item Binomial
         \begin{itemize}
         \item $f(x) = (m!/x!(m-x)! \cdot \theta^x (1-\theta)^{m-x}$
         \end{itemize}
   \item Poisson
         \begin{itemize}
         \item $f(x) = (\theta^x/x!)\exp(- \theta)$
         \end{itemize}
   \end{itemize}
\item Continuous $x$
   \begin{itemize}
   \item Uniform 
         \begin{itemize}
         \item $p(x) = 1/\theta $ ... if $x>0$ otherwise 0
         \end{itemize}
   \item Exponential
         \begin{itemize}
         \item $f(x) = \theta \exp(-\theta x)$ ... if $x>0$ otherwise 0
         \end{itemize}
   \item Rayleigh
         \begin{itemize}
         \item $f(x) = 2\theta x \exp(-\theta x^2)$ ... if $x>0$ otherwise 0
         \end{itemize}
   \end{itemize}
\end{itemize}


\subsection{Overviews of each p.d.f.}
%%\footnote{This subsection is mostly from those paraphrased from Internet web site such as Wikipedia}
\noindent
First, for a function $f(x)$ to be a p.d.f. it should fulfill
\begin{itemize}
%%\setlength{\itemsep}{0pt}
\item[(1)] $f(x) \ge 0$ for $\forall x$
\item[(2)] $\int_{-\infty}^{\infty} f(x) dx = 1$ or $\sum f(x_i)=1$ for discrete variable $x$
\end{itemize}
Then the probability of $a \le x \le b $ is 
\begin{displaymath}
p(a \le x \le b) = \int_{a}^{b} f(x) dx
\end{displaymath}
for continuous $x$.

%%\subsubsection{Bernoulli}
%%\noindent

\subsubsection{Binomial}
Imagine an experiment that has only two possible outcomes. We now suppose a probability that a particular event will occur is  $p$, and as such a probability that the event will not occur $(1-p)$. An example of those two events are 'Success' or 'Failure.' The p.d.f. models the probability that we will observe $r$ successes and $n-r$ failures in a total of $n$-trials.


\begin{figure}[bhtp]
\begin{center}
\includegraphics[width=5cm,height=3cm]{binomial.eps}
\includegraphics[width=5cm,height=3cm]{poisson.eps}
\end{center}
\caption{Binomial p.d.f. (left) and Poisson p.d.f. (right).}
\end{figure}


\subsubsection{Poisson}
%%\noindent
%%Poisson distribution function is used to model experiments with high degrees of uncertainty.
\noindent
Poisson distribution expresses the probability of how often the events we concern will occur in a fixed interval of time or space if these events occur with a known average rate and independently of the time since the last event.\\ 

\noindent
This is the limit of the binomial distribution as the number of possible events approaches infinity while the probability of any specific event approaches zero, maintaining the correct average number of events in a specific interval. 


\subsubsection{Uniform}
When the distribution is uniform in the region $a \le x \le b$, the p.d.f. is $f(x) = 1/(b-a)$.  For example, any result of fair roulette should be uniformly distributed. 


\begin{figure}[bhtp]
 \begin{center}
\includegraphics[width=5cm,height=3cm]{uni.eps}
 \end{center}
 \caption{Yet another example where two distributions are closer than the first example. 
          Two threshold are shown, considering a risk of miss-classification.}
\end{figure}

\subsubsection{Exponential}
This models events that occur continuously and independently at a constant average rate. For example, it is used to model a behavior with a constant failure rate. In the above equation, $\theta$ is a constant failure rate per unit mesurement, e.g. per hour, while $x$ is time, e.g., hour. \\

\noindent
It might be easy to understand if you think of its cumulative distribution function $F(x) = 1-f(x)$. \footnote{Cumulative distribution function expresses the probability that a random variable X is less than x for any x. Hence, $p(X>x)=1-F(x)$ because $p(X \le x)$ and $p(X>x)$ are mutually exclusive, and as such, $p(X \le x)+p(X>x) =1$.}

\begin{figure}[bhtp]
 \begin{center}
\includegraphics[width=6cm,height=4cm]{exp.eps}
\includegraphics[width=6cm,height=4cm]{exp-cumulative.eps}
 \end{center}
 \caption{Exponential p.d.f. (left) and its cumulative distribution function (right).}
\end{figure}


\subsubsection{Rayleigh}
\noindent
One example where the Rayleigh distribution naturally arises is when wind speed is analyzed into its orthogonal 2-dimensional vector components. Assuming that the magnitude of each component is uncorrelated and normally distributed with equal variance, then the overall wind speed (vector magnitude) will be characterized by a Rayleigh distribution.

\begin{figure}[bhtp]
 \begin{center}
\includegraphics[width=8cm,height=5cm]{rayleigh.eps}
 \end{center}
 \caption{Rayleigh distribution function with four different values of $\theta$.}
\end{figure}


\subsection{Maximum Likelihood Estimation}
Before entering this topic, try the following case where we have two classes each of which has only 4 training samples.

\bigskip
\begin{example}
Assuming in a 2-dimensional space, what if we have a pair of 4 samples from each of two classes? The patterns we have are $(8,3), (4,3), (6,2), (6,4)$ from $\omega_1$ and $(0,3), (-2,1), (-4,3), (-2,5)$ from $\omega_2$. Try to guess the border between two classes, and then classify a new point $(5,3)$, for example.
\end{example}

\bigskip
\noindent
We now further more simplify the situation.\\

\bigskip
\begin{example}
Our data is now $x_1 = 3$, $x_2 = 8$, $x_3 = 2$ and $x_4 = 5$. Guess what distribution
function of these 4 data follows?
\end{example}

\begin{figure}[bhtp]
\begin{center}
\includegraphics[width=10cm,height=5cm]{gaussian.eps}
\end{center}
\caption{Assuming Gaussian which one is more likely?}
\end{figure}

\bigskip
\noindent
This might be a Gaussian distribution but just a brief look at it suggests
it more like a Rayleigh distribution.

\bigskip
%% 1, 2, 4, 7

%% rayleigh
%% 0.095, 0.164, 0.180, 0.060  when theta = 0.05
%% 0.181, 0.268, 0.162, 0.010  when theta = 0.10

%% \begin{figure}[bhtp]
%%  \begin{center}
%% \includegraphics[width=5cm,height=5cm]{rayleigh-2.eps}
%% \includegraphics[width=5cm,height=5cm]{rayleigh-3.eps}
%%  \end{center}
%%  \caption{A cloud of 200 points each with different three different1Gt $N[\mu, \Sigma]$.}
%% \end{figure}


\bigskip
\color{blue}
\begin{exercise}
(1) We now assume Gaussian with $\sigma = 1$ with $\mu$ being unknown. 
Then estimate $\mu$ from the same 4 data, i.e. 
$x_1 = 3$, $x_2 = 8$, $x_3 = 2$ and $x_4 = 5$, in the same way as above.
(2) Next, create 10, 20, 100 data randomly from $N(1, 3)$, 
and plot $p(D \vert \mu)$ as a function of $\mu$ in each of the three cases. 
\end{exercise}
\color{black}

\bigskip
\color{red}
\begin{formula}[An assumption of independence of data]
Choose $\theta$ which maximizes
\begin{equation}
P(D \vert \theta) = \prod_{k=1}^{n} P(x_k \vert \theta)
\end{equation}
\end{formula}
\color{black}



\noindent
Then let's calculate our previous example of one-dimensional four data 
$D = \{2, 3, 5, 8\}$ by changing $\theta$ from 0.00 to 1.00 with an interval
of 0.01. The results are shown the left-most graph of the Fig.~\ref{fig:ML}. 
It might be interesting what if we have more data to estimate. 
The same procedures are made with the number of data 10, 20, 100 and the results
are shown in the same Figure.\\

\noindent
All we don't know is its parameters to specify the function. But we have an information of prior probability  $p(\theta)$ and training sample give us $p(\theta \vert D)$ which we expect to have a sharp peak at the true $\theta$. \\

\noindent
Important thing is is
\begin{center}{\it ``The more data we have, the sharper the graph becomes.''}
\end{center}

\begin{figure}[bhtp]\label{fig:ML}
 \begin{center}
\includegraphics[width=3cm,height=3cm]{ml-rayleigh.eps}
\includegraphics[width=3cm,height=3cm]{ml-rayleigh-10.eps}
\includegraphics[width=3cm,height=3cm]{ml-rayleigh-20.eps}
\includegraphics[width=3cm,height=3cm]{ml-rayleigh-100.eps}
 \end{center}
 \caption{An example of estimation when the number of sumple is 4, 10, 20, 100}
\end{figure}



\clearpage
\section{Density function estimation -- Parzen Window Method}
\noindent
We have so far assumed that the distributions is known in advance (e.g. Gaussian, Rayleigh etc.), So all we have to estimate are the parameters. However, many scenarios in reality, the distributions is unknown. Then what we need is to estimate the distribution. This is sometimes called non-parametric estimation. We now explore one of such method known as Parzen Windows.\\

\noindent
Once we know the distribution with this method (or others), the parameters are again estimated by the maximal likelihood method, numerically this time.\\

\noindent
Here we study only distribution function defined on one-dimensional space.\\

\noindent
Given a data sample $x_1, x_2,...,x_n,$, we use each data, one by one, to estimate distribution function.\\

\noindent
Parzen-windowing essentially superposes kernel functions placed at each data (as a window). We now suppose we are estimating the value of the distribution function $p(x)$ at point $X$. Then we place a window function at $X$ and determine how many other points fall within the window. Thus, the value is the sum of the contributions from those points to this window. To be more specific


\begin{displaymath}
p(x) = \frac{1}{n}\sum_{i=1}^{n}\frac{1}{h}K(\frac{x-x_i}{h})
\end{displaymath}

\noindent
where $K(x)$ is the window function called kernel, and $h$ is the window width usually chosen based on the number of available data $n$. \\

\noindent
The Gaussian is a popular kernel for Parzen-window density estimation.\\

\begin{displaymath}
K(x) = (1/\sqrt{2\pi}\exp (-x^2/2)
\end{displaymath}

\begin{figure}[bhtp]
 \begin{center}
\includegraphics[width=5cm,height=4cm]{kernel-gaussian.eps}
\includegraphics[width=5cm,height=4cm]{kernel-gaussian-2.eps}
 \end{center}
 \caption{Gaussain kernel functions and its transposition.}
\end{figure}

\noindent
Then 
\begin{displaymath}
p(x) = \frac{1}{n}\sum_{i=1}^{n}\frac{1}{h\sqrt{2\pi}}\exp(-\frac{1}{2}(\frac{x-x_i}{h})^2)
\end{displaymath}

\begin{figure}[bhtp]
 \begin{center}
\includegraphics[width=5cm,height=4cm]{rayleigh-4p-1.eps}
\includegraphics[width=5cm,height=4cm]{rayleigh-4p-2.eps}
\includegraphics[width=5cm,height=4cm]{rayleigh-4p-3.eps}
\includegraphics[width=5cm,height=4cm]{rayleigh-4p-4.eps}
\includegraphics[width=5cm,height=4cm]{rayleigh-4p-5.eps}
 \end{center}
 \caption{An example of application of Rayleigh kernel to a date with 4 points.}
\end{figure}
 

\noindent
We now try to apply Gaussian kernel function to the following data set of 100 points.\\

\begin{figure}[bhtp]
 \begin{center}\includegraphics[width=14cm,height=0.9cm]{rayleigh-100p.eps}
 \end{center}
 \caption{Randomly created 100 one-dimensional points following the Rayleigh p.d.f.}
\end{figure}
 
\noindent
Numerical of these points from Rayleigh p.d.f. with $\theta$ being 3 are:

\begin{quote}
{\footnotesize
 0.28 3.12 3.82 3.23 0.70 0.20 2.71 2.63 2.18 1.15 0.35 3.49 0.11 0.10 2.68 0.80 0.59 2.41 2.94 2.34 1.98 2.72 3.58 0.38 1.54 2.67 2.07 0.62 3.62 1.85 2.96 2.32 3.59 1.94 1.04 3.26 0.51 2.74 3.94 2.20 0.74 0.19 2.02 4.00 2.95 0.75 0.53 2.66 0.20 2.57 0.27 3.76 1.09 0.94 0.53 2.76 0.06 2.94 0.53 4.04 4.03 1.75 2.88 2.24 3.81 3.59 3.12 0.11 2.59 3.44 1.18 0.09 0.90 0.72 0.33 3.09 4.04 1.31 0.18 2.17 3.31 1.48 1.78 3.43 0.78 0.71 1.30 2.99 1.96 3.38 1.73 0.71 1.78 1.92 0.92 1.59 2.32 0.91 4.01 2.26}
\end{quote}


\noindent
Also random point from Gaussian distribution with $\mu$ and $\sigma$ being .. and .. respectively.
\begin{quote}
{\footnotesize
 0.70 0.20 1.15 0.80 0.59 0.62 1.04 0.51 0.74 1.09 0.94 0.53 1.18 0.90 1.31 0.71 1.30 0.92 0.91 1.46 0.83 1.28 1.48 0.96 0.58 0.82 0.79 1.07 1.38 1.03 1.61 1.21 1.69 1.30 0.66 0.83 1.05 0.45 1.30 0.94 0.79 0.80 1.39 0.84 0.97 1.02 1.22 1.08 0.93 1.53 0.96 1.25 2.03 0.88 0.07 1.05 1.40 1.28 1.27 0.02 1.05 0.99 0.91 0.97 0.39 1.15 1.09 0.54 0.84 1.25 1.26 0.94 0.86 0.89 1.43 0.73 1.79 0.90 0.81 1.39 1.01 0.62 1.29 0.78 1.40 1.17 1.34 1.28 0.64 0.57 0.69 1.33 1.19 0.99 0.87 1.08 0.75 0.60 0.23 1.49}
\end{quote}


\begin{figure}[bhtp]
 \begin{center}
\includegraphics[width=5cm,height=4cm]{rayleigh-100p-1.eps}
\includegraphics[width=5cm,height=4cm]{rayleigh-100p-2.eps}
\includegraphics[width=5cm,height=4cm]{rayleigh-100p-3.eps}
 \end{center}
 \caption{An example of application of Gaussian kernel to a date with 100 points.}
\end{figure}

\noindent
Or, more simply, we may use uniform distribution $K(x) = 1/2$ for $\vert x \vert \le h$ otherwise $K(x)=0$, which results in histogram as a resultant probability distribution function. 

\bigskip
\color{blue}
\begin{exercise}
(1) Assume we have only 4 sample data $x_1 = 3$, $x_2 = 8$, $x_3 = 2$ and $x_4 = 5$, apply Parzen method with its kerner being uniform p.d.f.
(2) Then try with Gaussian p.d.f.
\end{exercise}
\color{black}

\begin{figure}[bhtp]
\begin{center}
\includegraphics[width=5cm,height=5cm]{parzen-uni-1.eps}
\includegraphics[width=5cm,height=5cm]{parzen-uni-2.eps}
\includegraphics[width=5cm,height=5cm]{parzen-uni-3.eps}
\end{center}
\caption{With kernel being a uniform p.d.f.}
\end{figure}


\bigskip
\color{blue}
\begin{exercise}
Create 100 points distributed Rayleigh p.d.f., and then apply Parzen with Gaussian p.d.f. 
\end{exercise}
\color{black}



\subsection{Kernel functions}
A kernel function is a non-negative, real-valued, and integrable function satisfying the 

\begin{itemize}
\setlength{\itemsep}{0pt}
\item $\int_{-\infty}^{\infty} K(x) dx = 1$.
\item $K(-x)=K(x)$ for $\forall x.$
\end{itemize}

\subsubsection{Other kernel function commonly used}
The following seven functions are all defined in the region $\vert x \vert \le 1$.
\begin{itemize}
\setlength{\itemsep}{0pt}
\item Triangular
   \begin{itemize}
   \item $K(x) = 1 - \vert x \vert$ 
   \end{itemize}
\item Epanechnikov
   \begin{itemize}
   \item $K(x) = (3/4)(1-x^2)$ 
   \end{itemize}
\item Biweight (or Quartic)
   \begin{itemize}
   \item $K(x) = (15/16)(1-x^2)^2$ 
   \end{itemize}
\item Triweight
   \begin{itemize}
   \item $K(x) = (35/32)(1-x^2)^3$ 
   \end{itemize}
\item Tricube
   \begin{itemize}
   \item $K(x) = (70/81)(1- \vert x \vert^3)^3$ 
   \end{itemize}
\item Cosine
   \begin{itemize}
   \item $K(x) = (\pi/4)\cos (\pi x /2)$ 
   \end{itemize}
\end{itemize}

\begin{figure}[bhtp]
\begin{center}
\includegraphics[width=4cm,height=4cm]{kernel-triangle.eps}
\includegraphics[width=4cm,height=4cm]{kernel-epnechnikov.eps}
\includegraphics[width=4cm,height=4cm]{kernel-biweight.eps}
\includegraphics[width=4cm,height=4cm]{kernel-triweight.eps}
\includegraphics[width=4cm,height=4cm]{kernel-tricube.eps}
\includegraphics[width=4cm,height=4cm]{kernel-cosine.eps}
\end{center}
\caption{Six different kernel functions.}
\end{figure}


\subsubsection{Why are we happy with this?}
Thus we can know the function form $p(x \vert \omega_i)$ for each family $\omega_i$, and we can use our formula \label{rule-2}.\\

\bigskip
\noindent
\color{red}
{\bf Rule (Classification with posterior probability)}
If $P(x \vert \omega_1) > P(x \vert \omega_2)$
then classify it to $\omega_1$ otherwise $\omega_2$. \\
\color{black}

\bigskip
\noindent
Thus far, we are again happy to be able to perform Bayesian classification as described earlier.



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\begin{center}
{\Huge {\bf PART II}} \\ 
\bigskip 
{\Large {\bf BAYESIAN NETWORK}}
\end{center}

\vspace{.6in}

\begin{itemize}
\item[1.] What is Bayesian Network? 
\item[2.] Inferring from Bayesian Network.
\item[3.] Learning of Bayesian Network.
\end{itemize}




\clearpage
\section{Bayesian Network}
\noindent
So far our conditional probabilities are sometimes probability distribution function, such as $p(x|\omega)$, not a numerical value of probability. From now on, all the notations will be numerical value of the probability of some event. E.g. $p(A|B)$ means the probability of A under the condition of B, or equivalently, the probability of A given B. Specifically we call them ($A$ and $B$ here) {\it variables}.\\

\noindent
Then Bayesian network is a graph which represent dependence of these variables. Nodes represent these variables, and arcs represent the probability of these dependencies. That is, the arc from node $A$ to $B$ is $p(B|A)$. \\

\noindent
The objective of the Bayesian network is to infer a probability of some variable whose probability is unknown from the information of a set of value of the other variables. The former variable is called {\it hypothesis} and the latter are called {\it evidences}. Hence we may say this objective is to:

\begin{quote}
infer the probability of hypotheses from evidences given.
\end{quote}

\noindent
So our most frequent notation of a probability will be described $p(h|e)$. Sometimes this probability is called {\it belief} and also described as

\begin{displaymath}
Bel(h|e).
\end{displaymath}

\noindent
To simply put, this is,  "how much is our belief for the hypothesis given those evidences."


%% \bigskip
%% \begin{definition}[Conditional probability]
%% $p(X|Y) = p(X \cap Y)/p(Y)$, or equivalently, $p(X|Y)=p(X,Y)/p(Y)$
%% \end{definition}

%% \noindent
%% By repeating the above the following holds

%% \begin{definition}[Independence]
%% $X$ and $Y$ is independent when $p(X|Y)=p(X)$.
%% \end{definition}

%% \begin{definition}[Independence]
%% $X$ and $Y$ being independent given $Z$ when $p(X|Y,Z)=p(X|Y)$. 
%% \end{definition}

%% \lnot

%% \bigskip
%% \color{red}
%% \begin{formula}[Chain Rule]
%% $p(Z|X)=p(Z|Y)p(Y|X)+p(Z|\lnot Y)p(\lnot Y|X)$
%% \end{formula}
%% \color{black}

%% \noindent
%% And more generally

%% \color{red}
%% \begin{formula}[Chain Rule]
%% $p(Z|X)=\sum_{Y=y} p(Z|Y)p(Y|X)$
%% \end{formula}
%% \color{black}

%% \noindent
%% In the context of Bayesian theorem

%% \begin{displaymath}
%% p(h|e)={p(e|h)p(h)}/{p(e)}
%% \end{displaymath}

%% \noindent
%% We call $h$ {\it hypothesis} and $e$ {\it evidence}. And we denote

%% \begin{displaymath}
%% Belief(h)=p(h|e)
%% \end{displaymath}

%% Definition 1.5 Jeffrey conditionalization


%% \section{Bayesian Network}
%% \noindent
%% To simply put, Bayesian Network is a tool for us to infer the probability of {\it hypothesis} from a set of known {\it evidence}. 

%% A random variable denotes an attribute, feature, or hypothesis about which we may be uncertain. Each random variable has a set of mutually exclusive and collectively exhaustive possible values. That is, exactly one of the possible values is or will be the actual value, and we are uncertain about which one it is. 

\subsection{Examples}
\subsubsection{Flu \& Temperature}
This example is taken from Korb et al.\footnote{
K. B. Korb and A. E. Nicholson (2003) "Bayesian Artificial Intelligence."}\\

\noindent
Flu causes a high temperature by and large. We now suppose the probability that we are flu is $p(\mbox{\small Flu})=0.05$, the probability that we have High-temperature when we are flu is $p(\mbox{\small High-temperature} | \mbox{\small Flu})=0.9$ and the probability of we still have a high temperature even when we are not flu (false alarm) is $p(\mbox{\small High-temperature} | \lnot \mbox{\small Flu})=0.2$. See Figure \ref{fig:FLU}.

\bigskip
\color{blue}
\begin{exercise}
Now we assume to have an evidence that one guy has a high-temperature, then how much is a belief of this guy is Flu?
\end{exercise}
\color{black}

\noindent
Or conversely,

\bigskip
\color{blue}
\begin{exercise}
We have an evidence that one guy is flu then how much is a belief of this guy has a high-temperature?
\end{exercise}
\color{black}

\begin{figure}[bhtp]
\begin{center}
\includegraphics[width=8cm,height=4cm]{flu.eps}
\end{center}
\caption{Flu causes high-temperature. Redrawn from Korb et al. (Sorry but without permission.)}
\label{fig:FLU}
\end{figure}


\subsubsection{Season \& Rain}
In the example of the previous subsection, all the variables take a binary value. Sometimes we want variables which takes more cases. Here we have such an example. Again a simple example of two variables but one is about season which takes 4 values: \{winter, spring, summer and autumn\}, and weather which takes also 4 values: \{fine, cloudy, rain, and snow\} See Figure \ref{fig:SEASON}.

\begin{figure}[bhtp]
\begin{center}
\includegraphics[width=10cm,height=6cm]{season.eps}
\end{center}
\caption{Season \& Weather}
\label{fig:SEASON}
\end{figure}

\noindent
Now try the following two inferences. The first one is very direct.

\bigskip
\color{blue}
\begin{exercise}
Assume it's now Summer (evidence), then how much is the probability that it's rain?
\end{exercise}
\color{black}

\noindent
The next one is not such straight forward but still quite easy.

\bigskip
\color{blue}
\begin{exercise}
Now it's snow, then how much is the probability of being autumn now?
\end{exercise}
\color{black}




\subsubsection{Flu, Temperature \& Thermometer}
Now we move on to a case of three variables. First one is simple enough like $A \rightarrow B \rightarrow C$. Let's call $A$ "parent of $B$," and $C$ "child of $B$." This example is again taken from Korb et al.\\

\noindent
Relation of Flu \& High Temperature is the same as before. Now we have a thermometer whose rate of false negative reading is 5\% and false positive reading is 14 \%, that is,

\begin{center}
$p(\mbox{\small HighTherm} = True | \mbox{\small HighTemp} = True) = 0.95$\\
$p(\mbox{\small HighTherm} = True | \mbox{\small HighTemp} = False) = 0.15$\\
\end{center}

\begin{figure}[bhtp]
 \begin{center}
\includegraphics[width=10cm,height=6cm]{thermo.eps}
 \end{center}
 \caption{Flu $\rightarrow$ HighTemp $\rightarrow$ ThermoHigh. Redrawn from Korb et al. (Sorry but without permission.)}
\end{figure}

\bigskip
\color{blue}
\begin{exercise}
Evidence now is, he is Flu and Thermometer suggests HighTemp, then how much is the probability of hypothesis that he has a High temperature?
\end{exercise}
\color{black}

\noindent
Or, lack of one evidence
\bigskip
\color{blue}
\begin{exercise}
Now thermometer suggests HighTmp, then how much is the probability of his being Flu?
\end{exercise}
\color{black}





\subsubsection{Grass are soaked then it's rain or sprinkler}
Now we proceed a more complicated case in which dependency is not linear. This example is taken from Wikipedia.\footnote{at $http://en.wikipedia.org/wiki/Bayesian\_network$}

\noindent
The situation is described in the page as:
\begin{quote}
{\it Suppose that there are two events which could cause grass to be wet: either the sprinkler is on or it's raining. Also, suppose that the rain has a direct effect on the use of the sprinkler (namely that when it rains, the sprinkler is usually not turned on). All three variables have two possible values, T for true and F for false.}
\end{quote}

\begin{figure}[bhtp]
 \begin{center}
\includegraphics[width=12cm,height=6cm]{sprinkler.eps}
 \end{center}
 \caption{Grass are soaked because it's rain and{/}or sprinkler?}
\end{figure}

\noindent
Let's calculate the joint probability function. First, recall that the joint probability of $A$ and $B$, in general, can be expressed as:\\

\bigskip
\color{red}
\begin{formula}[Joint probability]
$p(A,B)=p(A|B)p(B)$.
\end{formula}
\color{black}




\noindent
We can extend this formula as:\\

\bigskip
\color{red}
\begin{formula}[Extended joint probability]
$p(A,B,C)=p(A|B,C)p(B,C)=p(A|B,C)p(B|C)p(C)$
\end{formula}
\color{black}

\noindent
We now regard $A=G$, and $B=(S,R)$. Then,


\begin{displaymath}
P(G,S,R) = P(G|S,R)P(S|R)P(R)
\end{displaymath}

\noindent
Notice here $G$ means $G=True$ unless otherwise mentioned.
Also $S$ means $S=True$ and $R$ means $R=True$.\\

\noindent
Let us now denote probability of $G=True$, $S=False$ and $R=True$, for example, as $p(G,S,R)_{TFT}$.\\

\noindent
Then we can assume

\begin{displaymath}
P(S,R) = p(G,S,R)_{TFT}+p(G,S,R)_{TTT}
\end{displaymath}
because $G$ is either $True$ or $False$. And similarly, 
\begin{displaymath}
P(R) = p(G,S,R)_{TFT}+p(G,S,R)_{TTT}+p(G,S,R)_{TFT}+p(G,S,R)_{TTT}.
\end{displaymath}

\noindent
For example, 
\begin{displaymath}
p(G,S,R)_{TFT}=0.80 \times 0.99  \times 0.20 = 0.1584.
\end{displaymath}

\noindent
Also recall the basic formula

\color{red}
\begin{displaymath}
p(X|Y) = \frac{p(X,Y)}{p(Y)}.
\end{displaymath}
\color{black}

\noindent
And

\color{red}
\begin{displaymath}
p(X,Y)=\sum_{Z}p(X|Z,Y)p(Z|Y)
\end{displaymath}
\color{black}

\noindent
Thus, the probability of it's rain under the observation of the grasses are wet is:

\begin{eqnarray}
 p(R|G) &=&  \frac{p(G,R)}{p(G)}                                                \nonumber \\
        &=&  \frac{p(G,S,R)_{TFT}+p(G,S,R)_{TTT}}
                  {p(G,S,R)_{TFF}+p(G,S,R)_{TFT}+p(G,S,R)_{TTF}+p(G,S,R)_{TTT}} \nonumber \\
        &=&  \frac{0.1584+0.00198}
                  {0+0.1584+0.288+0.00198}                                      \nonumber \\ 
     &\sim& 0.3577.
\end{eqnarray}

\bigskip
\color{blue}
\begin{exercise}
What is the probability that sprinkler is working, given the grass is wet?
\end{exercise}
\color{black}

\bigskip
\color{blue}
\begin{exercise}
If, on the other hand, we wish to answer an interventional question: "What is the likelihood that it would rain, given that we wet the grass?" 
\end{exercise}
\color{black}

\subsubsection{My family now goes out?}
This example is taken from Charniak.\footnote{
E.~Charniak (1991) "Bayesian Networks without Tears." AI MAGAZINE Vol. 12 No. 4, pp. 50-63.}
\begin{quote}
{\it Suppose when I go home at night, I want to know if my family is home before I try the doors. (Perhaps the most convenient door to enter is double locked when nobody is home.) Now, often when my wife leaves the house, she turns on an outdoor light. However, she sometimes turns on this light if she is expecting a guest. Also, we have a dog. When nobody is home, the dog is put in the back yard. The same is true if the dog has bowel troubles. Finally, if the dog is in the backyard, I will probably hear her barking (or what I think is her barking), but sometimes I can be confused by other dogs barking.}
\end{quote}


\bigskip
\color{blue}
\begin{exercise}
Try to draw the Bayesian network.
\end{exercise}
\color{black}

%% \begin{figure}[bhtp]
%% \begin{center}
%% \includegraphics[width=8cm,height=5cm]{dog.eps}
%% \end{center}
%% \caption{.}
%% \end{figure}


%% \subsubsection{credit card fraud} 
%% This example is taken from Heckerman (1995)\footnote{
%% David Heckerman (1995) "A Tutorial on Learning With Bayesian Networks."
%% Technical Report: MSR-TR-95-06. Microsoft Research Advanced Technology. Division Microsoft Corporation.} 
%% p(f=yes) = 0.00001
%% p(a=<30) = 0.25
%% p(a=30-50) = 0.40
%% p(s=male) = 0.5
%% p(g=yes|f=yes) = 0.2
%% p(g=yes|f=no) = 0.01
%% p(j=yes|f=yes,a=*,s=*) = 0.05
%% p(j=yes|f=no,a=<30,s=male) = 0..0001
%% p(j=yes|f=no,a=30-50,s=male) = 0.0004
%% p(j=yes|f=no,a=>50,s=male) = 0.0002
%% p(j=yes|f=no,a=<30,s=female) = 0..0005%% p(j=yes|f=no,a=30-50,s=female) = 0.002
%% p(j=yes|f=no,a=>50,s=female) = 0.001

%% see also section 12



\subsubsection{Pearl's earthquake Bayesian Network} 
This is a very popular example to show how Bayesian network looks like by Pearl.\footnote{Pearl, J. (1988) "Probabilistic Reasoning in Intelligent Systems: Networks of Plausible Inference." San Mateo, Morgan Kaufmann.}

\begin{quote}
{\it You have a new burglar alarm installed. It reliably detects burglary, but also responds to minor earthquakes. Two neighbors, John and Mary, promise to call the police when they hear the alarm. John always calls when he hears the alarm, but sometimes confuses the alarm with the phone ringing and calls then also. On the other hand, Mary likes loud music and sometimes doesn't hear the alarm. Given evidence about who has and hasn't called, you'd like to estimate the probability of a burglary.}
\end{quote}

\begin{figure}[bhtp]
\begin{center}
\includegraphics[width=12cm,height=6cm]{earthquake.eps}
\end{center}
\caption{Pearl's Earthquake}
\end{figure}


%% \begin{table}[h]
%% \begin{center}
%% \caption{All possible cases}
%% \hspace*{1in}\\
%% \begin{tabular}{c c c c c c c c} \hline \hline
%% %\begin{small}
%% FFFFFF & FFFFFT & FFFFTF & FFFFTT & FFFTFF & FFFTFT & FFFTTF & FFFTTT \\
%% 0.9960 & 0.0001 & 0.0001 & 0.0001 & 0.0001 & 0.0002 & 0.0002 & 0.0001 \\ \hline
%% FFTFFF & FFTFFT & FFTFTF & FFTFTT & FFTTFF & FFTTFT & FFTTTF & FFTTTT \\
%% 0.0002 & 0.0002 & 0.0002 & 0.0002 & 0.0002 & 0.0004 & 0.0004 & 0.0002 \\ \hline
%% FTTFFF & FTTFFT & FTTFTF & FTTFTT & FTTTFF & FTTTFT & FTTTTF & FTTTTT \\
%% 0.9960 & 0.0001 & 0.0001 & 0.0001 & 0.0001 & 0.0001 & 0.0001 & 0.0001 \\ \hline
%% TFFFFF & TFFFFT & TFFFTF & TFFFTT & TFFTFF & TFFTFT & TFFTTF & TFFTTT \\
%% 0.0000 & 0.0001 & 0.0001 & 0.0001 & 0.0000 & 0.00025 & 0.00025 & 0.0001 \\ \hline
%% TFTFFF & TFTFFT & TFTFTF & TFTFTT & TFTTFF & TFTTFT & TFTTTF & TFTTTT \\
%% 0.0000 & 0.00015 & 0.00015 & 0.0001 & 0.0000 & 0.00025 & 0.0001 & 0.0001 \\ \hline
%% TTTFFF & TTTFFT & TTTFTF & TTTFTT & TTTTFF & TTTTFT & TTTTTF & TTTTTT \\
%% 0.9960 & 0.0001 & 0.0001 & 0.0001 & 0.0001 & 0.0001 & 0.0001 & 0.0001 \\ \hline
%% \end{small}
%% \end{tabular} 
%% \end{center}
%% \end{table}


%% p(B)=0.01
%% p(E)=0.02

%% B E p(A|B,E)
%% y y  0.95
%% y n  0.94
%% n y  0.29
%% n n 0.001



%% A p(J|A)
%% y 0.9
%% n 0.05


%% A p(M|A)
%% y   0.7
%% n   0.01


%% p(B,M)=\sum_{EAJ}p(BEAJM)

%% BM
%% yy  0.000115
%% yn  0.000075
%% ny  0.00015
%% nn  0.99971


%% p(B|M)=p(B,M)/p(M)=0.000115/(0.000115)+0.00075)

%% \begin{figure}[bhtp]
%% \begin{center}
%% \includegraphics[width=8cm,height=5cm]{earthquake-2.eps}
%% \end{center}
%% \caption{}
%% \end{figure}

\clearpage
\section{Inference}
Inference task is collecting evidence and updating belief.\\

\subsection{Flu $\rightarrow$ HighTemp $\rightarrow$ HighThermo revisit}
\noindent
We now take a look at it by revisiting the simplest example we saw in the previous section.\\
\begin{figure}[bhtp]
\begin{center}
\includegraphics[width=8cm,height=4cm]{simplest-three.eps}
\end{center}
\caption{A simple Bayesian Network A $\rightarrow$ X $\rightarrow$ D} 
\end{figure}

\noindent
Assume now we want to know the probability of hypothesis HighTemp with the evidence HighThermo.
Let us now denote it as $A \rightarrow X \rightarrow D$. Then we can calculate it as
 $p(X|D) \propto p(D|X)p(X)$. We will notice that $p(X)$ is not explicitly known. But its implication is given by $p(X|A)p(A)$. So, we can conclude that
\begin{displaymath}
p(x|A,D)=p(D|X)p(X|A)p(A).
\end{displaymath}


\subsection{With a little more extension}
\noindent
We now take an example where target variable $X$ has three parent variables.



\begin{figure}[bhtp]
\begin{center}
\includegraphics[width=6cm,height=3cm]{from-parents-2.eps}
\includegraphics[width=6cm,height=3cm]{to-children-2.eps}
\end{center}
\caption{The variable of our concern $X$ has three parent variables $A$, $B$, and $C$ as well as three child variables $F$, $G$ and $H$.}
\end{figure}

\begin{eqnarray}
p(x| \mbox{\bf e}^P) &=&  p(x| e_A, e_B, e_C)                                                 \nonumber\\
&=& \sum_{\mbox{\tiny all possible } i,j,k} p(x| a_i, b_j, c_k) p(a_i, b_j, c_k|e_A, e_B, e_C)\nonumber\\
&=& \sum_{\mbox{\tiny all possible } i,j,k} p(x| a_i, b_j, c_k) p(a_i|e_A)p(b_j|e_B)p(c_k|e_C)\nonumber
\end{eqnarray}



\begin{displaymath}
p(\mbox{\bf e}^C|x) =  p(e_A, e_B, e_C | x) =  p(e_A|x)p(e_B|x)p(e_C|x)
\end{displaymath}

\bigskip
\noindent
So, by combining the above two, we obtain 
\begin{eqnarray}
& & p(x|e_A, e_B, e_C, e_F, e_G, e_H)                           \nonumber \\
&=& p(x| \mbox{\bf e}^P) p(\mbox{\bf e}^C|x)                    \nonumber \\
&=& p(e_A|x)p(e_B|x)p(e_C|x) \cdot
\sum_{i,j,k} p(x| a_i, b_j, c_k) p(a_i|e_A)p(b_j|e_B)p(c_k|e_C) \nonumber
\end{eqnarray}

\bigskip
\noindent
Here we must notice that we used the following formula:
\color{red}
\begin{displaymath}
p(X|Y)=\sum_{Z}p(X|Z,Y)p(Z|Y)
\end{displaymath}
\color{black}


\subsection{Salmon or Sea-bass?}
The example of this subsection including three exercises is totally taken, with minor modifications, from Duda et al.~\footnote{R. O. Duda, P. E. Hart and D. G. Stork (2000) "Pattern Classification." 2nd Edition, John Wiley \& Sons.}\\

\noindent
Try to think of the following Bayesian network shown in Figure \ref{fig:FISH}\\

\begin{figure}[h]
\begin{center}
\includegraphics[width=12cm,height=6cm]{fish.eps}
\end{center}
\caption{A Bayesian network as to classify the fish caught to Salmon or Sea-bass.}
\label{fig:FISH}
\end{figure}

\noindent
First of all, let's apply the formula described in the previous subsection. Assume now hypothesis is a value of $X$, and evidence is one of the values of each variable $A$, $B$, $C$ and $D$.\\

\noindent
So, $p(x|\mbox{\small four evidences})$ is
\begin{displaymath}
p(x| \mbox{\bf e}^P) p(\mbox{\bf e}^C|x)
\end{displaymath}
where parent evidences $\mbox{\bf e}^P$ are now $e_A$ and $e_B$, while child evidences $\mbox{\bf e}^C$ are $e_C$ and $e_D$.\\

\noindent
While $p(\mbox{\bf e}^C|x)$ will be simply calculated as
\begin{displaymath}
p(\mbox{\bf e}^C|x) =  p(e_A, e_B| x) =  p(e_A|x)p(e_B|x), 
\end{displaymath}

\noindent
calculation of $p(x| \mbox{\bf e}^P)$ will not be so simple, but any way: 


\begin{eqnarray}
p(x| \mbox{\bf e}^P) &=&  p(x| e_A, e_B)                                      \nonumber\\
&=& \sum_{\mbox{\tiny all possible } i,j} p(x| a_i, b_j) p(a_i, b_j|e_A, e_B) \nonumber\\
&=& \sum_{\mbox{\tiny all possible } i,j} p(x| a_i, b_j) p(a_i|e_A)p(b_j|e_B))\nonumber\\
&=& p(x|a_1,b_1)p(a_1|e_A)p(b_1|e_B)       \nonumber\\
&  +& p(x|a_1,b_2)p(a_1|e_A)p(b_2|e_B) \nonumber\\
&  +& p(x|a_2,b_1)p(a_2|e_A)p(b_1|e_B) \nonumber\\
&  +& p(x|a_2,b_2)p(a_2|e_A)p(b_2|e_B) \nonumber\\
&  +& p(x|a_3,b_1)p(a_3|e_A)p(b_1|e_B) \nonumber\\
&  +& p(x|a_3,b_2)p(a_3|e_A)p(b_2|e_B) \nonumber\\
&  +& p(x|a_4,b_1)p(a_4|e_A)p(b_1|e_B) \nonumber\\ 
&  +& p(x|a_4,b_2)p(a_4|e_A)p(b_2|e_B) \nonumber
\end{eqnarray}

\bigskip
\noindent
Now the arc of the network, that is, the conditional probability of each of the arcs are given in 
Figure\ref{fig:PROB}.\\


\begin{figure}[h]
\begin{center}
%% \includegraphics[width=6cm,height=3cm]{salmon-bass.eps}\\
%% \includegraphics[width=6cm,height=3cm]{salmon-bass.eps}\\
\includegraphics[width=5.1cm,height=2cm]{primer.eps}
\\ \hspace{.1in} \\
\includegraphics[width=14cm,height=3.3cm]{cpt.eps}
\end{center}
\caption{Given primer and conditional probabilities of Salmon and Sea-bass.}
\label{fig:PROB}
\end{figure}

\noindent
We now assume that the evidences we have is, $e_A$ is Winter, $e_B$ = South Pacific, $e_C$ = light, and $e_D$ = thin. Then assume our concern is, how much is the probability of hypothesis that fish is salmon under these evidences?\\ 

\noindent
Our scenario is as follows: it's Winter now, so $p(a_1|e_A) = 1$ and $p(a_i|e_A)=0$ for $i=2,3,4$. Suppose we don't know from which sea the boat came from, but the chief of the fishing crew prefers to fish in South Pacific Ocean, so assume $p(b_1|e_B)=0.2$ and $p(b_2|e_B)=0.8$.\\

\noindent
Further, the fish is fairly light, so $p(e_C|c_1)=1$, $p(e_C|c_2)=0.5$ and $p(e_C|c_3)=0$. For some reason we cannot measure the thickness of the fish, so assume $p(e_D|d_1)=p(e_D|d_2)=0.5$.\\

\noindent
\color{blue}
Then try to calculate the probability of hypothesis that fish is salmon under these evidences.\\ 
\color{black}

\noindent
We can change the scenario as those in the following three exercise.

\color{blue}
\begin{exercise}
Suppose it's November 10 -- the end of autumn and the beginning of winter -- and thus let $p(a_1)=p(a4)=0.5$. Furthermore it is know that the fish was caught in North Atlantic, that is $p(b_1)=1$. Suppose the color of the fish was not measured, but it is known that fish is thin, that is, $p(d_2)=1$. Classify the fish as salmon or sea-bass. What is the expected error rate of the estimate?
\end{exercise}
\color{black}

\color{blue}
\begin{exercise}
Suppose all we know about fish is thin and medium light color. What season is now most likely? And what is the probability it's being correct?  
\end{exercise}
\color{black}

\color{blue}
\begin{exercise}
Suppose the fish is thin and medium lightness and that it was caught in North Atlantic. Then the same question as above, what season is now most likely? And what is the probability it's being correct? 
\end{exercise}
\color{black}


\clearpage
\section{Algorithms for inference}
This section is paraphrased all from the section 3.3 in Korb et al.\footnote{
K. B. Korb and A. E. Nicholson (2003) "Bayesian Artificial Intelligence."}
\subsection{Exact inference}
\subsubsection{Kim and Pearl's message passing algorithm}
Assume $X$ is the query node, and there is some set of evidence nodes $E$ (not including $X$). The task is to update $Bel(X|E)$ by computing $p(X|E)$.\\

\noindent
A node $X$ is with all its connections to parents (the $U_i$), children (the $Y_j$), and the children's other parents (the $Z_{ij}$). The local belief updating for $X$ must incorporate evidence from all other parts of the network.\\

\begin{figure}[bhtp]
\begin{center}
\includegraphics[width=12cm,height=6cm]{more-general.eps}
\end{center}
\caption{Extended Pearl's Earthquake}
\end{figure}


\noindent
Evidence can be divided into:
\begin{itemize}
\setlength{\itemsep}{0pt}
\item The predictive support for X, from evidence nodes connected to X through its parents, $U_1, ..., U_m$.
\item The diagnostic support for X, from evidence nodes connected to X through its children $Y_1, ..., Y_n$.
\end{itemize}


\noindent
We use two types of messages $\pi$ and $lambda$. The messages $\pi$ are sent in the direction of the arc, from parent to child, hence we can notate 
\begin{displaymath}
\pi_{\mbox{\tiny receiver}} (\mbox{\small sender}), 
\end{displaymath}
while the messages $\pi$ are sent against the direction of the arc, from child to parent, hence we can notate 
\begin{displaymath}
\lambda_{\mbox{\tiny sender}} (\mbox{\small receiver}).\\
\end{displaymath}

\begin{figure}[h]
\begin{center}
\includegraphics[width=4cm,height=2cm]{message-passing.eps}\\
\end{center}
\caption{Notation of two messages $\lambda$ and $\pi$ between two nodes.}
\end{figure}

\noindent
Note that $\pi$ is from {\it prior} and $\lambda$ is from {\it likelihood} in Bayes' theorem.\\

\bigskip
\noindent
{\bf [ALGORITHM]}\\

\noindent
{\bf 0. Initialization}\\
(1) Set all $\lambda$ values $\lambda (x_i)$ to 1.\\
(2) Set all $\lambda$ messages $\lambda_{X} (U_i)$ and $\lambda_{Y_j} (X)$ to 1.
(3) Set all $\pi$     messages $\pi_{X} (U_i)$ and $\pi_{Y_j} (X)$ to 1.

\noindent
{\bf 1. Bottom-up propagation}\\
Node $X$ computes new $\lambda$ messages to send to its parents
\begin{displaymath}
\pi(x_i) = \sum_{u_1, ..., u_n} p(x_i|u_1, ..., u_n)\prod_{i}\pi_{X}(u_i)
\end{displaymath}

\noindent
{\bf 2. Top-down propagation}\\
Node $X$ computes new $\pi$ messages to send to its children.
\begin{displaymath}
\pi_{Y_j}(x_i) = \alpha \prod_{k \neq j} \lambda_{Y_k}(x_i) \sum_{u_1, ..., u_n} p(x_i|u_1, ..., u_n)\prod_{i}\pi_{X}(u_i)
\end{displaymath}

\noindent
{\bf 3. Belief updating}\\
At each iteration of the algorithm, $Bel(X)$ is updated as:

\begin{displaymath}
Bel(x_i) = \alpha \lambda(x_i) \pi(x_i)
\end{displaymath}

\noindent
where

\begin{displaymath}
\lambda (x_i) = \prod_{j} \lambda_{Y_j}(X)
\end{displaymath}

\noindent
and

\begin{displaymath}
\pi (x_i) = \sum_{u_1,... u_n} p(x_i|u_1,...,u_n) \prod_{i} \pi_{X}(U_i).
\end{displaymath}

\noindent
Note that $\alpha$ is a normalizing constant so that $\sum_{x_i} Bel (X=x_i)=1$.\\

\noindent
Note also that $ p(X|U_1, ..., U_n)$ is given as the conditional probability table in the original Bayesian network.\\ 




\bigskip
\noindent
{\bf An example -- Extended Pearl's Earthquake}\\

\begin{figure}[bhtp]
\begin{center}
\includegraphics[width=12cm,height=6cm]{earthquake-2.eps}
\end{center}
\caption{Extended Pearl's Earthquake}
\end{figure}

\subsection{Approximate inference}
\subsubsection{Logic Sampling}
Repeatedly a case is generated by selecting values for each node at random. In each cycle, the nodes are traversed from the roots down to the leaves. Selecting values is by following either the prior or the conditional probability table already given. When all the nodes have been visited, we have a case, or equivalently, an instantiation of all the nodes in the Bayesian network. \\

\noindent
To estimate $p(X|E)$ with a sample value $'(X|E)$, we compute the ratio of cases where both $X$ and $E$ are true to the number of cases where just $E$ is true.


\subsubsection{Likelihood Weighting}
This is a modified version of Logic Sampling described above. Modification is to avoid unlikely evidences. That is, if a node is the one evidence is specified choose the evidence, otherwise one of the values will be selected following the prior, if it's a root, or conditional probability table.





\clearpage
\section{Bayesian network for decision making}


\subsection{Utility}
When  we make a decision of an action, we might consider our preferences among different possible outcomes of those available actions. In the Bayesian decision theory this preference is called {\it utility}, or we may rephrase it as "usefulness," "desirability," or simply "value" of the outcome. \\

\noindent
Introducing this concept of utility allows us to calculate which action is expected to result in the most valuable utility given any available evidence $E$.\\

\noindent
We now define {\it expected utility} as:

\color{red}
\begin{displaymath}
eu(A|E) = p(O_i|E, A)u(O_i|A),
\end{displaymath}
\color{black}

\noindent
where $A$ is an action with possible outcome $O_i$. E is the available evidence. $U(O_i)|A$ is the utility of each of the outcome under the action $A$. $p(O_i|E,A)$ is the conditional probability distribution over the outcome $O_i$ under the action $A$ with the evidence $E$.
$E$ is the available evidence.

\subsubsection{Three different nodes to express network}

\begin{itemize}
\setlength{\itemsep}{0pt}
\item Chance nodes
\item Decision nodes:
   \begin{itemize}
   \item The decision being made at a particular point in time. The values of a decision node are the actions
   \end{itemize}
\item Utility nodes:
   \begin{itemize}
   \item Each utility node has an associated utility table with one entry for each possible instantiation of its parents, perhaps including an When there are multiple utility nodes, the overall utility is the sum of the individual utilities.
   \end{itemize}
\end{itemize}

\begin{figure}[bhtp]
\begin{center}
\includegraphics[width=6cm,height=2cm]{decision-n.eps}
\end{center}
\caption{Symbol to express BDN -- Chance, Decision, and Utility}
\end{figure}

\subsection{Example-1: To bet or not to my football team?}
\begin{quote}
{\it Clare's football team, Melbourne, is going to play her friend John's team, Carlton.  John offers Clare a friendly bet: whoever's team loses will buy the wine next time they go out for dinner. They never spend more than \$15 on wine when they eat out. When deciding whether to accept this bet, Clare will have to assess her team's chances of winning (which will vary according to the weather on the day). She also knows that she will be happy if her team wins and miserable if her team loses, regardless of the bet.}
\end{quote}



\begin{figure}[bhtp]
\begin{center}
\includegraphics[width=10cm,height=5cm]{football.eps}
\end{center}
\caption{To bet or not to my football team?}
\end{figure}

\subsubsection{Information links}
There may be arcs from chance nodes to decision nodes - these are called information links.
\begin{figure}[bhtp]
\begin{center}
\includegraphics[width=10cm,height=5cm]{football-2.eps}
\end{center}
\caption{An example of information link.}
\end{figure}

\clearpage
\subsection{Sequential decision making}
%% What can we expect next -- step to dynamic network}

\subsubsection{Revisit to the Flu example}
\begin{quote}
{\it Suppose that you know that a fever can be caused by the flu. You can use a thermometer, which is fairly reliable, to test whether or not you have a fever. Suppose you also know that if you take aspirin it will almost certainly lower a fever to normal.  Some people (about 5\% of the population) have a negative reaction to aspirin. You'll be happy to get rid of your fever, as long as you don't suffer an adverse reaction if you take aspirin.}
\end{quote}

\begin{figure}[h]
\begin{center}
\includegraphics[width=14cm,height=7cm]{aspirin.eps}
\end{center}
\caption{}
\end{figure}


\subsubsection{An investment to a Real estate}
\begin{quote}
{\it Paul is thinking about buying a house as an investment. While it looks fine externally, he knows that there may be structural and other problems with the house that aren't immediately obvious. He estimates that there is a 70\% chance that the house is really in good condition, with a 30\% chance that it could be a real dud. Paul plans to resell the house after doing some renovation. He estimates that if the house really is in good condition (i.e., structurally sound), he should make a \$5,000 profit, but if it isn't, he will lose about \$3,000 on the investment. Paul knows that he can get a building surveyor to do a full inspection for \$600. He also knows that the inspection report may not be completely accurate. Paul has to decide whether it is worth it to have the building inspection done, and then he will decide whether or not to buy the house.}
\end{quote}

\begin{figure}[h]
\begin{center}
\includegraphics[width=10cm,height=5cm]{real-estate.eps}
\end{center}
\caption{}
\end{figure}

\clearpage
\subsection{Dynamic Bayesian network (DBN)}
When we say Bayesian network, usually all events are static. In other words, all the probability value do not change as time goes by. But as we see in the Flu-Fever-Aspirin example above, taking an aspirin influence the fever tomorrow. Now we study the probabilities are dynamically change as a function of time with the structure of the network basically remaining the same. The structure of the network at time $t$ is called a {\it time-slice}. Arcs in one time-slice is called {\it inter-slice} arcs while arcs link to the next time-slice are called {\it intra-slice} arcs.\\

\noindent
Intra-slice are usually not from all the nodes to the corresponding nodes in the next time-slice. Only sometimes we have such connections as $X_i(T) \rightarrow X_i(t+1)$. Or sometimes one node in one time-slice links different node in the next time-slice $X_i(T) \rightarrow X_j(t+1)$.


\begin{figure}[h]
\begin{center}
\includegraphics[width=7cm,height=3.5cm]{dbn-1.eps}
\caption{A simple example of Dynamic Bayesian Network.}
\end{center}
\end{figure}

\noindent
Sometimes some nodes wield an observation, and as a result we see a time series of observation. In this scenario the node that wields the observation is called {\it state}.

\begin{figure}[h]
\begin{center}
\includegraphics[width=12cm,height=6cm]{dbn-2.eps}
\caption{Still simple but more realistic Dynamic Bayesian Network.}
\end{center}
\end{figure}

\noindent
Sometimes we want to call a node which creates an result that we can observe. From the other field like a Model of Automaton or the Hidden Markov Model, it might be convenient to call such nodes {\it state} and {\it observation}.\\

\begin{figure}[h]
\begin{center}
\includegraphics[width=4cm,height=2cm]{dbn-3.eps}
\caption{Node "{\it state}" and node "{\it observation}"}
\end{center}
\end{figure}

\noindent
Such Dynamic Bayesian Network are useful when we must make a decision making in an uncertainty. That is to say, it's a good tool for {\it Sequential design making} or {\it planning under uncertainty}. Let's recall the example of decision making: to take an aspirin or not to take being afraid of it bad reaction to a body.\\

\begin{figure}[h]
\begin{center}
\includegraphics[width=12cm,height=6cm]{dbn-4.eps}
\caption{A Dynamic Bayesian Network for decision making.}
\end{center}
\end{figure}

\subsubsection{Mobile robot example}
We now assume a mobile robot whose task is to detect and chase a moving object. The robot should reassess its own position as well as the information where the target object is. The robot observes at any slice of time its position with respect to walls and corners and the target position with respect to the robot.\\

\noindent
We denote the real location of own and target at time $t$ as $S_T (t)$ and  $S_R(t)$, and  
the observation of location of own and target at time $t$ as $O_T (t)$ and  $O_R(t)$. 
Utility is the distance from own to target.

\begin{figure}[h]
\begin{center}
%% \includegraphics[width=10cm,height=5cm]{robot-nav.eps}
\includegraphics[width=12cm,height=6cm]{dbn-5.eps}
\end{center}
\caption{Dynamic Bayesian Network for a mobile robot.}
\end{figure}
\clearpage





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\begin{center}
{\Huge {\bf PART III}} \\ 
\bigskip 
{\large {\bf HIDDEN MARKOV MODEL\\ \&\\ BAYESIAN NETWORK}}
\end{center}
\vspace{.6in}

\section{Hidden Markov Model}
This subsection describes what is Hidden Markov Model\footnote{Named after a mathematician Andrei Andreyevich Markov who were born in Ryazan, Russia in 1856 and died in Petrograd, Russia in 1922.}, taking 3 examples from the wonderful tutorial on Hidden Markov Model by Ravinar\footnote{L.~R.~Ravinar (1989) "a tutorial on Hidden Markov Models and selected applications in speech recognition." Proceedings of the IEEE Vol. 77 No. 22.}. Nowadays almost all speech recognition systems use this model. Or many areas in computational molecular biology such as grouping amino-acid sequences into protein families, or fault detection.\\

\subsection{Markov Process}
Before we study Hidden Markov Model, let's see Markov process in general. Image a system with $N$ states, each of which can transfers to another state, or to itself, with a probability. To be more specific, state $i$ transfer to the state $j$ with a probability $a_{ij}$.


\begin{displaymath}
a_{ij}=p(q_{t}=S_i|q_{t-1}=S_j)
\end{displaymath}
This is called $N$-state Markov Model. For example, assume now $N=3$, we have nine such transition probability and we can represent them as the matrix $A$.
\begin{eqnarray}
\nonumber
A =
\left(
\begin{array}{ccc}
a_{11} & a_{12} & a_{13}      \\
a_{21} & a_{22} & a_{23}      \\
a_{31} & a_{32} & a_{33}
\end{array}
\right).
\end{eqnarray}

\subsubsection{A 3-state Markov model of the weather -- Not yet "hidden" though}
We now take a daily weather transition as an example. Imagine the weather at noon everyday. One day it's rain, the next day it's cloudy, the third day it's cloudy again, the fourth day it's fine, the fifth day it's rain again, the sixth day it's fine, and so on. \\

\noindent
Let's assume the transition probability is:


\begin{eqnarray}
\nonumber
A =
\left(
\begin{array}{l|cccc}
\hspace{.01in} & Fine & Cloudy & Rain \\ \hline
Fine           & 0.7 & 0.1 & 0.2      \\
Cloudy         & 0.5 & 0.4 & 0.1      \\
Rain           & 0.6 & 0.3 & 0.1      \\
\end{array}
\right).
\end{eqnarray}

\noindent
Or, schematically,

\begin{figure}[h]
\begin{center}
\includegraphics[width=6cm,height=4.5cm]{weather.eps}
\end{center}
\caption{A toy example of State transitions between three distinct weathers.}
\end{figure}


\color{blue}\begin{exercise}
Calculate the probability of the observation during a 7 day in a row.
\begin{displaymath}
sunny-sunny-sunny-rainy-rainy-sunny-cloudy-sunny
\end{displaymath}
%% under the Malkov Model above.
\end{exercise}\color{black}



\subsection{Hidden Markov Model}
Then what is Hidden Markov Model? Assume now we have $N$ states. The probability of the first state to be started with is $i$-th state is denoted.\\
\begin{displaymath}
 \pi_i,  \hspace{.2in} i = 1,2,\cdots, N.
\end{displaymath}
\noindent
Then the probability of transition from state $i$ to state $j$ is $a_{ij}$. Let's denote this with the matrix $A$:
\begin{displaymath}
A = \{ a_{ij} \},    \hspace{.2in} i = 1,2,\cdots, N.
\end{displaymath}

\noindent
We further assume each state results in one of $M$ distinct observations:
\begin{displaymath}
o_1, o_2, o_3, \cdots, o_M.
\end{displaymath}

\noindent
The probability that state $S_i$ results in the observation $o_j$ is denoted as $b_{ij}$ also denoted with the matrix $B$:
\begin{displaymath}
B = \{ b_{ij} \},    \hspace{.2in} i = 1,2,\cdots, M.
\end{displaymath}

\noindent
The important thing is, all we can know is only a series of observations. we cannot know the state that each of those observations has been resulted from. The state transition is hidden to us. This is the reason of the we call it Hidden Markov Model. \\

%% Let's assume we have $N$ distinct states each of which results in $M$ distinct observations. 
%% What we need now is the state transition probability $p(S_t|S_{t-1}$ and the the probability of output from each of the state 
\noindent
Let's take an example when $N=2$ and $M=4$.

\begin{eqnarray}
\nonumber
B =
\left(
\begin{array}{cccc}
b_{11} & b_{12} & b_{13} & b_{14}     \\
b_{21} & b_{22} & b_{23} & b_{24} 
\end{array}
\right).
\end{eqnarray}


\begin{figure}[h]
\begin{center}
\includegraphics[width=9cm,height=5cm]{state-observation-2.eps}
\end{center}
\caption{A schematic diagram of Hidden Markov model with 2 states and 4 observations.}
\end{figure}

\noindent
Now assume a series of observations was: 
\begin{displaymath}
O=\{o_1, o_2, o_3, \cdots, o_T\}
\end{displaymath}

\noindent
Let us now denote the state at time $t$ as $q_t$. Generally speaking, the transition probability depends on all those states it has shifted from the start. That is,
\begin{displaymath}
a_{ij}=p(S_j).
\end{displaymath}
Then let's think of just a special case where the state at time $t$ is only affected by the state at time $t-1$. Then  
\noindent
Notation \\
\begin{displaymath}
\lambda = \{\pi, A, B\}
\end{displaymath}
\noindent

\noindent
We express the state at time $t$ as $q_t$, that is, $q_t = S_i$ is the state at time $t$ is $S_i$. 
$o_t$ is observation at time $t$.\\

\noindent
Then the probability of this observation given the model $\lambda$ is 
\begin{displaymath}
p(O|\lambda) = \sum_q \pi_{q_0} \prod_{t=1}^{T} {a_{q_{t-1}}a_{q_t} b_{q_t}o_t}
\end{displaymath}


\subsubsection{An example: Fair dice and biased dice} 
Now let's see an example. Assume we have two dices. One is fair dice and the other is biased one. We have two states. The first state is the fair dice, and the second state is the biased one. Each gives one of 6 observations with a probability distribution. For example, fair coin (state 1), of course, results in either of 1, 2, 3, 4, 5, or 6 with the equal probability, namely 1/6, while the biased coin (state 2) results in 1, 2, 3, 4, and 5 with the probability of 1/10 and 1/2 for 6. Assume transition probability between two states is 
\begin{eqnarray}
\nonumber
A =
\left(
\begin{array}{cc}
0.90 & 0.05     \\ 
0.10 & 0.95
\end{array}
\right).
\end{eqnarray}

\noindent
See the Figure below. \\

\begin{figure}[h]
\begin{center}
\includegraphics[width=10cm,height=4cm]{dice.eps}
\end{center}
\caption{A toy example of a fair dice and biased one.}
\label{Fig:dice}
\end{figure}

\noindent
Assume we cannot know which dice is used. Behind the curtain a hidden man changes the dice from time to time according to the probability distribution $A$, with the first dice is chosen according to the probability $\pi$. All we can observe is the result of the dice, such as:\\

\noindent
Then, a question is, e.g., "How likely the following result will occur?" 

\begin{figure}[h]
\begin{center}
	\includegraphics[width=7cm,height=0.5cm]{result-dice-1.eps}
\hspace{.1in}\\Or\\\hspace{.1in}\\
	\includegraphics[width=7cm,height=0.5cm]{result-dice-2.eps}
\end{center}
\end{figure}


\noindent
Or, we can imagine the situation at a casino, where a roulette dealer tries to switch his roulette machine a fair mode and a biased mode.


\subsubsection{Another example: Coin toss models}
Now behind the curtain a dealer tosses coins several times. And each time the dealer tells us the result is {\it "Head"} or {\it "Tail."}\\

\noindent
The dealer has a multiple coins each has a different probability to result in Head or Bottom. The dealer changes from one coin to another using a prefixed transition probability table. Then assume the result was
\begin{quote}
{\it Head, Head, Head, Tail, Head, Tail, Head, Head, Head, Tail, Tail, Head}
\end{quote}
We might guess that the occurrences of {\it Head} are too many for the coins are fair. Then the question is, "what happens behind the curtain?" \\
 
%% \begin{figure}[h]
%% \begin{center}
%% \includegraphics[width=5cm,height=3cm]{coin-1.eps}
%% \end{center}
%% \caption{A coin model assuming one coin.}
%% \end{figure}

\noindent
{\bf Two coin model}\\
\noindent
We suppose the dealer has two unfair coins and the dealer follows the transition rule

\begin{eqnarray}
\nonumber
A =
\left(
\begin{array}{l|cc}
\hspace{.01in} & Coin-1      & Coin-2       \\ \hline
Coin-1         & a_{11}    & a_{12}     \\
Coin-2         & a_{21}    & a_{22}     \\
\end{array}
\right).
\end{eqnarray}

\noindent
And each coin result in {\it Head} or {\it Tail} is from the probability table:
 
\begin{eqnarray}
\nonumber
A =
\left(
\begin{array}{l|cc}
\hspace{.01in} & Coin-1 & Coin-2            \\ \hline
Head           & b_{11}    & b_{12}     \\
Tail           & b_{21}    & b_{22}     \\
\end{array}
\right).
\end{eqnarray}

\noindent
Further, the dealer start the tossing with $i$-th coin ($i=1,2$) with the probability $\pi_i$. See the Figure below.

\begin{figure}[h]
\begin{center}
\includegraphics[width=12cm,height=4cm]{coin-2.eps}
\end{center}
\caption{A coin model assuming two coins.}
\end{figure}

\noindent
\color{blue}
Now our question might be to guess these 15 parameters, that is, $\lambda = \{\pi_i, A, B\}$ so that the observation is most likely, or equivalently, to maximize the probability of the observation:
\begin{displaymath}
p(Head, Head, Head, Tail, Head, Tail, Head, Head, Head, Tail, Tail, Head).
\end{displaymath}
\color{black}

\noindent
Or, the other question might be, \color{blue} "Which series of hidden states are most likely?" \color{black}\\


\noindent
{\bf Three coin model}\\
\noindent
Yet another possibility is, the dealer has 3 coins, not two. Then the state transition would be:

\begin{figure}[h]
\begin{center}
\includegraphics[width=13.5cm,height=6cm]{coin-3.eps}
\end{center}
\caption{A coin model assuming three coins.}
\end{figure}


\subsubsection{Further example: two urns with colored balls}
The final toy example is with two urns each contains a number of balls with red, blue, and purple color. The. The state-1 is the first urn and the state-2 is the second urn. Assume now, the first urn contains 5 red, 3 blue, and 1 purple balls while the second contains 2 red, 4 blue, and 2 purple balls. The dealer, behind the curtain, pick up one ball from either of the urns and tell us the color of the ball. Then the dealer return the ball to the urn he picked up the ball. This is repeated by changing urn to pick up the ball from according to the preset probability table as previous two examples. See the Figure.\\ 

\begin{figure}[h]
\begin{center}
	\includegraphics[width=9cm,height=4.5cm]{urn.eps}
\end{center}
\caption{A toy example of thought experiment with two urns each of which contains balls with three different colors.}
\end{figure}

\noindent
The question might be, \color{blue} "What is the probability of a series of observations, like in the Figure below.


\begin{figure}[h]
\begin{center}
	\includegraphics[width=6cm,height=0.2cm]{result-urn.eps}
\hspace{.1in}\\Or\\
	\includegraphics[width=6cm,height=0.2cm]{result-urn-2.eps}
\end{center}
\caption{A toy example of thought experiment with two urns each of which contains balls with three different colors.}
\end{figure}



\subsection{Three important problems}
As we have seen in examples above, three important questions raise.
\begin{itemize}
\setlength{\itemsep}{0pt}
\item Given $\lambda = \{\pi, A, B \}$, estimate "How likely the observation is?"  That is:
   \begin{itemize}
   \item[] $p(o_1, o_2, o_3, \cdots, o_T) = ?$
   \end{itemize}
\item Given $\lambda = \{\pi, A, B \}$, guess the most likely series of hidden states?
   \begin{itemize}
   \item[] $(q_1, q_2, q_3, \cdots, q_T)$
   \end{itemize}
so that we can predict the probability of the next state:
   \begin{itemize}
   \item[] $p(q_{T+1} | q_1, q_2, q_3, \cdots, q_T)$
   \end{itemize}
\item Given a series of observations $(o_1, o_2, o_3, \cdots, o_T)$ modify $\lambda$ so that it will maximize the $p(o_1, o_2, o_3, \cdots, o_T)$.
   \begin{itemize}
   \item[$\star$]This might be called {\it TRAINING}, or equivalently, {\it LEARNING} of the model.
   \end{itemize}
\end{itemize}


\noindent
To be more specific:
\begin{itemize}
\setlength{\itemsep}{0pt}
\item The Evaluation Problem
   \begin{itemize}
   \item[$\star$] Given the observation sequence $O$ and a model $lambda$, how do we efficiently evaluate the probability of being produced by the source model $/lambda$. That is, what is $p(O|\lambda)$.
   \end{itemize}
\item The Decoding Problem
   \begin{itemize}
   \item[$\star$] how to deduce from $O$ the most likely state sequence $q$ in a meaningful manner.
   \item[$\star$] it is important in many applications to have the knowledge of the most likely state sequence for several reasons. As an example, if we use the states of a word model to represent the distinct sounds in the word, it may be desirable to know the correspondence between the speech segments and the sounds of the word, because the duration of the individual speech segments provides useful information for speech recognition.
   \end{itemize}
\item The Estimation Problem
   \begin{itemize} 
   \item[$\star$] Given the observation $O$, how do we solve the inverse problem of estimating the parameters
in $\lambda$?
   \item[$\star$] Given an observation sequence (or a set of sequence) $O$, the estimation problem involves finding the "right" model parameter values that specify a model most likely to produce the given sequence. In speech recognition, this is often called "training,"
   \end{itemize}
\end{itemize}

\clearpage
\section{Speech recognition}
\begin{figure}[h]
\begin{center}
\includegraphics[width=11cm,height=3cm]{speech-recognition.eps}
\end{center}
\caption{A block diagram of a system for speech recognition.}
\end{figure}
\noindent
Usually in Speech recognition hidden states represent {\it phonemes} such as {\it /k/, /ae/, /t/} etc.\\


\begin{figure}[h]
\begin{center}
\includegraphics[width=11cm,height=5cm]{st-ob-time.eps}
\end{center}
\caption{A schematic diagram of a time series of speech recognition by Hidden Markov Model.}
\end{figure}


\begin{displaymath}
\hat{w} = \operatorname{arg\,max}_w \{p(w|\boldsymbol{y})\}.
\end{displaymath}
\noindent
However, as $p(w|\boldsymbol{y})$ is difficult to be treated, we transform this to
\color{red}\begin{displaymath}
\hat{w} = \operatorname{arg\,max}_w \{p(\boldsymbol{y}|w)p(w)\}.
\end{displaymath}\color{black}
\noindent
recalling the Bayes' rule.\\
\noindent
Then $p(\boldsymbol{y}|w)$ is determined by an {\it acoustic model} and the $p(w)$ is determined by a {\it language model}.

\noindent
1) Feature analysis: A special and/or temporal analysis of the speech signal is to give observation vectors for training the HMMs which characterize speech sounds
2) Unit matching 
Typically each such unit is characterized by an HMM whose parameters are estimated from a training set
3) Lexical decoding: Vocabulary must be specified in terms of the basic units for recognition.
such a specification can be either deterministic, or stochastic.
deterministic => one or more FSA for each word in the vocabulary
statistical => p is attached to the arcs in the FSA representation of words.
4) Syntactic analysis: A grammar can be represented by a deterministic finite state automaton.
5) Semantic analysis: depending on the state of the recognizer, some syntactically correct input strings are eliminated from consideration.

\subsection{Speech recognition by Hidden Markov Model}


\subsection{Speech recognition by Dynamic Bayesian Network}


\begin{figure}[h]
\begin{center}
\includegraphics[width=11cm,height=5cm]{speech-recog-bayes.eps}
\end{center}
\caption{A block diagram of speech recognition by Dynamic Bayesian Network.}  
\end{figure}


\subsection{Hidden Markov Model \& Dynamic Bayesian Network}
Thus far we have learned Hidden Markov models are a particular form of Dynamic Bayesian networks through an application of speech recognition.


\clearpage
\section{Stock Market Forecasting}
\subsection{A simple model - Not hidden}
Let's start with a very simple model in which states are not hidden. States are, for example, (1) good financial state also know as Bull State, (2) normal state, and (3) bad state a.k.a. Bear state. Assume state transition probabilities are know. When one state changes to another state, economy also change. For example, either of (i) large rise, (ii), small rise, (iii) no change, (iv) small fall, and (v) large fall. Then the phenomena will be shown as Figure \ref{Fig: no-hidden-economy}~\footnote{This example was taken from\\ Y. Zhang (2001) "Prediction of financial time series with Hidden Markov Models." Msc dissertation submitted to Simon Fraser University.}. 
\begin{figure}[h]
\begin{center}
\includegraphics[width=11cm,height=5cm]{stock-not-hidden.eps}
\end{center}
\caption{An example of three-state model for stock market forecasting.}
\label{Fig: no-hidden-economy}
\end{figure}

\noindent
Then we can calculate the probability of a series of state changes, like
\color{blue}
\begin{displaymath}
1 \rightarrow 1 \rightarrow 3 \rightarrow 2 \rightarrow 3 \rightarrow 2 \rightarrow 1
\end{displaymath}
\color{black}

\subsection{Hidden Markov Model for stock market forecasting}
States are financial states, as the example in the previous section. Or trends of investors, government's financial strategies, or something else. In any case each state reflects, or equivalently, results in, the stock price. Depending on what we want to forecast, the price is average of all stocks, or specific one stock, such as Microsoft Corporation, I.B.M, or Google Co, etc. Or instead of prices we can think of fluctuation of the price. Anyway those values are not discrete as we have studied so far, but a continuous value. We can digitize the value, but usually we analyse the continuous values. Therefore, the probability of one state to result in an observation should be also continuous. The most popular way is using a weighting sum of Gaussian probability distribution functions. This is called {\it Gaussian Mixture p.d.f.}
\begin{displaymath}
\sum_{i=1}^{k} N_i (\mu_i, \sigma_i)
\end{displaymath}
where
\begin{displaymath}
N(x, \mu, \sigma) = \frac{1}{n}\sum_{i=1}^{n}\frac{1}{h\sqrt{2\pi}}\exp(-\frac{1}{2}(\frac{x-x_i}{h})^2).
\end{displaymath}
For example:
\begin{figure}[h]
\begin{center}
\includegraphics[width=5cm,height=5cm]{gaussian-mixture-1.eps}
%%\includegraphics[width=5cm,height=5cm]{gaussian-mixture-3.eps}
\includegraphics[width=5cm,height=5cm]{gaussian-mixture-2.eps}
\end{center}
\caption{Two Gaussian-mixtures. Left $0.2*N(5, 1.2) + 0.5*N(2, 0.9) + 0.3* N(-2,  0.7)$ and right
$0.6*N(3, 0.6) + 0.1*N(0, 0.4) + 0.3* N(-2,  0.6)$} 
\end{figure}

\noindent
Or, if observation is not one dimensional value such as price, but a high-dimensional vector, like 
\begin{center}
{\it \{today's price, yesterday's price, price two day's ago \}}
\end{center}
then we use a high-dimensional Gaussian p.d.f.
\begin{equation} \label{eq: gaussian-multi-d} \nonumber
f(\mbox{\bf x}) = 
\frac{1}{(2\pi)^{d/2} \vert \Sigma_i \vert ^{1/2}}
\exp\{- \frac{1}{2}(\mbox{\bf x} - \boldsymbol{\mu}_i)^t {\Sigma_i}^{-1} (\mbox{\bf x} - \boldsymbol{\mu}_i)\}
\end{equation}
as we studied previously in Part I.\\

\noindent
Then imagine two-dice-example we saw in Figure~\ref{Fig:dice}. We have two states each of which result in observation of a continuous value following the Gaussian mixture p.d.f., instead of 1, 2, 3, 4, 5, or 6 following a probability like 1/6 or 1/10.\\

%% \subsection{A more general model}
\begin{figure}[h]
\begin{center}
\includegraphics[width=11cm,height=5cm]{continuous-hmm.eps}
\end{center}
\caption{A schematic diagram of two states each of which yields an observation with its Gaussian mixture p.d.f.}  
\end{figure}

\noindent
Recall a training of a HMM from a dataset $D$ is obtaining the model $M$ by maximizing
\begin{displaymath}
p(M|D)=\frac{p(D|M)p(M)}{p(D)}.
\end{displaymath}
\noindent
When, however, the model $M$ includes a set of continuous parameters $\theta$ the probability is
\begin{displaymath}
p(M|D)=\frac{\int p(D|\theta, M)p(\theta)d\theta p(M)}{p(D)}.
\end{displaymath}

\noindent
In stock market prediction, assume we have a series of observation $y_t$, that is 
\begin{displaymath}
D = \{y_1, y_2, y_3, \cdots, y_t\}.
\end{displaymath}
Then what we want to know is,
\begin{displaymath}
p(y_{t+1}|D) = \int p(y_{t+1}|\theta, M, D)p(\theta|M,D)p(M|D)d\theta dM.
\end{displaymath}
This is called {\it predictive distribution}.\\

\noindent
Now our hidden states are investment strategies or trend that are mixture of the weighted sum of 4 multi dimensional Gaussian pdf.
\begin{displaymath}
\sum_{i=1}^4 w_i N_i (\Sigma_i, \mu_i)
\end{displaymath}


\noindent
Then we can calculate how likely the series of state transitions which yields the series of change of prices we have observed, or more importantly, we can calculate the probability of the next state and most likely observations from the predicted state, that is, the price of tomorrow, for example. \\

\noindent
Probably most importantly, from a series of observations:
\begin{displaymath}
O_1, O_2, O_3, O_4, O_5, O_6, O_7, O_8, \cdots, O_T 
\end{displaymath}
you can optimize the parameters such that this series of observations is most likely, then
with those parameters you may infer the most likely series of hidden states,
\begin{displaymath}
S_1, S_2, S_3, S_4, S_5, S_6, S_7, S_8, \cdots, S_T
\end{displaymath}
and $S_{T+1}$ which means a most likely state of tomorrow. Finally, you can infer the most 
likely $O_{T+1}$ that will most likely result in from $S_{T+1}$. This is what we might want to know, namely, tomorrow's price. \\

\noindent
I wish your luck!


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\begin{center}
{\bf CONCLUDING REMARKS} \\ 
\end{center}


\bigskip
\noindent
In the article in The New York Times on 16 March 2012, Steve Lohr wrote:
\begin{quote}
{\small
{\it 
\noindent
Google search, I.B.M.'s Watson Jeopardy-winning computer, credit-card fraud detection and automated speech recognition. There seems not much in common on that list. But it is a representative sampling of the kinds of modern computing chores that use the ideas and technology developed by Judea Pearl, the winner of this year's Turing Award.  The award, often considered the computer science equivalent of a Nobel prize, was announced on Wednesday by the Association for Computing Machinery.  "It allowed us to learn from the data rather than write down rules of logic," said Peter Norvig, an artificial intelligence expert and research director at Google. "It really opened things up." \\

\noindent
Dr. Pearl, with his work, he added, "was influential in getting me, and many others, to adopt this probabilistic point of view." Dr. Pearl, 75, a professor at the University of California, Los Angeles, is being honored for his contributions to the development of artificial intelligence. In the 1970s and 1980s, the dominant approach to artificial intelligence was to try to capture the process of human judgment in rules a computer could use. They were called rules-based expert systems.  Dr. Pearl championed a different approach of letting computers calculate probable outcomes and answers. It helped shift the pursuit of artificial intelligence onto more favorable terrain for computing.  Dr. Pearl's work on Bayesian networks - named for the 18th-century English mathematician Thomas Bayes - provided "a basic calculus for reasoning with uncertain information, which is everywhere in the real world," said Stuart Russell, a professor of computer science at the University of California, Berkeley. "That was a very big step for artificial intelligence." \\

\noindent
Dr. Pearl said he was not surprised that his ideas are seen in many computing applications. "The applications are everywhere, because uncertainty is everywhere," Dr. Pearl said.  "But I didn't do the applications," he continued. "I provided a way for thinking about your problem, and the formalism and framework for how to do it." \\

\noindent
(The Turing Award, named for the English mathematician Alan M. Turing, includes a cash prize of \$250,000, with financial support from Intel and Google.) 
}}
\end{quote}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\begin{center}
{\Huge {\bf APPENDIX}} \\ 
\end{center}

\vspace{.6in}

\begin{itemize}
\setlength{\itemsep}{0pt}
\item[1.] Three Prisoners two of whom will be executed tomorrow. 
\item[2.] Quadratic form in 2-dimensional space.
\item[3.] How to calculate inverse of 3-dimensional matrix?
\end{itemize}




\clearpage
\section*{I. Bayesian formula in another scenario}
\begin{itemize}
\item[$\cdot$] Three prisoners ({\bf A}, {\bf B}, and {\bf C}) are 
               in a prison.
\item[$\cdot$] {\bf A} knows that the two out of the three are to 
               be executed tomorrow, and the rest becomes free.
\item[$\cdot$] {\bf A} thought either one of {\bf B} or {\bf C} is sure
               to be executed. 
\item[$\cdot$] Then, {\bf A} asked a guard ``even if you tell me
               which of {\bf B} and {\bf C} is executed, that will not give
               me any information as for me. So please tell it to me.'' 
\item[$\cdot$] The guard answers that {\bf C} will. $\Rightarrow$ data $D$
\item[$\cdot$] Now, {\bf A} knows one of {\bf A} or {\bf B} is sure to be
               free.
\end{itemize}

\begin{center} \underline{\hspace*{7in}} \end{center} 

\noindent
Do you guess probability $p(A \vert D) = 1/2$?\\
\hspace*{1in}\\
If this is correct, then the answer of the guard had given an information as for A, since probability $p(A)$ was $1/3$ without the information.\\

\noindent
You agree that prior probabilities of being free tomorrow for each of {\bf A}, {\bf B}, and {\bf C} are

\begin{displaymath}
p(A) = p(B) = p(C) = 1/3.
\end{displaymath}

Then, try to apply Bayesian rule, i.e., obtain the conditional probability of the data ``C will be executed'' under the condition that ``A will be free tomorrow'' And in the same way for B and C. They are:

\begin{eqnarray}
\nonumber
p(D \vert A) &=& 1/2. \\
\nonumber
p(D \vert B) &=& 1.   \\
\nonumber
p(D \vert C) &=& 0.
\end{eqnarray}

\noindent
In conclusion:

\begin{displaymath}
p(A \vert D)=\frac{p(D \vert A)p(A)}
                  {p(D \vert A)p(A)+p(D \vert B)p(B)+p(D \vert C)p(C)}
=1/3.
\end{displaymath}

\bigskip
\noindent
This shows probability did not change after the information!

\clearpage 
\section*{II. Quadratic form in 2-dimensional space}
You might be interested, first of all, in how points scattered are influenced by values in $\Sigma$, that is, $\sigma_1^2$, $\sigma_2^2$, and $\sigma_{12}=\sigma_{21}$. Let's observe here three different cases of $\Sigma$ when $\mu=(0, 0)$.

\begin{small}
\begin{eqnarray}
\nonumber
(1) \hspace{.1in}\Sigma_1 =
\left(
\begin{array}{cc}
0.20 & 0             \\
0    & 0.20
\end{array}
\right)
\hspace{.1in}
(2) \hspace{.1in}\Sigma_2 =
\left(
\begin{array}{cc}
0.1 & 0             \\
0   & 0.9
\end{array}
\right)
\hspace{.1in}
(3) \hspace{.1in}\Sigma_3 =
\left(
\begin{array}{cc}
0.5 & 0.3             \\
0.3 & 0.2
\end{array}
\right)
\end{eqnarray}
\end{small}

\begin{figure}[bhtp]
 \begin{center}
\includegraphics[width=5cm,height=5cm]{gaussian-2d-200-points-1.eps}
\includegraphics[width=5cm,height=5cm]{gaussian-2d-200-points-2.eps}
\includegraphics[width=5cm,height=5cm]{gaussian-2d-200-points-3.eps}
 \end{center}
 \caption{A cloud of 200 Gaussian random points with three different three $\Sigma$.}
\end{figure}

\clearpage
\section*{III. How to calculate inverse of 3-dimensional matrix.} \label{append}
We now try to calculate the inverse of the following 3-D matrix $A$ which appeared in the subsection \ref{subsec}.

\begin{eqnarray}
\nonumber
A =
\left(
\begin{array}{ccc}
 0.3 &  0.1 &  0.1      \\
 0.1 &  0.3 & -0.1      \\
 0.1 & -0.1 &  0.3
\end{array}
\right)
\end{eqnarray}

\noindent
We use a relation 
$A\mbox{{\bf x}} = I$
where $\mbox{{\bf x}} = (x, y, z)^T$ and $I$ is {\it identity matrix}, i.e.,
\begin{eqnarray}
\nonumber
\left(
\begin{array}{ccc}
 0.3 &  0.1 &  0.1      \\
 0.1 &  0.3 & -0.1      \\
 0.1 & -0.1 &  0.3
\end{array}
\right)
\left(
\begin{array}{r}
x \\
y \\
z 
\end{array}
\right)
=
\left(
\begin{array}{ccc}
1 & 0 & 0       \\
0 & 1 & 0       \\
0 & 0 & 1
\end{array}
\right)
\end{eqnarray}
It remains identical 
if we multiply \{{\it 2nd-raw}\} by 3 and subtract the {\it \{1st-raw\}}, i.e.,
\begin{eqnarray}
\nonumber
\left(
\begin{array}{ccc}
 0.3 &  0.1 &  0.1      \\
 0   &  0.8 & -0.4      \\
 0.1 & -0.1 &  0.3
\end{array}
\right)
\left(
\begin{array}{r}
x \\
y \\
z 
\end{array}
\right)
=
\left(
\begin{array}{ccc}
1  & 0  & 0       \\
-1 & 3  & 0       \\
0  & 0  & 1
\end{array}
\right)
\end{eqnarray}
In the same way, but this time, we multiply \{{\it 3rd-raw}\} by 3 and subtract the {\it \{1st-raw\}}.
\begin{eqnarray}
\nonumber
\left(
\begin{array}{ccc}
 0.3 &  0.1 &  0.1      \\
 0   &  0.8 & -0.4      \\
 0   & -0.4 &  0.8
\end{array}
\right)
\left(
\begin{array}{r}
x \\
y \\
z 
\end{array}
\right)
=
\left(
\begin{array}{ccc}
 1 & 0  & 0       \\
-1 & 3  & 0       \\
-1 & 0  & 3
\end{array}
\right)
\end{eqnarray}
Then, e.g.,
multiply the {\it \{1st-raw\}} by 8 and then subtract the {\it \{2nd-raw\}}:
\begin{eqnarray}
\nonumber
\left(
\begin{array}{ccc}
 2.4 &  0   &  1.2        \\
 0   &  0.8 & -0.4        \\
 0   & -0.4 &  0.8
\end{array}
\right)
\left(
\begin{array}{r}
x \\
y \\
z 
\end{array}
\right)
=
\left(
\begin{array}{ccc}
 9 & -3  &   0       \\
-1 &  3  &   0       \\
 0 &  0  &   3
\end{array}
\right)
\end{eqnarray}
Multiply the {\it \{3rd-raw\}} by 2 and then add the {\it \{2nd-raw\}}:
\begin{eqnarray}
\nonumber
\left(
\begin{array}{ccc}
 2.4 &  0   &  1.2        \\
 0   &  0.8 & -0.4      \\
 0   &  0   &  1.2
\end{array}
\right)
\left(
\begin{array}{r}
x \\
y \\
z 
\end{array}
\right)
=
\left(
\begin{array}{ccc}
 9 & -3  & 0       \\
-1 &  3  & 0       \\
-1 &  3  & 6
\end{array}
\right)
\end{eqnarray}
Subtract {\it \{3rd-raw\}} from the  {\it \{1st-raw\}}:
\begin{eqnarray}
\nonumber
\left(
\begin{array}{ccc}
 2.4 &  0   &  0        \\
 0   &  0.8 & -0.4      \\
 0   &  0   &  1.2
\end{array}
\right)
\left(
\begin{array}{r}
x \\
y \\
z 
\end{array}
\right)
=
\left(
\begin{array}{ccc}
 10 & -6 & -6       \\
 -1 &  3 &  0       \\
 -1 &  3 &  6
\end{array}
\right)
\end{eqnarray}
Multiply the {\it \{2nd-raw\}} by 3 then add the {\it \{3rd-raw\}}:
\begin{eqnarray}
\nonumber
\left(
\begin{array}{ccc}
 2.4 &  0   &  0        \\
 0   &  2.4 &  0        \\
 0   &  0   &  1.2
\end{array}
\right)
\left(
\begin{array}{r}
x \\
y \\
z 
\end{array}
\right)
=
\left(
\begin{array}{ccc}
 10 &  -6 & -6       \\
 -4 &  12 &  6       \\
 -1 &   3 &  6
\end{array}
\right)
\end{eqnarray}
Finally, divide the {\it \{1st-raw\}} by 2.4, divide the {\it \{2nd-raw\}} by 2.4, and divide the {\it \{3rd-raw\}} by 1.2, we obtain,

\begin{eqnarray}
\nonumber
\left(
\begin{array}{ccc}
 1   &  0   &  0        \\
 0   &  1   &  0        \\
 0   &  0   &  1
\end{array}
\right)
\left(
\begin{array}{r}
x \\
y \\
z 
\end{array}
%% 25/6  & -5/2 & -5/2       \\
%% -5/3  &  5   &  5/2       \\
%% -5/6  &  5/2 &  5
\right)
= \frac{1}{30}
\left(
\begin{array}{ccc}
 5  & -3 & -3       \\
-2  &  6 &  3       \\
-1  &  3 &  6
\end{array}
\right)
\end{eqnarray}

\noindent
Now we know the right-hand-side is the inverse of $A$ because the equation implies $I \mbox{{\bf x}} = B$ and it holds $AI \mbox{{\bf x}} = AB$, that is, $A \mbox{{\bf x}} = AB$. Hence $AB = I$ which means $B=A^{-1}$.\\

%% 0.3 &  0.1 &  0.1       25  & -15 & -15    7.5-1.0-0.5  -4.5+3.0+1.5  -4.5+1.5+3.0  6 0 0
%% 0.1 &  0.3 & -0.1      -10  &  30 &  15    2.5-3.0+0.5  -1.5+9.0-1.5  -1.5+4.5-3.0  0 6 0          
%% 0.1 & -0.1 &  0.3       -5  &  15 &  30    2.5+1.0-1.5  -1.5-3.0+4.5  -1.5-1.5+9.0  0 0 6

\noindent
To make it sure, calculate and find

\begin{eqnarray}
\nonumber
\left(
\begin{array}{ccc}
 0.3 &  0.1 &  0.1      \\
 0.1 &  0.3 & -0.1      \\
 0.1 & -0.1 &  0.3
\end{array}
\right)
\times
\frac{1}{30}
\left(
\begin{array}{ccc}
 5  & -3 & -3       \\
-2  &  6 &  3       \\
-1  &  3 &  6
\end{array}
\right)
\end{eqnarray}

\begin{eqnarray}
\nonumber
= \frac{1}{6}
\left(
\begin{array}{ccc}
 25  & -15 & -15       \\
-10  &  30 &  15       \\
 -5  &  15 &  30
\end{array}
\right)
\times
\left(
\begin{array}{ccc}
 0.3 &  0.1 &  0.1      \\
 0.1 &  0.3 & -0.1      \\
 0.1 & -0.1 &  0.3
\end{array}
\right)
= 
\left(
\begin{array}{ccc}
1 & 0 & 0  \\
0 & 1 & 0  \\
0 & 0 & 1
\end{array}
\right)
\end{eqnarray}

\noindent
Therefore
\begin{eqnarray}
\nonumber
A^{-1}
= \frac{1}{30}
\left(
\begin{array}{ccc}
 5  & -3 & -3       \\
-2  &  6 &  3       \\
-1  &  3 &  6
\end{array}
\right)
\end{eqnarray}

\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Definition 1.5 Jeffrey conditionalization
Suppose your observational evidence does not correspond specifically to proposition e, but can be represented as a posterior shift in belief about e. In other words, posterior belief in e is not full but partial, having shifted from p(e) to belief(e). Then, instead of Bayesian conditionalization, apply Jeffreys update rule [123] for probability kinematics:

     belief (h) = p(h|e)belief(e) + p(h|non e)belief(non e) 

Jeffreys own example is one where your hypothesis is about the color of a cloth, the evidence proposition e describes the precise quality of your visual experience under good light, but you are afforded a view of the cloth only under candlelight, in such a way that you cannot exactly articulate what you have observed. Nevertheless, you have learned something, and this is reflected in a shift in belief about the quality of your visual experience.

Jeffrey conditionalization is very intuitive, but again is not strictly valid. As a practical matter, the need for such partial updating is common in Bayesian modeling.

