#LyX 2.3 created this file. For more info see http://www.lyx.org/
\lyxformat 544
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass article
\begin_preamble
\def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]}
\let\endchangemargin=\endlist
\pagenumbering{gobble}
\usepackage{pxfonts}
\usepackage{color}
\definecolor{commentgreen}{RGB}{0,94,11}
\definecolor{darkblue}{rgb}{0,0,0.75}
\definecolor{darkred}{rgb}{0.6,0,0}
\end_preamble
\use_default_options true
\begin_modules
customHeadersFooters
minimalistic
todonotes
\end_modules
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding utf8
\fontencoding global
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\use_microtype true
\use_dash_ligatures true
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command biber
\index_command default
\paperfontsize default
\spacing onehalf
\use_hyperref true
\pdf_title "Hidden Markov Models"
\pdf_author "Andy Pack"
\pdf_subject "EEEM030"
\pdf_keywords "EEEM030"
\pdf_bookmarks true
\pdf_bookmarksnumbered false
\pdf_bookmarksopen false
\pdf_bookmarksopenlevel 1
\pdf_breaklinks false
\pdf_pdfborder true
\pdf_colorlinks false
\pdf_backref false
\pdf_pdfusetitle true
\papersize default
\use_geometry true
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine biblatex
\cite_engine_type authoryear
\biblio_style plain
\biblio_options urldate=long
\biblatex_bibstyle ieee
\biblatex_citestyle ieee
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date true
\justification true
\use_refstyle 1
\use_minted 0
\index Index
\shortcut idx
\color #008000
\end_index
\leftmargin 1.8cm
\topmargin 2cm
\rightmargin 1.8cm
\bottommargin 2cm
\secnumdepth 3
\tocdepth 3
\paragraph_separation skip
\defskip medskip
\is_math_indent 0
\math_numbering_side default
\quotes_style english
\dynamic_quotes 0
\papercolumns 1
\papersides 1
\paperpagestyle fancy
\listings_params "language=Python,breaklines=true,frame=tb,otherkeywords={self},emph={State},emphstyle={\ttb\color{darkred}},basicstyle={\ttfamily},commentstyle={\bfseries\color{commentgreen}\itshape},keywordstyle={\color{darkblue}},emphstyle={\color{red}},stringstyle={\color{red}}"
\bullet 1 0 9 -1
\bullet 2 0 24 -1
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header
\begin_body
\begin_layout Title
\size giant
Hidden Markov Model Analysis
\end_layout
\begin_layout Author
Andy Pack
\end_layout
\begin_layout Standard
\begin_inset VSpace 15pheight%
\end_inset
\end_layout
\begin_layout Standard
\align center
\begin_inset Graphics
filename surrey.png
lyxscale 15
width 40col%
\end_inset
\end_layout
\begin_layout Standard
\begin_inset VSpace vfill
\end_inset
\end_layout
\begin_layout Standard
\noindent
\align center
EEEM030
\begin_inset Newline newline
\end_inset
January 2021
\size large
\begin_inset Newline newline
\end_inset
Department of Electrical and Electronic Engineering
\begin_inset Newline newline
\end_inset
Faculty of Engineering and Physical Sciences
\begin_inset Newline newline
\end_inset
University of Surrey
\end_layout
\begin_layout Standard
\begin_inset Newpage newpage
\end_inset
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
pagenumbering{roman}
\end_layout
\end_inset
\end_layout
\begin_layout Abstract
An analysis of a continuous probability density hidden Markov model is presented.
Forward and backward likelihoods for all observation/state combinations
are given before confirming the same observation likelihood from each method.
The occupation likelihoods for each state at each time step are calculated
and used in combination with the transition likelihoods to complete an
iteration of Baum-Welch training.
This procedure results in a re-estimation of the output function parameters,
these are compared to the originals for analysis.
\end_layout
\begin_layout Standard
\begin_inset CommandInset toc
LatexCommand tableofcontents
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Newpage pagebreak
\end_inset
\end_layout
\begin_layout Standard
\begin_inset FloatList figure
\end_inset
\end_layout
\begin_layout Standard
\begin_inset FloatList table
\end_inset
\end_layout
\begin_layout Standard
\begin_inset CommandInset toc
LatexCommand lstlistoflistings
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Newpage newpage
\end_inset
\end_layout
\begin_layout Right Footer
Andy Pack / 6420013
\end_layout
\begin_layout Left Footer
January 2021
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
pagenumbering{arabic}
\end_layout
\begin_layout Plain Layout
\backslash
setcounter{page}{1}
\end_layout
\end_inset
\end_layout
\begin_layout Section
Introduction
\end_layout
\begin_layout Standard
The Markov model is a stochastic model for analysing random processes.
The model describes a system of multiple states and the transitions between
them; a key feature is the
\emph on
Markov property
\emph default
which states that the future state of the system depends only on the current
state
\begin_inset CommandInset citation
LatexCommand cite
key "towards-data-science-markov-intro"
literal "false"
\end_inset
.
This is also described as the system being
\emph on
memoryless
\emph default
.
The hidden Markov model extends the standard Markov chain by modelling
a system where the states are not directly observable but are hidden
\begin_inset CommandInset citation
LatexCommand cite
key "standford-hmm-book"
literal "false"
\end_inset
, instead the states are inferred from the state topology and visible observatio
ns.
\end_layout
\begin_layout Subsection
Brief
\end_layout
\begin_layout Standard
This work analyses a continuous-density hidden Markov model of 2 emitting
states describing a 1D observation space.
Various statistics and calculations will be analysed including forward,
backward, occupation and transition likelihoods.
Using these, an iteration of Baum-Welch training
\begin_inset CommandInset citation
LatexCommand cite
key "standford-hmm-book,pj-h-baum-welch"
literal "false"
\end_inset
will be completed resulting in re-estimated output probabilities.
\end_layout
\begin_layout Standard
The model is specified as follows; the transition probabilities are described
by entry (
\begin_inset Formula $\pi$
\end_inset
) and exit (
\begin_inset Formula $\eta$
\end_inset
) probabilities for each state along with a matrix of state-to-state transitions
(
\begin_inset Formula $a$
\end_inset
),
\end_layout
\begin_layout Standard
\begin_inset Formula
\[
A=\left\{ \pi_{j},a_{ij},\eta_{i}\right\}
\]
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Box Frameless
position "t"
hor_pos "c"
has_inner_box 1
inner_pos "t"
use_parbox 0
use_makebox 0
width "30col%"
special "none"
height "1in"
height_special "totalheight"
thickness "0.4pt"
separation "3pt"
shadowsize "4pt"
framecolor "black"
backgroundcolor "none"
status open
\begin_layout Plain Layout
\begin_inset Formula
\[
\pi_{j}=\left\{ 0.44,0.56\right\}
\]
\end_inset
\end_layout
\end_inset
\begin_inset space \hfill{}
\end_inset
\begin_inset Box Frameless
position "t"
hor_pos "c"
has_inner_box 1
inner_pos "t"
use_parbox 0
use_makebox 0
width "30col%"
special "none"
height "1in"
height_special "totalheight"
thickness "0.4pt"
separation "3pt"
shadowsize "4pt"
framecolor "black"
backgroundcolor "none"
status open
\begin_layout Plain Layout
\begin_inset Formula
\[
a_{ij}=\left[\begin{array}{cc}
0.92 & 0.06\\
0.04 & 0.93
\end{array}\right]
\]
\end_inset
\end_layout
\end_inset
\begin_inset space \hfill{}
\end_inset
\begin_inset Box Frameless
position "t"
hor_pos "c"
has_inner_box 1
inner_pos "t"
use_parbox 0
use_makebox 0
width "30col%"
special "none"
height "1in"
height_special "totalheight"
thickness "0.4pt"
separation "3pt"
shadowsize "4pt"
framecolor "black"
backgroundcolor "none"
status open
\begin_layout Plain Layout
\begin_inset Formula
\[
\eta_{i}=\left\{ 0.02,0.03\right\}
\]
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
These, in combination, describe a state topology than can be seen graphically
in figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:State-topology"
plural "false"
caps "false"
noprefix "false"
\end_inset
.
\end_layout
\begin_layout Standard
As previously mentioned, the states are described by 1D continuous probability
density functions (PDF) of a Gaussian profile.
Each has an associated mean and variance as seen below,
\end_layout
\begin_layout Standard
\noindent
\align center
\begin_inset Tabular
\begin_inset Text
\begin_layout Plain Layout
State,
\begin_inset Formula $i$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
1
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
2
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
Mean,
\begin_inset Formula $\mu_{i}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
1.00
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
4.00
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
Variance,
\begin_inset Formula $\varSigma_{i}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
1.44
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.49
\end_layout
\end_inset
|
\end_inset
\end_layout
\begin_layout Standard
Finally, a set of observations from the above model are provided below,
\end_layout
\begin_layout Standard
\noindent
\align center
\begin_inset Formula
\[
\mathcal{O}=\left\{ 3.8,4.2,3.4,-0.4,1.9,3.0,1.6,1.9,5.0\right\}
\]
\end_inset
\end_layout
\begin_layout Standard
These are used as the basis for training the model using the Baum-Welch
algorithm
\begin_inset CommandInset citation
LatexCommand cite
key "standford-hmm-book,pj-h-baum-welch"
literal "false"
\end_inset
, a form of expectation-maximisation.
\end_layout
\begin_layout Section
Implementation
\end_layout
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status open
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Graphics
filename StateTopology.png
lyxscale 50
width 65col%
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
State topology for the specified Markov Model
\begin_inset CommandInset label
LatexCommand label
name "fig:State-topology"
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Plain Layout
\end_layout
\end_inset
\end_layout
\begin_layout Standard
The work was completed using Python
\begin_inset CommandInset citation
LatexCommand cite
key "python"
literal "false"
\end_inset
, Matplotlib
\begin_inset CommandInset citation
LatexCommand cite
key "hunter2007matplotlib"
literal "false"
\end_inset
and the Jupyter notebook
\begin_inset CommandInset citation
LatexCommand cite
key "jupyter"
literal "false"
\end_inset
.
Apart from the standard library, NumPy
\begin_inset CommandInset citation
LatexCommand cite
key "numpy"
literal "false"
\end_inset
was used for a n-dimensional array implementation.
An implementation of the Gaussian function
\begin_inset CommandInset citation
LatexCommand cite
key "wolfram-gaussian"
literal "false"
\end_inset
was written in order to derive output probability densities for each state
given an observation, see listing
\begin_inset CommandInset ref
LatexCommand ref
reference "maths-listing"
plural "false"
caps "false"
noprefix "false"
\end_inset
.
\end_layout
\begin_layout Standard
The forward and backward procedure are outlined by
\begin_inset CommandInset citation
LatexCommand cite
key "standford-hmm-book,pj-h-forward-backward"
literal "false"
\end_inset
, the algorithm for both forward and backward likelihood can be seen in
figures
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:forward-algorithm"
plural "false"
caps "false"
noprefix "false"
\end_inset
and
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:backward-algorithm"
plural "false"
caps "false"
noprefix "false"
\end_inset
.
Following these procedures, the values were used to calculate the transition
and occupation likelihoods
\begin_inset CommandInset citation
LatexCommand cite
key "standford-hmm-book,pj-h-baum-welch"
literal "false"
\end_inset
as described in figures
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:occupation"
plural "false"
caps "false"
noprefix "false"
\end_inset
and
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:transition"
plural "false"
caps "false"
noprefix "false"
\end_inset
, this constitutes the E-step of the training process
\begin_inset CommandInset citation
LatexCommand cite
key "pj-h-pdf-re-estimate"
literal "false"
\end_inset
.
With all likelihoods calculated, the PDF parameters were re-estimated as
described in figures
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Mean-re-estimate"
plural "false"
caps "false"
noprefix "false"
\end_inset
and
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Variance-re-estimate"
plural "false"
caps "false"
noprefix "false"
\end_inset
, this is one half of the M-step of the training procedure
\begin_inset CommandInset citation
LatexCommand cite
key "pj-h-pdf-re-estimate"
literal "false"
\end_inset
.
\end_layout
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status open
\begin_layout Plain Layout
\begin_inset Box Shadowbox
position "t"
hor_pos "c"
has_inner_box 1
inner_pos "t"
use_parbox 0
use_makebox 0
width "40col%"
special "none"
height "1in"
height_special "totalheight"
thickness "0.4pt"
separation "3pt"
shadowsize "4pt"
framecolor "black"
backgroundcolor "none"
status open
\begin_layout Plain Layout
Initialisation:
\end_layout
\begin_layout Plain Layout
\begin_inset Formula
\[
\alpha_{1}\left(i\right)=\pi_{i}b_{i}\left(o_{1}\right)\qquad1\leq i\leq N
\]
\end_inset
\end_layout
\begin_layout Plain Layout
Iteration:
\end_layout
\begin_layout Plain Layout
\begin_inset Formula
\[
\alpha_{t}\left(j\right)=\left[\sum_{i=1}^{N}\alpha_{t-1}\left(i\right)a_{ij}\right]b_{j}\left(o_{t}\right)\qquad1\leq j\leq N
\]
\end_inset
\end_layout
\begin_layout Plain Layout
Finalise:
\end_layout
\begin_layout Plain Layout
\begin_inset Formula
\[
P\left(\mathcal{O}|\lambda\right)=\sum_{i=1}^{N}\alpha_{T}\left(i\right)\eta_{i}
\]
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Forward procedure
\begin_inset CommandInset citation
LatexCommand cite
key "standford-hmm-book,pj-h-forward-backward"
literal "false"
\end_inset
\begin_inset CommandInset label
LatexCommand label
name "fig:forward-algorithm"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\begin_inset space \hfill{}
\end_inset
\begin_inset Box Shadowbox
position "t"
hor_pos "c"
has_inner_box 1
inner_pos "t"
use_parbox 0
use_makebox 0
width "40col%"
special "none"
height "1in"
height_special "totalheight"
thickness "0.4pt"
separation "3pt"
shadowsize "4pt"
framecolor "black"
backgroundcolor "none"
status open
\begin_layout Plain Layout
Initialisation:
\end_layout
\begin_layout Plain Layout
\begin_inset Formula
\[
\beta_{T}\left(i\right)=\eta_{i}\qquad1\leq i\leq N
\]
\end_inset
\end_layout
\begin_layout Plain Layout
Iteration:
\end_layout
\begin_layout Plain Layout
\begin_inset Formula
\[
\beta_{t}\left(i\right)=\sum_{j=1}^{N}a_{ij}b_{j}\left(o_{t+1}\right)\beta_{t+1}\left(j\right)\qquad1\leq i\leq N
\]
\end_inset
\end_layout
\begin_layout Plain Layout
Finalise:
\end_layout
\begin_layout Plain Layout
\begin_inset Formula
\[
P\left(\mathcal{O}|\lambda\right)=\sum_{i=1}^{N}\pi_{i}b_{i}\left(o_{1}\right)\beta_{1}\left(i\right)
\]
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Backward procedure
\begin_inset CommandInset citation
LatexCommand cite
key "standford-hmm-book,pj-h-forward-backward"
literal "false"
\end_inset
\begin_inset CommandInset label
LatexCommand label
name "fig:backward-algorithm"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status open
\begin_layout Plain Layout
\begin_inset Box Shadowbox
position "t"
hor_pos "c"
has_inner_box 1
inner_pos "t"
use_parbox 0
use_makebox 0
width "40col%"
special "none"
height "1in"
height_special "totalheight"
thickness "0.4pt"
separation "3pt"
shadowsize "4pt"
framecolor "black"
backgroundcolor "none"
status open
\begin_layout Plain Layout
\begin_inset Formula
\[
\gamma_{t}\left(i\right)=P\left(x_{t}=i|\mathcal{O},\lambda\right)
\]
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Formula
\[
\gamma_{t}\left(i\right)=\frac{\alpha_{t}\left(i\right)\beta_{t}\left(i\right)}{P\left(\mathcal{O}|\lambda\right)}
\]
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Occupation likelihood
\begin_inset CommandInset citation
LatexCommand cite
key "standford-hmm-book,pj-h-baum-welch"
literal "false"
\end_inset
\begin_inset CommandInset label
LatexCommand label
name "fig:occupation"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\begin_inset space \hfill{}
\end_inset
\begin_inset Box Shadowbox
position "t"
hor_pos "c"
has_inner_box 1
inner_pos "t"
use_parbox 0
use_makebox 0
width "40col%"
special "none"
height "1in"
height_special "totalheight"
thickness "0.4pt"
separation "3pt"
shadowsize "4pt"
framecolor "black"
backgroundcolor "none"
status open
\begin_layout Plain Layout
\begin_inset Formula
\[
\xi_{t}\left(i,j\right)=P\left(x_{t-1}=i,x_{t}=j|\mathcal{O},\lambda\right)
\]
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Formula
\[
\xi_{t}\left(i,j\right)=\frac{\alpha_{t-1}\left(i\right)a_{ij}b_{j}\left(o_{t}\right)\beta_{t}\left(j\right)}{P\left(\mathcal{O}|\lambda\right)}
\]
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Transition likelihood
\begin_inset CommandInset citation
LatexCommand cite
key "standford-hmm-book,pj-h-baum-welch"
literal "false"
\end_inset
\begin_inset CommandInset label
LatexCommand label
name "fig:transition"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status open
\begin_layout Plain Layout
\begin_inset Box Shadowbox
position "t"
hor_pos "c"
has_inner_box 1
inner_pos "t"
use_parbox 0
use_makebox 0
width "40col%"
special "none"
height "1in"
height_special "totalheight"
thickness "0.4pt"
separation "3pt"
shadowsize "4pt"
framecolor "black"
backgroundcolor "none"
status open
\begin_layout Plain Layout
\begin_inset Formula
\[
\hat{\mu_{i}}=\frac{\sum_{t=1}^{T}\gamma_{t}\left(i\right)o_{t}}{\sum_{t=1}^{T}\gamma_{t}\left(i\right)}
\]
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Mean re-estimation
\begin_inset CommandInset citation
LatexCommand cite
key "pj-h-pdf-re-estimate"
literal "false"
\end_inset
\begin_inset CommandInset label
LatexCommand label
name "fig:Mean-re-estimate"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\begin_inset space \hfill{}
\end_inset
\begin_inset Box Shadowbox
position "t"
hor_pos "c"
has_inner_box 1
inner_pos "t"
use_parbox 0
use_makebox 0
width "40col%"
special "none"
height "1in"
height_special "totalheight"
thickness "0.4pt"
separation "3pt"
shadowsize "4pt"
framecolor "black"
backgroundcolor "none"
status open
\begin_layout Plain Layout
\begin_inset Formula
\[
\hat{\Sigma_{i}}=\frac{\sum_{t=1}^{T}\gamma_{t}\left(i\right)\left(o_{t}-\mu_{i}\right)^{2}}{\sum_{t=1}^{T}\gamma_{t}\left(i\right)}
\]
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Variance re-estimation adapted for uni-variate observations
\begin_inset CommandInset citation
LatexCommand cite
key "pj-h-pdf-re-estimate"
literal "false"
\end_inset
\begin_inset CommandInset label
LatexCommand label
name "fig:Variance-re-estimate"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Plain Layout
\end_layout
\end_inset
\end_layout
\begin_layout Section
Results
\end_layout
\begin_layout Subsection
Output Probability Density Functions
\end_layout
\begin_layout Standard
The Gaussian probability density functions described by the initial parameters
can be seen in figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:PDFs"
plural "false"
caps "false"
noprefix "false"
\end_inset
.
\end_layout
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status open
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Graphics
filename res/pdfs.png
lyxscale 50
width 70col%
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Probability density functions for both states across the observation space
\begin_inset CommandInset label
LatexCommand label
name "fig:PDFs"
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Plain Layout
\end_layout
\end_inset
\end_layout
\begin_layout Subsection
Observation Probability Densities
\end_layout
\begin_layout Standard
The output probability densities for each observation in each state can
be seen in table
\begin_inset CommandInset ref
LatexCommand ref
reference "tab:obs-prob-dens"
plural "false"
caps "false"
noprefix "false"
\end_inset
.
These observations can be seen overlaid on the original PDFs in figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:PDFs-w-obs"
plural "false"
caps "false"
noprefix "false"
\end_inset
.
\end_layout
\begin_layout Standard
\begin_inset Float table
wide false
sideways false
status open
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Tabular
\begin_inset Text
\begin_layout Plain Layout
t
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $o_{t}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $b_{i}\left(o_{t}\right)$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $i=1$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $i=2$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
1
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
3.8
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.022
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.55
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
2
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
4.2
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.0095
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.55
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
3
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
3.4
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.045
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.39
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
4
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
-0.4
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.17
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
1.5
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
5
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
1.9
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.25
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.0063
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
6
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
3.0
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.083
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.21
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
7
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
1.6
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.29
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.0016
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
8
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
1.9
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.25
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.0063
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
9
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
5.0
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.0013
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.21
\end_layout
\end_inset
|
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Probability densities for each observation from each state (2 s.f)
\begin_inset CommandInset label
LatexCommand label
name "tab:obs-prob-dens"
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Plain Layout
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status open
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Graphics
filename res/pdfs-w-obs.png
lyxscale 50
width 70col%
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Previous PDFs (figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:PDFs"
plural "false"
caps "false"
noprefix "false"
\end_inset
) with observations highlighted
\begin_inset CommandInset label
LatexCommand label
name "fig:PDFs-w-obs"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Subsection
Forward Procedure and Likelihoods
\end_layout
\begin_layout Standard
The forward likelihoods calculated as part of the forward procedure can
be seen in figure
\begin_inset CommandInset ref
LatexCommand ref
reference "tab:Forward-likelihoods"
plural "false"
caps "false"
noprefix "false"
\end_inset
.
The natural logarithm of these results can be seen graphically in figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:forward-log-like"
plural "false"
caps "false"
noprefix "false"
\end_inset
.
The log-likelihoods were used here as subsequent original values can decrease
by orders of magnitude making it hard to visualise, as a monotonic function
\begin_inset CommandInset citation
LatexCommand cite
key "pj-h-forward-backward,wolfram-monotone"
literal "false"
\end_inset
, the relationship between values remains relevant when presenting the log
of each value.
\end_layout
\begin_layout Standard
Both states generally decrease over time, however, state 1 has a peak while
state 2 drastically drops around
\begin_inset Formula $t=4$
\end_inset
.
State 1 then finally peaks again at
\begin_inset Formula $t=9$
\end_inset
to finish higher than state 2.
\end_layout
\begin_layout Standard
\begin_inset Float table
wide false
sideways false
status open
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Tabular
\begin_inset Text
\begin_layout Plain Layout
t
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $\alpha_{t}\left(i\right)$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $i=1$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $i=2$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
1
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $9.61\times10^{-3}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.306
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
2
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $2.00\times10^{-4}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.156
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
3
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $2.89\times10^{-4}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.0573
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
4
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $4.31\times10^{-4}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $8.01\times10^{-11}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
5
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $9.95\times10^{-5}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $1.64\times10^{-7}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
6
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $7.59\times10^{-6}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $1.26\times10^{-6}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
7
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $2.06\times10^{-6}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $2.59\times10^{-9}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
8
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $4.76\times10^{-7}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $7.99\times10^{-10}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
9
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $5.63\times10^{-10}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $6.02\times10^{-9}$
\end_inset
\end_layout
\end_inset
|
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Forward likelihoods for each state at each time step
\begin_inset CommandInset label
LatexCommand label
name "tab:Forward-likelihoods"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status open
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Graphics
filename res/forward-logline.png
lyxscale 50
width 70col%
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Forward log-likelihood for each state over all observations
\begin_inset CommandInset label
LatexCommand label
name "fig:forward-log-like"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
Using the forward procedure (figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:forward-algorithm"
plural "false"
caps "false"
noprefix "false"
\end_inset
), the observation likelihood,
\begin_inset Formula $P\left(\mathcal{O}|\lambda\right)$
\end_inset
, was calculated as follows,
\end_layout
\begin_layout Standard
\begin_inset Formula
\[
P\left(\mathcal{O}|\lambda\right)=\eta_{1}\alpha_{9}\left(1\right)+\eta_{2}\alpha_{9}\left(2\right)
\]
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Formula
\begin{equation}
P\left(\mathcal{O}|\lambda\right)=\left(0.02\cdot5.63\times10^{-10}\right)+\left(0.03\cdot6.02\times10^{-9}\right)=1.92\times10^{-10}\label{eq:forward}
\end{equation}
\end_inset
to 2 decimal places.
\end_layout
\begin_layout Subsection
Backward Procedure and Likelihoods
\end_layout
\begin_layout Standard
The backward likelihoods were calculated as part of the backwards procedure
and can be seen in table
\begin_inset CommandInset ref
LatexCommand ref
reference "tab:Backward-likelihoods"
plural "false"
caps "false"
noprefix "false"
\end_inset
, the log-likelihoods can be seen in figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:backward-log-like"
plural "false"
caps "false"
noprefix "false"
\end_inset
.
Reading backwards in time (from bottom to top), for both states the backwards
likelihood can be seen to decrease to a minimum at
\begin_inset Formula $t=1$
\end_inset
.
\end_layout
\begin_layout Standard
\begin_inset Float table
wide false
sideways false
status open
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Tabular
\begin_inset Text
\begin_layout Plain Layout
t
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $\beta_{t}\left(i\right)$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $i=1$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $i=2$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
1
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $6.58\times10^{-11}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $6.25\times10^{-10}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
2
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $2.93\times10^{-9}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $1.23\times10^{-9}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
3
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $6.90\times10^{-8}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $3.00\times10^{-9}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
4
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $4.45\times10^{-7}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $2.11\times10^{-8}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
5
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $1.93\times10^{-6}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $3.02\times10^{-7}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
6
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $2.51\times10^{-5}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $1.15\times10^{-6}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
7
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $9.30\times10^{-5}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $3.77\times10^{-5}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
8
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $3.93\times10^{-4}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $5.73\times10^{-3}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
9
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.02
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.03
\end_layout
\end_inset
|
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Backward likelihoods for each state at each time step
\begin_inset CommandInset label
LatexCommand label
name "tab:Backward-likelihoods"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status open
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Graphics
filename res/backward-logline.png
lyxscale 50
width 70col%
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Backward log-likelihood for each state over all observations
\begin_inset CommandInset label
LatexCommand label
name "fig:backward-log-like"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
Finalising the backward procedure can also produce
\begin_inset Formula $P\left(\mathcal{O}|\lambda\right)$
\end_inset
,
\end_layout
\begin_layout Standard
\begin_inset Formula
\[
P\left(\mathcal{O}|\lambda\right)=\pi_{1}b_{1}\left(o_{1}\right)\beta_{1}\left(1\right)+\pi_{2}b_{2}\left(o_{1}\right)\beta_{1}\left(2\right)
\]
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Formula
\[
P\left(\mathcal{O}|\lambda\right)=\left(0.44\cdot0.022\cdot6.58\times10^{-11}\right)+\left(0.56\cdot0.55\cdot6.25\times10^{-10}\right)=1.92\times10^{-10}
\]
\end_inset
to 2 decimal places.
Looking back to equation
\begin_inset CommandInset ref
LatexCommand ref
reference "eq:forward"
plural "false"
caps "false"
noprefix "false"
\end_inset
, these can be seen to be the same, as expected.
\end_layout
\begin_layout Subsection
Occupation Likelihoods
\end_layout
\begin_layout Standard
The above forward and backward likelihoods were used to calculate the occupation
likelihoods of each state at each time step, the results can be seen in
table
\begin_inset CommandInset ref
LatexCommand ref
reference "tab:Occupation-likelihoods"
plural "false"
caps "false"
noprefix "false"
\end_inset
and are visualised in figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:occupation-likelihood-bars"
plural "false"
caps "false"
noprefix "false"
\end_inset
.
\end_layout
\begin_layout Standard
\begin_inset Float table
wide false
sideways false
status open
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Tabular
\begin_inset Text
\begin_layout Plain Layout
t
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $\gamma_{t}\left(i\right)$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $i=1$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $i=2$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
1
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.003295
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.9967
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
2
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.003055
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.9969
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
3
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.1040
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.8960
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
4
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.9999...
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $8.818\times10^{-9}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
5
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.9997
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.0002579
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
6
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.9925
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.007517
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
7
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.9995
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.0005095
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
8
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.9761
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.02386
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
9
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.05868
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.9413
\end_layout
\end_inset
|
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Occupation likelihoods for each state at each time step (4 s.f.)
\begin_inset CommandInset label
LatexCommand label
name "tab:Occupation-likelihoods"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status open
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Graphics
filename res/occupation-line.png
lyxscale 50
width 70col%
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Occupation likelihoods for each state for each observation
\begin_inset CommandInset label
LatexCommand label
name "fig:occupation-likelihood-bars"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Subsection
Re-estimated Output Parameters
\end_layout
\begin_layout Standard
Following one iteration of Baum-Welch training, the output Gaussian parameters
were re-estimated as follows (2 d.p.),
\end_layout
\begin_layout Standard
\noindent
\align center
\begin_inset Tabular
\begin_inset Text
\begin_layout Plain Layout
State,
\begin_inset Formula $i$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
1
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
2
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
Mean,
\begin_inset Formula $\mu_{i}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
1.67
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
4.09
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
Variance,
\begin_inset Formula $\varSigma_{i}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
1.85
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
0.38
\end_layout
\end_inset
|
\end_inset
\end_layout
\begin_layout Standard
This represents the following deltas from the original parameters (2 s.f.),
\end_layout
\begin_layout Standard
\noindent
\align center
\begin_inset Tabular
\begin_inset Text
\begin_layout Plain Layout
State,
\begin_inset Formula $i$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
1
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
2
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
Mean,
\begin_inset Formula $\mu_{i}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
+0.67
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
+0.089
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
Variance,
\begin_inset Formula $\varSigma_{i}$
\end_inset
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
+0.41
\end_layout
\end_inset
|
\begin_inset Text
\begin_layout Plain Layout
-0.11
\end_layout
\end_inset
|
\end_inset
\end_layout
\begin_layout Standard
Displayed graphically, these two sets of Gaussian functions can be seen
in figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Re-estimated-PDFs"
plural "false"
caps "false"
noprefix "false"
\end_inset
.
Compared to the original function, increasing the standard deviation has
widened and shortened the new function for state 1.
The slight increase in mean has also shifted the function to the right.
For state 2, the new function has a tighter, taller distribution as a result
of the decreased variance; the mean has, again, slightly increased.
\end_layout
\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status open
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Graphics
filename res/re-est-pdfs.png
lyxscale 50
width 70col%
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
Probability density functions following re-estimation of parameters
\begin_inset CommandInset label
LatexCommand label
name "fig:Re-estimated-PDFs"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Section
Discussion
\end_layout
\begin_layout Standard
From the occupation likelihoods, the state sequence for the training data
is suggested to be as follows,
\end_layout
\begin_layout Standard
\begin_inset Formula
\[
S=\left\{ 2,2,2,1,1,1,1,1,2\right\}
\]
\end_inset
\end_layout
\begin_layout Standard
Interestingly, when comparing the occupation likelihoods to each observation's
probability density (P.D), the majority are in alignment, that is, the state
with the highest occupation likelihood also has the higher P.D per observation.
This is not the case for
\begin_inset Formula $o_{6}=3.0$
\end_inset
where, despite state 2 having a higher output P.D, the occupation likelihoods
would in fact suggest that this was emitted from state 1.
This would be a result of the model topology and relative transition likelihood
s, the probability that the state alternates is low (6% and 4%).
\end_layout
\begin_layout Section
Conclusion
\end_layout
\begin_layout Standard
An analysis of hidden Markov models has been demonstrated with a single
iteration of Baum-Welch training providing new parameter estimations.
The forward and backward procedures were demonstrated and confirmed to
produce the same observation likelihood.
The occupation likelihoods were calculated and used to provide a suggestion
to the state sequence for the observations.
Finally, new output parameters were estimated and compared to the originals.
\end_layout
\begin_layout Standard
\begin_inset Newpage newpage
\end_inset
\end_layout
\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "sec:bibliography"
\end_inset
\begin_inset CommandInset bibtex
LatexCommand bibtex
btprint "btPrintCited"
bibfiles "references"
options "bibtotoc"
\end_inset
\end_layout
\begin_layout Section
\start_of_appendix
Source Code
\end_layout
\begin_layout Standard
\begin_inset CommandInset include
LatexCommand lstinputlisting
filename "../constants.py"
lstparams "caption={Constants file defining initial state transition probabilities and PDF parameters},label={constants-listing}"
\end_inset
\end_layout
\begin_layout Standard
\begin_inset CommandInset include
LatexCommand lstinputlisting
filename "../maths.py"
lstparams "caption={Maths utility file with definition for a gaussian},label={maths-listing}"
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Newpage newpage
\end_inset
\end_layout
\begin_layout Standard
\begin_inset CommandInset include
LatexCommand lstinputlisting
filename "../markov.py"
lstparams "caption={Markov model object defining forward and backward procedure, occupation likelihoods, Baum-Welch equations},label={markov-listing}"
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Newpage newpage
\end_inset
\end_layout
\begin_layout Standard
The development of the model behind this report was completed using Jupyter
Notebook.
The used notebook can be seen formatted in plain text below, the relevant
mark scheme elements are referenced in brackets (%%= cell delimiter).
\end_layout
\begin_layout Standard
\begin_inset CommandInset include
LatexCommand lstinputlisting
filename "../notebook.py"
lstparams "commentstyle={\\large\\bfseries\\color{commentgreen}},caption={Plain output of Jupyter Notebook used for development and debugging},label={notebook-listing}"
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Newpage newpage
\end_inset
\end_layout
\begin_layout Section
Extensions
\end_layout
\begin_layout Standard
Figure
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:5-training-iterations"
plural "false"
caps "false"
noprefix "false"
\end_inset
shows how the output probability density functions move during 50 iterations
of training.
State 1's output function can be seen to spread out (increasing variance)
and shift slightly to the right (increasing mean).
State 2's mean begins by increasing before decreasing below the initial
value.
The variance also decreases, tightening the function.
\end_layout
\begin_layout Standard
\begin_inset Float figure
placement h
wide false
sideways false
status open
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Graphics
filename res/iterated-pdfs.png
lyxscale 50
width 70col%
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
5 iterations of training completed using the Baum-Welch equations
\begin_inset CommandInset label
LatexCommand label
name "fig:5-training-iterations"
\end_inset
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\end_body
\end_document