Commit fc20063a authored by Azat Garifullin's avatar Azat Garifullin
Browse files

fixed mean sampling + docs

parent 52f59592
No preview for this file type
No preview for this file type
File added
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
TEX_DIR=$SCRIPT_DIR/texs
FIG_DIR=$SCRIPT_DIR/../figs/
BUILD_DIR=$SCRIPT_DIR/.rep_build/
doc_name=$1
bib_name=$2
set -e
mkdir -p $BUILD_DIR
cp -r $TEX_DIR $BUILD_DIR
cp -r $FIG_DIR $BUILD_DIR/texs/
cd $BUILD_DIR/texs
pdflatex ${doc_name}.tex
if [ -z "$bib_name" ]
then
echo "no bib provided"
else
bibtex $doc_name
fi
pdflatex ${doc_name}.tex
pdflatex ${doc_name}.tex
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$SCRIPT_DIR/${doc_name}.pdf ${doc_name}.pdf
rm -rf $BUILD_DIR
# rm $SCRIPT_DIR/paper.pdf
\ No newline at end of file
#!/bin/bash
./make_doc.sh "matern_mcmc"
\ No newline at end of file
\documentclass[a4paper,runningheads]{article}
\usepackage{lineno,hyperref}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{amsmath, amssymb}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage[paperwidth=210mm,paperheight=297mm]{geometry}
\usepackage{enumitem}
\usepackage{mathtools}
\renewcommand\UrlFont{\color{blue}\rmfamily}
\DeclareMathOperator{\E}{\mathbb{E}}
\DeclareMathOperator{\diag}{diag}
\DeclareMathOperator{\sign}{sign}
\DeclareMathOperator*{\argmin}{arg\,min}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}
\DeclarePairedDelimiterX{\inp}[2]{\langle}{\rangle}{#1, #2}
\DeclarePairedDelimiterX{\infdivx}[2]{(}{)}{%
#1\;\delimsize\|\;#2%
}
\newcommand{\infdiv}{\infdivx}
\newcommand\iids{\overset{\text{iid}}{\sim}}
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\newcommand\numberthis{\addtocounter{equation}{1}\tag{\theequation}}
\newcommand{\Var}{\mathrm{Var}}
\newcommand{\Cov}{\mathrm{Cov}}
\newcommand\given[1][]{\:#1\vert\:}
\newcommand*\mean[1]{\bar{#1}}
% Simple notes for commenting the manuscript
\usepackage{color}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\title{MCMC Sampling of Mat\'{e}rn fields}
%\titlerunning{AV uncertainty}
\author{Azat Garifullin}
%
\maketitle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Sampling Mat\'{e}rn fields}
Let's consider a model:
\begin{gather}
\mathbf{y} = \mathbf{z}(\mathbf{x}\ + \epsilon), \\
\epsilon \sim \mathcal{N}(0, \sigma_{\epsilon}^2), \\
\mathbf{z} \sim \mathcal{GP}\left(0, \mathcal{K}_{\theta}\right),
\label{eq:basic-model}
\end{gather}
where \(\mathbf{y}\) is an observed field, \(\mathbf{z}\) is a hidden field, and
\(\mathcal{K}\) is a Mat\'{e}rn covariance function with parameters \(\theta\).
\begin{figure}
\centerline{
\subfloat[]{\includegraphics[width=0.30\textwidth]{k_smooth_05_cov_mtx}}
\hfil
\subfloat[]{\includegraphics[width=0.30\textwidth]{k_smooth_1_cov_mtx}}
\hfil
\subfloat[]{\includegraphics[width=0.30\textwidth]{k_smooth_2_cov_mtx}}
}
\caption{Calculated Mat\'{e}rn covariance matrices for (a) \( \nu = 0.5 \);
(b) \( \nu = 1 \); (c) \( \nu = 2.5 \). For all three \( \sigma = 1 \)
and \( l = 2 \).}
\label{fig:covs}
\end{figure}
\begin{figure}
\captionsetup[subfigure]{labelformat=empty}
\subfloat[]{\includegraphics[width=0.30\textwidth]{k_smooth_05_0}}
\hfil
\subfloat[]{\includegraphics[width=0.30\textwidth]{k_smooth_05_1}}
\hfil
\subfloat[]{\includegraphics[width=0.30\textwidth]{k_smooth_05_2}}
\\
\subfloat[]{\includegraphics[width=0.30\textwidth]{k_smooth_1_0}}
\hfil
\subfloat[]{\includegraphics[width=0.30\textwidth]{k_smooth_1_1}}
\hfil
\subfloat[]{\includegraphics[width=0.30\textwidth]{k_smooth_1_2}}
\\
\subfloat[]{\includegraphics[width=0.30\textwidth]{k_smooth_2_0}}
\hfil
\subfloat[]{\includegraphics[width=0.30\textwidth]{k_smooth_2_1}}
\hfil
\subfloat[]{\includegraphics[width=0.30\textwidth]{k_smooth_2_2}}
\caption{Sampled Mat\'{e}rn dields for rows: \( \nu = 0.5 \),
\( \nu = 1 \), \( \nu = 2.5 \). For all samples \( \sigma = 1 \)
and \( l = 2 \).}
\label{fig:samples}
\end{figure}
\section{Metropolis-within-Gibbs}
The goal is to estimate the hidden field given the observations. The joint posterior is
defined as:
\begin{align}
p \left( \mathbf{z}, \theta \given \mathbf{y} \right) &=
p \left( \mathbf{z} \given \mathbf{y}, \theta \right)
p \left( \theta \given \mathbf{y} \right), \\
p \left( \mathbf{z} \given \mathbf{y}, \theta \right) &\propto
p \left( \mathbf{y} \given \mathbf{z}, \theta \right)
p \left( \mathbf{z} \given \theta \right),
\end{align}
where the conditional posterior is:
\begin{equation}
p \left( \mathbf{z} \given \mathbf{y}, \theta \right) =
\mathcal{N}\left(
\mathbf{C}_{\theta}
\left( \mathbf{C}_{\theta} + \sigma_{\epsilon}^2 \mathbf{I} \right)^{-1}
\mathbf{y},
\mathbf{C}_{\theta} - \mathbf{C}_{\theta}
\left( \mathbf{C}_{\theta} + \sigma_{\epsilon}^2 \mathbf{I} \right)^{-1}
\mathbf{C}_{\theta}
\right), \\
\end{equation}
and the factorisation of the parameters posterior
\begin{align}
p \left( \theta \given \mathbf{y}, \mathbf{z} \right) &\propto
p \left( \mathbf{y}, \mathbf{z} \given \theta \right)
p \left( \theta \right) \\
&\propto
p \left( \mathbf{y} \given \mathbf{z}, \theta \right)
p \left( \mathbf{z} \given \theta \right)
p \left( \theta \right),
\label{eq:theta-post}
\end{align}
with neg-log posterior rewritten as:
\begin{align}
-\log p \left( \theta \given \mathbf{y}, \mathbf{z} \right) &=
\mathcal{L} ( \mathbf{y} \given \mathbf{z}, \theta ) +
\mathcal{R} ( \mathbf{z} \given \theta ),
\\
\mathcal{L} ( \mathbf{y} \given \mathbf{z}, \theta ) &=
\norm{\mathbf{y} - \mathbf{z}}_{\sigma_{\epsilon}^2\mathbf{I}},
\\
\mathcal{R} ( \mathbf{z} \given \theta ) &=
\norm{\mathbf{z}}_{\mathbf{C}_{\theta}} +
2 \sum_{n} \log \mathbf{L}_{n, n},
\\
\mathbf{C}_{\theta} &= \mathbf{L}\mathbf{L}^T.
\label{eq:theta-nl-post}
\end{align}
The joint sampling then consists of the following steps:
\begin{itemize}
\item Sample the parameters:
\begin{align}
\theta &= \exp \mathbf{s}^{t + 1}, \\
\mathbf{s}^{t + 1} &= \mathbf{s}^{t} + \sqrt{\Sigma_{p}} \delta, \\
\delta &\sim \mathcal{N}(0, \mathbf{I})
\end{align}
\item Sample the field given the proposed \(\theta\):
\begin{align}
\mathbf{z}^{t + 1} &= \mu_{\mathbf{z}} + \mathbf{L}_{\mathbf{z}} \mathbf{n}, \\
\mu_{\mathbf{z}} &=
\mathbf{C}_{\theta}
\left( \mathbf{C}_{\theta} + \sigma_{\epsilon}^2 \mathbf{I} \right)^{-1}
\mathbf{y},
\\
\mathbf{C}_{\mathbf{z}} &=
\mathbf{C}_{\theta} - \mathbf{C}_{\theta}
\left( \mathbf{C}_{\theta} + \sigma_{\epsilon}^2 \mathbf{I} \right)^{-1}
\mathbf{C}_{\theta},
\\
\mathbf{L}_{\mathbf{z}}\mathbf{L}_{\mathbf{z}}^{T} &= \mathbf{C}_{\mathbf{z}}
\end{align},
\item Evaluate posterior according to \eqref{eq:theta-post} and \eqref{eq:theta-nl-post}
\item Accept the parameters according to Metropolis formula.
\end{itemize}
The trivial extension for cloud modeling affects \eqref{eq:basic-model}:
\begin{equation}
\mathbf{y} = \mathbf{M} \circ \mathbf{z}(\mathbf{x}\ + \epsilon),
\end{equation}
where \(\mathbf{M} \circ \mathbf{z}\) is an Hadamard product of the hidden field
and a priori known mask describing clouds. \(\mathbf{M}\) contains ones where the
observations are available and zeros otherwise.
The modified likelihood in \eqref{eq:theta-nl-post} then is:
\begin{equation}
\mathcal{L} ( \mathbf{y} \given \mathbf{z}, \theta ) =
\norm{
\mathbf{M} \circ (\mathbf{y} - \mathbf{z})
}_{\sigma_{\epsilon}^2\mathbf{I}}
\end{equation}
\section{Dummy chain running}
\section{Dummy chain running with clouds}
\end{document}
\ No newline at end of file
figs/dist_mtx.png

477 KB | W: | H:

figs/dist_mtx.png

89.9 KB | W: | H:

figs/dist_mtx.png
figs/dist_mtx.png
figs/dist_mtx.png
figs/dist_mtx.png
  • 2-up
  • Swipe
  • Onion skin
figs/k_smooth_05_0.png

17.9 KB | W: | H:

figs/k_smooth_05_0.png

14.8 KB | W: | H:

figs/k_smooth_05_0.png
figs/k_smooth_05_0.png
figs/k_smooth_05_0.png
figs/k_smooth_05_0.png
  • 2-up
  • Swipe
  • Onion skin
figs/k_smooth_05_1.png

17.2 KB | W: | H:

figs/k_smooth_05_1.png

15.4 KB | W: | H:

figs/k_smooth_05_1.png
figs/k_smooth_05_1.png
figs/k_smooth_05_1.png
figs/k_smooth_05_1.png
  • 2-up
  • Swipe
  • Onion skin
figs/k_smooth_05_2.png

17.7 KB | W: | H:

figs/k_smooth_05_2.png

17.9 KB | W: | H:

figs/k_smooth_05_2.png
figs/k_smooth_05_2.png
figs/k_smooth_05_2.png
figs/k_smooth_05_2.png
  • 2-up
  • Swipe
  • Onion skin
figs/k_smooth_05_cov_mtx.png

183 KB | W: | H:

figs/k_smooth_05_cov_mtx.png

101 KB | W: | H:

figs/k_smooth_05_cov_mtx.png
figs/k_smooth_05_cov_mtx.png
figs/k_smooth_05_cov_mtx.png
figs/k_smooth_05_cov_mtx.png
  • 2-up
  • Swipe
  • Onion skin
figs/k_smooth_1_0.png

17.3 KB | W: | H:

figs/k_smooth_1_0.png

14.7 KB | W: | H:

figs/k_smooth_1_0.png
figs/k_smooth_1_0.png
figs/k_smooth_1_0.png
figs/k_smooth_1_0.png
  • 2-up
  • Swipe
  • Onion skin
figs/k_smooth_1_1.png

19.1 KB | W: | H:

figs/k_smooth_1_1.png

15.3 KB | W: | H:

figs/k_smooth_1_1.png
figs/k_smooth_1_1.png
figs/k_smooth_1_1.png
figs/k_smooth_1_1.png
  • 2-up
  • Swipe
  • Onion skin
figs/k_smooth_1_2.png

20.4 KB | W: | H:

figs/k_smooth_1_2.png

17.8 KB | W: | H:

figs/k_smooth_1_2.png
figs/k_smooth_1_2.png
figs/k_smooth_1_2.png
figs/k_smooth_1_2.png
  • 2-up
  • Swipe
  • Onion skin
figs/k_smooth_1_cov_mtx.png

191 KB | W: | H:

figs/k_smooth_1_cov_mtx.png

104 KB | W: | H:

figs/k_smooth_1_cov_mtx.png
figs/k_smooth_1_cov_mtx.png
figs/k_smooth_1_cov_mtx.png
figs/k_smooth_1_cov_mtx.png
  • 2-up
  • Swipe
  • Onion skin
figs/k_smooth_2_0.png

20.6 KB | W: | H:

figs/k_smooth_2_0.png

14.9 KB | W: | H:

figs/k_smooth_2_0.png
figs/k_smooth_2_0.png
figs/k_smooth_2_0.png
figs/k_smooth_2_0.png
  • 2-up
  • Swipe
  • Onion skin
figs/k_smooth_2_1.png

18 KB | W: | H:

figs/k_smooth_2_1.png

15 KB | W: | H:

figs/k_smooth_2_1.png
figs/k_smooth_2_1.png
figs/k_smooth_2_1.png
figs/k_smooth_2_1.png
  • 2-up
  • Swipe
  • Onion skin
figs/k_smooth_2_2.png

18.6 KB | W: | H:

figs/k_smooth_2_2.png

17.2 KB | W: | H:

figs/k_smooth_2_2.png
figs/k_smooth_2_2.png
figs/k_smooth_2_2.png
figs/k_smooth_2_2.png
  • 2-up
  • Swipe
  • Onion skin
figs/k_smooth_2_cov_mtx.png

191 KB | W: | H:

figs/k_smooth_2_cov_mtx.png

112 KB | W: | H:

figs/k_smooth_2_cov_mtx.png
figs/k_smooth_2_cov_mtx.png
figs/k_smooth_2_cov_mtx.png
figs/k_smooth_2_cov_mtx.png
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment