Machine Learning for Inverse Problems and Data Assimilation

Extracted source text · arXiv 2410.10523

\documentclass[11pt,reqno,twoside]{book}









\usepackage{cmap} %

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{placeins}

\usepackage{verbatim}

\usepackage[utf8]{inputenc}
\usepackage{imakeidx}
\makeindex[columns=2, title=Alphabetical Index, 
           options= -s example_style.ist]
           \usepackage[nottoc]{tocbibind}
           
           



\usepackage{setspace}

\let\counterwithout\relax     %
\let\counterwithin\relax  %
\usepackage{lmodern} %
\usepackage[scale=0.88]{tgheros} %


\newcommand\hmmax{2} %
\newcommand\bmmax{2} %

\usepackage{bm} %
\providecommand{\mathbold}[1]{\bm{#1}}

\usepackage{bbold}

\usepackage{amsmath,amsbsy,amsgen,amscd,amsthm,amsfonts,amssymb,thmtools} 

\usepackage[centering,top=1.5in,bottom=1.2in,left=1.4in,right=1.4in]{geometry}

\usepackage{titling}
\usepackage{musicography}
\setlength{\droptitle}{-7.5em}


\usepackage[sf,bf,compact]{titlesec}

\usepackage{booktabs,longtable,tabu} %
\setlength{\tabulinesep}{1mm}
\usepackage[font=small,margin=12pt,labelfont={sf,bf},labelsep={space}]{caption}


\usepackage{enumitem}
\setitemize{itemsep=0pt} 
\setenumerate{itemsep=0pt}
\setlist[1]{labelindent=\parindent,%
 }

\usepackage{tikz}


\renewcommand{\nabla}{D}
\newcommand{\qf}{\mathfrak{q}}
\newcommand{\su}{\mathsf{u}}
\newcommand{\sy}{\mathsf{u}}
\newcommand{\dt}{|_{\rm det}}
\newcommand{\ff}{q}
\newcommand{\mG}{\mathsf{G}}
\newcommand{\vd}{v^{\dagger}}
\newcommand{\yd}{y^{\dagger}}
\newcommand{\xid}{\xi^{\dagger}}
\newcommand{\etad}{\eta^{\dagger}}
\newcommand{\vdm}{v^{\dagger\,(m)}}
\newcommand{\ydm}{y^{\dagger\,(m)}}
\newcommand{\xidm}{\xi^{\dagger\,(m)}}
\newcommand{\etadm}{\eta^{\dagger\,(m)}}
\newcommand{\Yd}{Y^{\dagger}}
\newcommand{\Vd}{V^{\dagger}}
\newcommand{\Vs}{V^{\star}}
\newcommand{\vs}{v^{\star}}
\newcommand{\Ks}{\mathsf{K}}
\newcommand{\Gammas}{\mathsf{\Gamma}}
\newcommand{\Sigmas}{\mathsf{\Sigma}}
\newcommand{\Hs}{\mathsf{H}}
\newcommand{\ks}{\mathsf{k}}
\newcommand{\CRPS}{\mathsf{CRPS}}
\newcommand{\ES}{\mathsf{ES}}
\newcommand{\QS}{\mathsf{QS}}
\newcommand{\LS}{\mathsf{LS}}
\newcommand{\Id}{\mathrm{Id}}
\newcommand{\mS}{\mathsf{S}}
\newcommand{\hs}{\mathsf{h}}
\newcommand{\hC}{\hat{C}}
\newcommand{\hv}{\hat{v}}

\newcommand{\pie}{\pi^{\textrm{EnKF}}}
\newcommand{\pip}{\pi^{\textrm{PF}}}
\newcommand{\pop}{\pi^{\textrm{OPF}}}
\newcommand{\pir}{\pi^{\textrm{RPF}}}
\newcommand{\por}{\pi^{\textrm{ROPF}}}
\newcommand{\pio}{\pi^{\textrm{EOPF}}}
\newcommand{\uupsilon}{\varphi}

\definecolor{dark-gray}{gray}{0.3}
\definecolor{dkgray}{rgb}{.4,.4,.4}
\definecolor{dkblue}{rgb}{0,0,.5}
\definecolor{dkgreen}{rgb}{0,0.5,.0}
\definecolor{rust}{rgb}{0.5,0.1,0.1}

\newcommand{\eb}[1]{{\color{dkgreen}{#1}}}
\newcommand{\rb}[1]{{\color{dkblue}{#1}}}
\newcommand{\as}[1]{{\color{rust}{#1}}}
\newcommand{\ds}[1]{{\color{orange}{#1}}}

\usepackage{url}
\usepackage[colorlinks=true]{hyperref}
\hypersetup{linkcolor=dkblue}    
\hypersetup{citecolor=rust}      
\hypersetup{urlcolor=rust}     

\usepackage{doi}

\usepackage[final]{microtype} 


\newtheoremstyle{myThm} %
    {\topsep}                    %
    {\topsep}                    %
    {\itshape}                   %
    {}                           %
    {\sffamily\bfseries}                   %
    {.}                          %
    {.5em}                       %
    {}  %

\newtheoremstyle{myRem} %
    {\topsep}                    %
    {\topsep}                    %
    {}                   %
    {}                           %
    {\sffamily}                   %
    {.}                          %
    {.5em}                       %
    {}  %

\newtheoremstyle{myDef} %
    {\topsep}                    %
    {\topsep}                    %
    {}                   %
    {}                           %
    {\sffamily\bfseries}                   %
    {.}                          %
    {.5em}                       %
    {}  %

\theoremstyle{myThm}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{fact}[theorem]{Fact}
\newtheorem{assumption}[theorem]{Assumption}
\newtheorem{dataassumption}[theorem]{Data Assumption}

\theoremstyle{myRem}
\newtheorem{remarkx}[theorem]{Remark}
 \newenvironment{remark}
  {\pushQED{\qed}\renewcommand{\qedsymbol}{$\diamondsuit$}\remarkx}
  {\popQED\endremarkx}

\theoremstyle{myDef}
\newtheorem{definitionx}[theorem]{Definition}
\newenvironment{definition}
  {\pushQED{\qed}\renewcommand{\qedsymbol}{$\diamondsuit$}\definitionx}
  {\popQED\enddefinitionx}


 \newtheorem{examplex}[theorem]{Example}
 \newenvironment{example}
  {\pushQED{\qed}\renewcommand{\qedsymbol}{$\diamondsuit$}\examplex}
  {\popQED\endexamplex}

\usepackage{fancyhdr}
\usepackage{nopageno} %
\fancyhf{} %
\renewcommand{\headrulewidth}{0.5pt} %
\pagestyle{fancy}
\fancyhead[LE,RO]{\textsf{\small \thepage}}

\setlength{\headheight}{14pt}

\let\originalleft\left
\let\originalright\right
\renewcommand{\left}{\mathopen{}\mathclose\bgroup\originalleft}
\renewcommand{\right}{\aftergroup\egroup\originalright}



\usepackage{mathtools}
\mathtoolsset{centercolon}  %



\newcommand{\notate}[1]{\textcolor{red}{\textbf{[#1]}}}

\let\oldphi\phi
\renewcommand{\phi}{\varphi}
\renewcommand{\div}{\mathrm{div}\,}
\newcommand{\eps}{\varepsilon}
\newcommand{\thetas}{\theta^{\star}}
\newcommand{\betas}{\beta^{\star}}
\newcommand{\alphas}{\alpha^{\star}}
\newcommand{\psis}{\psi^{\star}}
\renewcommand{\ss}{s^{\star}}
\newcommand{\ps}{p^{\star}}
\newcommand{\qs}{q^{\star}}
\newcommand{\qfs}{\qf^{\star}}
\newcommand{\ms}{m^{\star}}
\newcommand{\Sigmast}{\Sigma^{\star}}
\newcommand{\gs}{g^{\star}}
\newcommand{\fs}{f^{\star}}
\newcommand{\psn}{\ps^{(n)}}
\newcommand{\pn}{p^{(n)}}
\newcommand{\pist}{\pi^{\star}}


\newcommand{\cnst}[1]{\mathrm{#1}}  
\newcommand{\econst}{\mathrm{e}}

\newcommand{\zerovct}{\vct{0}} %
\newcommand{\onemtx}{\bm{1}}
\newcommand{\zeromtx}{\bm{0}}

\providecommand{\mathbbm}{\mathbb} %

\newcommand{\R}{\mathbbm{R}}
\newcommand{\C}{\mathbbm{C}}
\newcommand{\N}{\mathbbm{N}}
\newcommand{\Z}{\mathbbm{Z}}
\newcommand{\la}{\langle}
\newcommand{\ra}{\rangle}


\newcommand{\grn}{\color{mygreen}}
\definecolor{mygreen}{rgb}{0.1,0.75,0.2}
\newcommand{\nc}{\normalcolor}




\newcommand{\dz}{d_z}
\newcommand{\ttheta}{\vartheta}
\newcommand{\mn}{\Upsilon^{\tiny{{\rm N}}}}
\newcommand{\un}{u^{(n)}}
\newcommand{\UN}{U}
\newcommand{\xn}{x^{(n)}}
\newcommand{\xr}{u^{(r)}}
\newcommand{\yn}{y^{(n)}}
\newcommand{\psid}{\psi^{\dagger}}
\newcommand{\gd}{g^{\dagger}}
\newcommand{\co}{\mathsf{c}}
\newcommand{\dm}{\mathsf{d}}
\newcommand{\Fd}{F^{\dagger}}
\renewcommand{\hm}{H_{\Upsilon}}
\newcommand{\hmn}{H_{\Upsilon^{\tiny{{\rm N}}}}}
\newcommand{\pr}{\rho}
\newcommand{\prg}{\rho_g}
\newcommand{\post}{\pi}
\newcommand{\intp}{\mathfrak{p}}
\newcommand{\postg}{\pi_g}
\newcommand{\postr}{\rho}
\newcommand{\postv}{\varrho}
\newcommand{\Fr}{F_{\postr}}
\newcommand{\Fv}{F_{\postv}}


\newcommand{\noise}{\nu}
\newcommand{\loss}{\mathsf{L}}
\newcommand{\lossd}{\mathsf{L}_{\mbox {\tiny{\rm data}}}}
\newcommand{\lossp}{\mathsf{L}_{\mbox {\tiny{\rm train}}}}
\newcommand{\losss}{\ell}
\newcommand{\like}{\mathsf{l}}
\newcommand{\ELBO}{\mathsf{ELBO}}
\newcommand{\reg}{\mathsf{R}}
\newcommand{\precision}{\Omega}
\newcommand{\V}{V}
\newcommand{\Y}{Y}
\newcommand{\varg}{v}
\newcommand{\qopt}{q_{\text{\sc{opt}}}}
\newcommand{\topt}{\theta_{\text{\sc{opt}}}}
\newcommand{\refT}{\varrho}

\newcommand{\pMC}{\post^N_{\mbox {\tiny{\rm MC}}}}
\newcommand{\prMC}{\pr^N_{\mbox {\tiny{\rm MC}}}}
\newcommand{\ppCN}{\post^N_{\mbox {\tiny{\rm pCN}}}}
\newcommand{\pIS}{\post^N_{\mbox {\tiny{\rm IS}}}}
\newcommand{\pMCMC}{\post^N_{\mbox {\tiny{\rm MCMC}}}}

\newcommand{\mpr}{\hat{m}}
\newcommand{\mpost}{m}
\newcommand{\Cpr}{\hat{C}}
\newcommand{\Cpost}{C}

\newcommand{\Prob}{\operatorname{\mathbbm{P}}}
\newcommand{\Expect}{\operatorname{\mathbb{E}}}
\newcommand{\Sam}{N}
\newcommand{\sam}{n}
\newcommand{\pdfs}{{\mathscr{P}}}
\newcommand{\cE}{\mathcal{E}}


\newcommand{\du}{d}
\newcommand{\dy}{k}
\newcommand{\Ru}{\mathbbm{R}^\du}
\newcommand{\Ry}{\mathbbm{R}^\dy}
\newcommand{\Ruu}{\mathbbm{R}^{\du \times \du}}
\newcommand{\Ryu}{\mathbbm{R}^{\dy \times \du}}
\newcommand{\Ruy}{\mathbbm{R}^{\du \times \dy}}
\newcommand{\Ryy}{\mathbbm{R}^{\dy \times \dy}}

\newcommand{\Gp}{G_{\mathrm{p}}}
\newcommand{\Gs}{G_{\mathrm{c}}}
\newcommand{\Gss}{G_{\mathrm{s}}}


\newcommand{\vct}[1]{{#1}}
\newcommand{\mtx}[1]{{#1}}

\newcommand{\umap}{u_{\mbox {\tiny{\rm MAP}}}}
\newcommand{\upm}{u_{\mbox {\tiny{\rm PM}}}}


\newcommand{\pmh}{p_{\mbox {\tiny{\rm MH}}}}
\newcommand{\pimh}{\pi_{\mbox {\tiny{\rm MH}}}}

\newcommand{\As}{A_{\mbox {\tiny{\rm std}}}}
\newcommand{\Ao}{A_{\mbox {\tiny{\rm opt}}}}

\newcommand{\Gammao}{\Gamma_{\mbox {\tiny{\rm opt}}}}

\newcommand{\pis}{\pi_{\mbox {\tiny{\rm std}}}}

\newcommand{\mus}{\mu_{\mbox {\tiny{\rm std}}}}
\newcommand{\muo}{\mu_{\mbox {\tiny{\rm opt}}}}

\newcommand{\Ko}{K_{\mbox {\tiny{\rm opt}}}}

\newcommand{\Ss}{S_{\mbox {\tiny{\rm std}}}}
\newcommand{\So}{S_{\mbox {\tiny{\rm opt}}}}

\newcommand{\lambdas}{\lambda_{\mbox {\tiny{\rm std}}}}
\newcommand{\lambdao}{\lambda_{\mbox {\tiny{\rm opt}}}}

\newcommand{\rhos}{\rho_{\mbox {\tiny{\rm std}}}}
\newcommand{\rhoo}{\rho_{\mbox {\tiny{\rm opt}}}}

\newcommand{\Sigmao}{\Sigma_{\mbox {\tiny{\rm opt}}}}

\newcommand{\Tr}{\text{Tr}}



\newcommand{\rrho}{\pi}
\newcommand{\mA}{A^{-1}}
\newcommand{\K}{\mathbb{K}}
\newcommand{\Cn}{\mathbb{C}^n}
\newcommand{\cV}{\mathcal V}
\newcommand{\cW}{\mathcal W}
\newcommand{\Rnn}{\bbR^{n \times n}}
\newcommand{\ud}{\mathrm{d}}
\newcommand{\e}{\mathrm{e}}
\newcommand{\loc}{\mathrm{loc}}
\newcommand{\f}{\mathcal{F}}
\newcommand{\g}{\gamma}
\newcommand{\ci}{\mathbf{i}}
\newcommand{\TT}{\mathbb{T}}
\newcommand{\Pb}{\mathbb{P}}
\newcommand{\OP}{\mathbb{P}}
\newcommand{\bn}{{\bf n}}
\newcommand{\bu}{\bar{u}}
\newcommand{\cA}{\mathcal{A}}
\newcommand{\cO}{\mathcal{O}}
\newcommand{\E}{\mathcal{E}}
\newcommand{\cH}{\mathcal{H}}
\newcommand{\cdiv}{\nabla\cdot}
\newcommand{\grad}{\nabla}
\newcommand{\lt}{\left}
\newcommand{\rt}{\right}
\newcommand{\paro}{\partial D}
\newcommand{\ddt}{\frac{\ud}{\ud t}}
\newcommand{\pf}{p_{\phi}}

\newcommand{\kk}{\tiny{\rm K}}
\newcommand{\cN}{\mathcal{N}}
\newcommand{\cL}{\mathcal{L}}
\newcommand{\cX}{\mathcal{X}}
\newcommand{\bbN}{\mathbb{N}}
\newcommand{\bbR}{\mathbb{R}}
\newcommand{\bbZ}{\mathbb{Z}}
\newcommand{\cG}{\mathcal{G}}
\newcommand{\bbP}{\mathbb{P}}
\newcommand{\cP}{\mathcal{P}}
\newcommand{\cQ}{\mathcal{Q}}
\newcommand{\cC}{\mathcal{C}}
\newcommand{\sC}{\mathscr{C}}
\newcommand{\bbE}{\mathbb{E}}

\newcommand{\bigO}{\mathcal{O}}

\newcommand{\dhh}{d_{\mbox {\tiny{\rm Hell}}}}

\newcommand{\ba}{\bar{a}}
\newcommand{\aep}{a^{\epsilon}}

\newcommand{\rank}{\mbox{rank}}
\newcommand{\ind}{\perp\!\!\!\!\perp}



\newcommand{\dkl}{\mathsf{D}_{\mbox {\tiny{\rm KL}}}}
\newcommand{\dwas}{\mathsf{D}_{\mbox {\tiny{\rm W}}}}
\newcommand{\dwasp}{\mathsf{D}_{\mbox {\tiny${\rm W}_p$}}}
\newcommand{\dtv}{\mathsf{D}_{\mbox {\tiny{\rm TV}}}}
\newcommand{\dchi}{\mathsf{D}_{\mbox {\tiny{$ \chi^2$}}}}
\newcommand{\dhell}{\mathsf{D}_{\mbox {\tiny{\rm H}}}}
\newcommand{\dmmd}{\mathsf{D}_{\mbox {\tiny{\rm MMD}}}}
\newcommand{\den}{\mathsf{D}_{\mbox {\tiny{\rm E}}}}
\newcommand{\Nc}{\mathcal{N}}
\newcommand{\D}{\mathsf{D}}
\newcommand{\ha}{h_{\alpha}}
\newcommand{\La}{L_{\alpha,\varrho}}
\newcommand{\qv}{q_{\varrho}}
\newcommand{\qr}{q_{\rho}}

\usepackage[]{algorithm}

\usepackage{graphicx, subfig}
\usepackage{algorithmic}
\usepackage{authblk}
\usepackage[square,numbers]{natbib}
\makeatletter
\makeatother
\usepackage{chngcntr}
\usepackage{mathrsfs}
\counterwithin{table}{chapter}
\counterwithin{algorithm}{chapter}

\title{{\huge\emph{Inverse Problems and Data Assimilation:\\ A Machine Learning Approach}}\\
} %

\author{\vspace{.55in}  Eviatar Bach $^{\musSharp{}\musNatural{}}$, Ricardo Baptista $^{\musSharp{}}$, Daniel Sanz-Alonso $^{\musFlat{}},$ Andrew Stuart $^{\musSharp{}}$\\
	\vspace{.6in} 
 $^{\musSharp{}}$ Caltech \vspace{.05in} 
 \\  $^{\musNatural{}}$ University of Reading\vspace{.05in}
 \\ $^{\musFlat{}}$  University of Chicago}


\vspace{.25in} 

\date{}

\makeatletter\@addtoreset{section}{part}\makeatother%
\numberwithin{equation}{chapter}


\renewcommand{\triangleq}{:=}
\newcommand{\upperRomannumeral}[1]{\uppercase\expandafter{\romannumeral#1}}
\newcommand{\lowerromannumeral}[1]{\romannumeral#1\relax}
\renewcommand{\hat}{\widehat}
\renewcommand{\bar}{\overline}
\newcommand{\Kk}{{\mathcal{K}}}


\newcommand{\bepsilon}{b}
\newcommand{\bgamma}{\sigma}

\newcommand{\An}{{\mathsf{A}}}
\newcommand{\Pred}{{\mathsf{P}}}

\newcommand{\J}{{\mathsf{J}}}
\newcommand{\F}{{\mathsf{F}}}
\newcommand{\I}{{\mathsf{I}}}
\newcommand{\JJ}{{\mathcal{J}}}

\newcommand{\Jtp}{\J_{\mbox {\tiny{\rm TP}}}}
\newcommand{\Jdm}{\J_{\mbox {\tiny{\rm DM}}}}

\newcommand{\Jlm}{\J_{\mbox {\tiny{\rm LM,}}\ell}}
\newcommand{\Jl}{\J_\ell^{\mbox {\tiny{lin}}}}
\newcommand{\Juc}{\J_\ell^{\mbox {\mbox{\tiny{UC} }  }}}
\newcommand{\Jtpl}{\J_{\mbox{\tiny{\rm TP,}}\ell}^{\ell} }
\newcommand{\Jdml}{\J_{\mbox{\tiny{\rm DM,}}\ell}^{\ell} }

\newcommand{\Juctp} {\J_{\mbox {\tiny{\rm TP}},\ell}^{\mbox {\mbox{\tiny{UC} }  }}}
\newcommand{\Jucdm} {\J_{\mbox {\tiny{\rm DM}},\ell}^{\mbox {\mbox{\tiny{UC} }  }}}
\newcommand{\Jucdmn} {\J_{\mbox {\tiny{\rm DM}},\ell}^{(n),\mbox {\mbox{\tiny{UC} }  }}}
\newcommand{\Jtpn}{\J_{\mbox {\tiny{\rm TP}},\ell}^{(n)}}
\newcommand{\Juctpn} {\J_{\mbox {\tiny{\rm TP}},\ell}^{(n),\mbox {\mbox{\tiny{UC} }  }}}

\newcommand{\rtp}{r_{\mbox {\tiny{\rm TP}}}}
\newcommand{\rdm}{r_{\mbox {\tiny{\rm DM}}}}

\newcommand{\uin}{u_\ell^{(n)}}
\newcommand{\yin}{y_\ell^{(n)}}
\newcommand{\vin}{v_\ell^{(n)}}
\newcommand{\xiin}{\xi_\ell^{(n)}}
\newcommand{\zin}{z_\ell^{(n)}}

\newcommand{\Cf}{\mathfrak{C}}
\newcommand{\mf}{\mathfrak{m}}

\newcommand{\NN}{{\footnotesize \text{NN}}}
\newcommand{\EMEnKF}{{\footnotesize \text{EM-EnKF}}}
\newcommand{\LEM}{\mathcal{L}_{\EM}}
\newcommand{\LEMEnKF}{\mathcal{L}_{\EMEnKF}}
\newcommand{\hpost}{\hat{\post}}
\newcommand{\joint}{\gamma}
\newcommand{\marg}{\kappa}

\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}

\newcommand\Armeen[1]{{\color{magenta}Armeen: ``#1''}}



\renewcommand{\theHsection}{\thepart.section.\thesection}


\begin{document}

\maketitle %

\newpage

\input{lectures/Intro}

\newpage \tableofcontents


\part{Inverse Problems}

\input{lectures/IP/formulations}
\input{lectures/IP/variational_inference}
\input{lectures/IP/surrogate_modeling}
\input{lectures/IP/learning_priors}
\input{lectures/IP/learning_transport}
\input{lectures/IP/learning_data_dependence}


\part{Data Assimilation}

\input{lectures/DA/filtering_smoothing}
\input{lectures/DA/learning_parameters}
\input{lectures/DA/learning_gain}
\input{lectures/DA/learning_filter}
\input{lectures/DA/data_driven_forecasts}

\part{Learning Frameworks}
\input{lectures/MachineLearning/metrics}
\input{lectures/MachineLearning/generative_models}
\input{lectures/MachineLearning/supervised_learning}
\input{lectures/MachineLearning/time_series}
\input{lectures/MachineLearning/optimization}

\newpage
\bibliographystyle{abbrvnat} 

\bibliography{references,references_new}

\newpage
\printindex
\end{document}

\section*{\Large{\sffamily{Introduction}}}



\subsection*{Aim and Overview}

The aim of the notes is to demonstrate the potential for
ideas in machine learning to impact on the fields of
inverse problems and data assimilation. The perspective
is one that is primarily aimed at researchers from
inverse problems and/or data assimilation who wish to
see a mathematical presentation of machine learning as it
pertains to their fields. As a by-product of the presentation
we present a succinct mathematical treatment of various
topics in machine learning. The material on machine learning, along with some other related topics, is summarized in
Part III, Appendix. Part I of the notes is concerned with
inverse problems, employing material from Part III;
Part II of the notes is concerned with
data assimilation, employing material from Parts I and III. 





\subsection*{Existing Review Articles}

This is a rapidly evolving research area and there
are already several
articles that review aspects of the material we will cover. See, for example, \cite{arridge2019solving} for uses of ML in inverse problems,
and \cite{bocquet_surrogate_2023,cheng_machine_2023} and Chapter 10 of \cite{chen_stochastic_2023} for uses of ML in data assimilation.


\subsection*{Prerequisites}

Even though the subjects of inverse problems and data assimilation are succinctly reviewed in these notes, there remains an assumption of previous knowledge of these topics. The book \cite{sanz-alonso_inverse_2023} (also available in closely related form on arXiv) provides a good background on these topics, and we have tried to maintain similar notation. These notes also assume familiarity with linear algebra, probability, multivariable calculus, and matrix calculus.

\subsection*{Notation}



Throughout the notes we adopt the following notational conventions:

\begin{itemize}

\item {\bf Sets.} 
$\bbN$ denotes the positive integers $\{1,2,3, \ldots \},$
and
$\bbZ^+ := \bbN \cup \{0\}=\{0,1,2,3, \cdots \}$ denotes the non-negative integers. $\bbR^d$ denotes the set of $d$-dimensional real vectors, and $\bbR^+$ denotes the non-negative reals.
The set $B(u,\delta) \subset \R^d$ denotes
the open ball of radius $\delta$ at $u$ in $\R^d$,
in the Euclidean norm.

\item {\bf Linear Algebra} The symbol $I_\du \in \bbR^{d \times d}$ 
denotes the identity matrix on $\Ru$, and
$\Id$ denotes the identity mapping. We denote the Euclidean norm on $\R^d$ by $|\cdot|$, noting
that it is induced by the inner-product $\langle a ,  b \rangle = a^\top b.$  We also use $|\cdot|$ 
to denote the induced norm on matrices and $|\cdot|_F$ to denote the Frobenius norm.


We say that symmetric matrix $A$
is \index{positive definite}positive definite (resp. positive semi-definite) if $\langle u, Au \rangle$ is positive (resp. non-negative)
for all $u \ne 0$, sometimes denoting this by  $A>0$ (resp. $A \ge 0).$ We let $\bbR^{d \times d}_{\textrm{sym}}$ denote the
subset of symmetric matrices in $\bbR^{d \times d}$ and $\bbR^{d \times d}_{\textrm{sym},>}$ the subset of positive definite symmetric matrices
and $\bbR^{d \times d}$ and $\bbR^{d \times d}_{\textrm{sym},\ge}$ the subset of positive semidefinite symmetric matrices. 
We often wish to use covariance-weighted inner-product and norm and, to this end,
for covariance matrix $A>0,$ we define $|v|_A^2  = v^\top A^{-1} v $.
This norm $|\cdot|_A$ is induced by the weighted Euclidean inner-product 
$\langle \cdot \;,  \; \cdot \rangle_{A}:=\langle \cdot \;, A^{-1}\cdot \rangle.$
The outer product $\otimes$ between two vectors $a,b \in \R^d$ is defined by the following identity,
assumed to hold for all vectors $c \in \R^d:$
$(a \otimes b)c=\langle b,c \rangle a.$ We also use $\otimes$ to denote the Kronecker product between matrices.
We use $\det$ and $\Tr$ to denote the determinant 
and trace functions on matrices. 
We use $\operatorname{vec}(\cdot)$ to denote the vectorization operation on matrices.

\item {\bf Probability} To simplify we mostly consider probability measures which have a 
probability density function (with respect to Lebesgue measure). For this reason
we will blur the distinction between probability measures and probability density
functions. In particular, when a random variable $u$ has probability density function $\rho$ 
we will write $u \sim \rho.$  Occasionally we will need to
employ \index{Dirac delta}Dirac masses. In this context we will
use the notational convention that the \index{Dirac delta}Dirac mass at point $v$
has ``density'' $\delta(\cdot-v)$, also denoted by $\delta_v(\cdot).$


Given probability density function $\rho$, defined on $\R^{\dz}$,
and function $g:\R^{\dz} \to \Ru$, $\rho_g$ denotes the
probability density function of the random variable $g(z)$ where $z \sim \rho.$ 
We refer to $\rho_g$ as
the \emph{pushforward}\index{pushforward} of $\rho$ under $g$ and write 
$\rho_g$ as $g_\sharp \rho.$ 
Formally the pushforward notation $\rho_g = g_\sharp \rho$ means that $\mathbb{P}^{\rho_g}(A) = \mathbb{P}^\rho(g^{-1}(A))$ for any Borel set $A$. 
We note that, in some other texts, the pushforward is denoted by $g\#\rho = \rho_g$ or $g_\star \rho = \rho_g$.


We denote by $\Prob (\cdot), \Prob(\cdot \; | \; \cdot )$ the probability density function of
a random variable and its conditional probability density function, respectively.
When random variables $u$ and $v$ are independent we write $u \ind v.$ 
For jointly varying random variables $(u,v)$ we let $u|v$ denote the distribution
of random variable $u$, given a specific realization of random variable $v.$



Given $f: \Ru \mapsto  \mathbb{R}$ we denote by
$$\Expect^\rho[f]=\int_{\Ru}f(u)\rho(u) \, du$$
the expectation of $f$ with respect to probability density function $\rho$ on $\Ru.$ On occasion, we also denote this expectation by $\rho(f).$
We let $\cP(\R^d)$ denote the space of all probability measures over $\R^d;$ we simply
write $\cP$ if the Euclidean space $\R^d$ is clear.

\item {\bf Calculus} Given function $f:\R^d \to \R$ we denote by $\nabla f: \R^d \to \R^d$ the gradient\index{gradient} 
and by $D^2f: \R^d \to \R^{d \times d}$ the Hessian\index{Hessian}. For more general 
functions $f: \cal{V} \to \R$ acting on elements $v$ of vector space $\cal{V}$
we write $D f$ to denote the derivative. We also directly consider functions 
$f:\R^d \to \R^d$ with Jacobian\index{Jacobian} matrix $Df: \R^d \to \R^{d \times d}.$ When there are two potentially varying arguments and we wish to indicate
differentiation with respect to only one of them, say $v$, we will indicate 
this with a subscript: $D_v$ (and similarly for second derivatives). When we contract a derivative
to obtain divergence we write $\div$: for example, for $f:\R^d \to \R$, ${\rm Tr}\, Df=\div f.$ We use $f\circ g$ to indicate the composition of $f$ and $g$, assuming input dimensions (of $f$) and output dimensions (of $g$) are compatible, allowing composition.
\end{itemize}

\subsection*{Acknowledgments}
EB acknowledges support from Caltech's Foster and Coco Stanback Postdoctoral Fellowship, the Schmidt Foundation, and the support through federal funding provided to AMS. RB also gratefully acknowledges support for the von K\'{a}rm\'{a}n Postdoctoral Instructorship from Caltech and AFOSR MURI programs.
DSA is grateful for the support of DOE and NSF (US) and the BBVA Foundation (Spain).
AMS would like to acknowledge the various US Government Agencies that have 
generously supported research in areas related to these notes:  AFOSR,
ARO, DARPA, DoD, NSF and ONR. 

All the authors thank the students who took ACM270 at Caltech in Spring 2024. The lecture notes for this
course constituted an early draft of these notes. The students' comments and questions have helped to improve them considerably.
The authors are also grateful to Bohan Chen and Jochen Br\"ocker.

\paragraph{Warning and Request}

This is a first draft of these notes. As an early draft the notes are likely to contain mathematical errors, incomplete bibliographical information and citations to the rapidly growing literature, inconsistencies in notation, and typographical errors. The authors would be grateful for all feedback that might help eliminate any of these issues. The authors may be contacted at: Eviatar Bach (\href{mailto:eviatarbach@protonmail.com}{eviatarbach@protonmail.com}), Ricardo Baptista (\href{mailto:rsb@caltech.edu}{rsb@caltech.edu}), Daniel Sanz-Alonso (\href{mailto:sanzalonso@uchicago.edu}{sanzalonso@uchicago.edu}), Andrew Stuart (\href{mailto:astuart@caltech.edu}{astuart@caltech.edu})



\chapter{\Large{\sffamily{Bayesian Inversion}}}
\label{ch1}


A forward model $G: \Ru \to \Ry$ specifies output $y \in \Ry$ from input $u \in \Ru$ by the relationship $y = G(u).$ The related inverse problem is to 
recover unknown parameter\index{parameter} $u \in \Ru$ from data\index{data} 
$y \in \Ry$ defined by
\begin{equation}
\label{eq:jc0}
 y = G(u) + \eta, 
\end{equation}
where $\eta \in \Ry$ denotes \index{observation!noise}observation noise.
In the \index{Bayesian}Bayesian approach to the inverse problem we view $(u,y)$ as 
jointly
varying random variables and the solution of the inverse problem is the \index{posterior}posterior distribution  on  parameter\index{parameter} $u$ 
given a specific instance of the data\index{data} $y.$  
 In Section \ref{sec:11} we formulate \index{Bayesian!inverse problem}Bayesian inverse problems and state Bayes Theorem, giving an explicit expression for the \index{posterior}posterior probability density function. In Section \ref{sec:112} we connect Bayesian inversion to the classical optimization based approach to inverse problems.
 Section \ref{sec:13} describes the \index{well-posed}well-posedness of the \index{Bayesian}Bayesian formulation, using the Hellinger distance
from Chapter \ref{ch:distances}. In Section \ref{sec:ME} we discuss
various perspectives on model error.
Section \ref{sec:14} contains bibliographical remarks.


\section{\index{Bayesian!inversion}Bayesian Inversion}
\label{sec:11}


We view $(u, y ) \in \Ru \times \Ry$ as a random variable, whose distribution is specified by means of the identity \eqref{eq:jc0} and the following assumption on the distribution of $(u,\eta) \in \Ru \times \Ry:$
\begin{assumption}\label{a:jc1}
The random variable $(u,\eta) \in \Ru \times \Ry$ is defined by assuming
that $u \ind \eta$, that $u \sim \pr(u)$ and that $\eta \sim \noise(\eta)$.
\end{assumption}

Combining this assumption with
the relationship between $u,$ $y$ and $\eta$ postulated in equation \eqref{eq:jc0}
we can define the \index{Bayesian!inverse problem}Bayesian inverse problem, a specific and important
subclass of general Bayesian inference\index{inference!Bayesian}.
We refer to $\pr(u)$, the probability density function of $u$, as the \index{prior}\emph{prior} probability density function. Given
identity \eqref{eq:jc0}, then for fixed $u\in \Ru,$ the distribution of $y$ given $u$
defines the \index{likelihood}\emph{likelihood}:
\begin{equation}
\label{eq:like}
y |  u \sim \like(y|u):=\noise\bigl(y - G(u)\bigr).
\end{equation}
The \index{posterior}posterior probability density function is the conditional distribution of $u$ given $y$, that is the distribution of random
variable $u|y$, and is the solution to the Bayesian
formulation of the inverse problem. 

The primary computational challenge associated
with Bayesian inversion is that it is an infinite dimensional problem. In
particular it is important to appreciate that, although 
\index{Bayes theorem}Bayes theorem (which follows) delivers a formula
for the probability density function of $u|y$, the task of obtaining
information from this probability density function, for example by drawing many samples from it, is,
in general, a substantial one.




 \begin{theorem}
\label{t:bayes}
 Let Assumption \ref{a:jc1} hold, assume that $u,y$ and $\eta$ satisfy \eqref{eq:jc0}, and that
\[
 Z = Z(y) :=\int_{\Ru} \noise\bigl( y - G(u)\bigr)\pr(u) \, du  >0.\]
 Then $u | y\sim \post^y(u),$ where\footnote{When there is no possibility of confusion,
we will  simply write $\post(u)$ for  the \index{posterior}posterior probability density function, rather than
$\post^y(u).$}
\begin{equation}\label{eq:bayesformula}
 \post^y(u) = \frac{1}{Z} \noise\bigl(y - G(u)\bigr)\pr(u).
\end{equation}
 \end{theorem}
 \begin{proof}
We denote by $\Prob (\cdot)$ the probability density function of a random variable; and we denote 
by $\Prob(\cdot | \cdot )$ the probability density function conditional on the second argument. 
The standard laws of conditional probability give the two identities
 \[
 \begin{aligned}
 \Prob(u , y) &=  \Prob (u | y) \Prob(y),  \textrm{ if } \Prob(y) > 0 ,\\
 \Prob(u, y) &=  \Prob (y | u ) \Prob(u),  \textrm{ if } \Prob(u) > 0 .\\
\end{aligned}
 \]
The marginal probability density function on $y$ is given by
 \begin{align*}
 \Prob(y) &= \int_{\Ru} \Prob( u, y) \, du  \\
 & = \int_{\Ru} \Prob(y|u) \Prob(u) \, du = Z 
 \end{align*}
and so the assumption that $Z>0$ ensures that the data could indeed have been
obtained from the posulated model. Since $Z>0$ we have, by combining the
two identities above, the desired result
 \begin{equation}
\label{eq:jc1}
 \Prob(u | y) = \frac{1}{\Prob(y) } \Prob(y | u) \Prob(u)   =  \frac{1}{\Prob(y)}\noise\bigl(y - G(u )\bigr) \pr(u).
 \end{equation}
\end{proof}

\begin{remark}
\label{rem:minus1}
We write the density of the 
joint distribution of $(y,u) \in \Ry \times \Ru$ as $\joint(y,u).$
We write the marginal density on $y \in \Ry$ as $\marg(y).$ Note that
$\marg(y)=Z.$
\end{remark}


\begin{remark}
\label{rem:zero}
When $G$ is linear and $(u,\eta)$ is Gaussian then the posterior on $u|y$ 
is Gaussian. This setting provides numerous useful explicitly solvable
inverse problems in which the posterior\index{posterior} is characterized
by its mean and covariance; this reduces the infinite dimensional problem to
a finite dimensional problem for a vector (mean) in $\Ru$ and a symmetric,
positive matrix (covariance) in $\Ruu.$
\end{remark}

\begin{remark}
We have concentrated on formulating Bayes Theorem around equation \eqref{eq:jc0}
in which the noise appears additively. However it is not restricted to this setting.
Section \ref{sec:den} provides an explicit example, going beyond this additive noise setting,
to formulate density estimation in a Bayesian fashion.
\end{remark}

\section{MAP Estimation and \index{optimization}Optimization}
\label{sec:112}

The infinite dimensional
\index{posterior}posterior distribution $\post^y(u)$ contains all knowledge 
about the parameter $u$, given Assumptions \ref{a:jc1} and equation \eqref{eq:jc0}.
It is often useful, however, to extract finite dimensional information from the \index{posterior}posterior distribution which summarizes it. Remark \ref{rem:zero}
identifies a specific situation where 
this finite dimensional summary, along with the fact that the posterior is Gaussian, fully characterize the posterior. In general, however, we must seek finite dimensional summaries that may not fully characterize the posterior.
One natural  summary 
is the \index{posterior}posterior mode or MAP estimator:
\begin{definition}\label{def:map}
A {\em maximum a posteriori (\index{MAP estimator}MAP) estimator} of $u$ given data $y$ is  defined as any point $\umap$ satisfying
	$$\umap \in \argmax_{\vct{u}\in\Ru}\post^{\vct{y}}(\vct{u}).$$
\end{definition}

 
We now show how MAP estimation connects with classical optimization based approaches to inversion.
Recall that the \index{posterior}posterior probability density function $\post^y(u)$ on $u|y$ from \index{Bayes theorem}Theorem \ref{t:bayes} has the form
\[
\post^y (\vct u) = \frac{1}{Z} \noise \bigl(\vct y- \vct G(\vct u)\bigr) \pr (\vct u).
\]
We define a \index{loss}\emph{loss function}
\begin{equation}
\label{eq:loss}
\loss (\vct u) = - \log \noise \bigl(\vct y-\vct G(\vct u)\bigr)= - \log \like(y|u),
\end{equation}
and a \emph{regularizer}\index{regularizer}
\begin{equation}
\label{eq:reg}
\reg(\vct u) = - \log \pr(\vct u).
\end{equation}
Adding the loss function and regularizer we obtain
an \index{objective}\emph{objective function} of the form
\begin{equation}
\label{eq:MAPO}
\J(\vct u) = \loss(\vct u) + \reg(\vct u).
\end{equation}
Furthermore
\[
\post^y (\vct u) = \frac{1}{Z} \noise \bigl(\vct y-\vct G(\vct u)\bigr) \pr (\vct u) \propto e^{-\J(\vct u)}.
\]
Thus the \index{MAP estimator}MAP estimator can be rewritten in terms of $\J$ as follows:
\begin{align*}
\umap & \in \argmax_{\vct{u}\in\Ru}\post^{\vct{y}}(\vct{u}) \\
&= \arg \min_{u \in \Ru} \J(u);
\end{align*} 
minimizing the \index{objective}objective function $\J(\cdot)$
is equivalent to determining a MAP estimator by 
maximizing the \index{posterior}posterior probability density function $\post^y(\cdot)$.

\begin{remark}
 Setting the regularizer to zero, known as choosing a \emph{flat prior}\index{prior!flat},
 we obtain the maximum likelihood estimation (MLE)\index{maximum likelihood estimation}
 problem.
\end{remark}




\begin{example}[Gaussian Observational Noise and Gaussian Prior]
	\label{ex:loss-l2}
	If $\eta = \Nc(\zerovct ,\mtx \Gamma)$, then
	$$\noise\bigl(\vct y-\vct G(\vct u)\bigr) \propto \exp(- \frac{1}{2} |\vct y-\vct G(\vct u)|_{\mtx \Gamma} ^2).$$
Thus in this case the \index{loss}loss is 
$$\loss(\vct u) = \frac{1}{2} |\vct y-\vct G(\vct u)|_{\mtx \Gamma}^2,$$ 
a \(\mtx \Gamma\)-weighted \(\losss_2\) loss.

Now assume that the \index{prior}prior is a centered Gaussian
\(\pr(\vct u) = \Nc(\zerovct ,\mtx \Cpr)\), where $\Cpr$ is positive.  
Ignoring $u$-independent normalization factors, which appear as constant
shifts in $\J(\cdot)$ and therefore can be ignored from the viewpoint of
minimization, we may take the regularizer to be 
$$\reg(\vct u) = \frac{1}{2} |\vct u|_{\mtx \Cpr}^2.$$ 



Combining these assumptions we obtain a canonical \index{objective}objective function 
\begin{equation}
\label{eq:Phillips}
\J(\vct u) = \frac{1}{2} |\vct y-\vct G(\vct u)|_{\mtx \Gamma}^2 + \frac{1}{2} |\vct  u|_{\mtx \Cpr}^2.
\end{equation}
We refer to minimization of \eqref{eq:Phillips}
as the \emph{Tikhonov-Phillips regularized inverse 
problem}\index{inverse problem!Tikhonov-Phillips regularized}.
If $\Gamma \propto \Id$ and $\Cpr=\lambda^{-1} \Gamma$ then this reduces
to the classical \emph{Tikhonov regularized inverse problem} \index{inverse problem!Tikhonov regularized}
with objective function
\begin{equation}
\label{eq:Tikhonov}
\J(\vct u) = \frac{1}{2} |\vct y-\vct G(\vct u)|^2 + \frac{\lambda}{2} |\vct  u|^2.
\end{equation}


Finally we note that if $G(u)=Lu$ for matrix $L \in \Ryu$ then the MAP estimator related
to the Tikhonov-Phillips regularized inverse 
problem\index{inverse problem!Tikhonov-Phillips regularized} is unique and
given by point $m$ solving
\begin{subequations}
\begin{align}
C^{-1}&=\Cpr^{-1}+L^\top \Gamma^{-1}L,\\
C^{-1}m&=L^\top \Gamma^{-1}y.
\end{align}
\end{subequations}
In this case, as discussed in Remark \ref{rem:zero}, the posterior is Gaussian, and in fact
$\post^{\vct{y}}(\vct{u})=\Nc(m ,\mtx C).$ This fact may be seen by completing the
square in the formula for the posterior. We note that the posterior mean, in this linear
Gaussian setting, is equal to the (in this case unique) MAP estimator. 
\end{example}



\begin{example}[\(\losss_1\) Regularizer -- Laplace Prior]
	\label{ex:reg-l1}
Now consider the setting where 	
$$\pr(\vct u) \propto \exp\biggl(-\lambda \sum_{i=1}^\du |u_i| \biggr) = \exp(-\lambda |\vct u|_1).$$
This is known as a Laplace\index{prior!Laplace} 
distribution. Then
\(\reg( \vct u ) = \lambda |\vct u|_1\), an \(\losss_1\) regularizer.
Combining this \index{prior}prior with the weighted \(\losss_2\) \index{loss}loss above,
we obtain the \index{objective}objective function 
$$\J(\vct u) = \frac{1}{2} |\vct y - \vct G ( \vct u ) |_{\mtx \Gamma}^2 + \lambda |\vct u |_1.$$ 
It is well known that regularizers of this type promote sparse solutions when $\J(\cdot)$
is minimized. However it is important to appreciate that samples
from the underlying \index{posterior}posterior distribution are typically not sparse. 
\end{example} 


\section{\index{well-posed}Well-Posedness of \index{Bayesian!inverse problem}Bayesian Inverse Problems}\label{sec:13}

The MAP estimator is an unstable quantity in the following sense: it may change discontinuously with respect to changes in the problem specification, such as the
data $y.$ This is because the minimizer of an objective function is not, in general,
continuous with respect to changes in the objective. Such instability is a general feature
of all optimization based approaches to inversion, unless there is some convexity
built in via the specifics of a particular problem. On the other hand, the Bayesian
formulation of the inverse problem\index{Bayesian!inverse problem} 
leads to stability in broad generality: small changes in the
problem specification lead to small changes in the posterior density. Here
we prove a prototypical result of this type.




We consider two different  \index{likelihood}likelihoods
\[\like(y|u)=\noise\bigl(y-G(u)\bigr)\quad \text{and}\quad \like_\delta(y|u)=\noise\bigl(y-G_\delta(u)\bigr)\]
associated with two different forward models $G(u)$ and $G_\delta(u).$ 
Assuming the associated Bayesian inverse problems both adopt the same prior
$\rho$ we obtain two different posteriors of the form
\[\post^y(u)=\frac{1}{Z}\like(y|u)\pr(u)\quad \text{and}\quad \post_\delta^y(u)=\frac{1}{Z_\delta}\like_\delta(y|u)\pr(u),\]
where $Z, Z_\delta$ are the corresponding normalizing constants. 
Our aim is to show that, if $\like(y|u)$ and  $\like_\delta(y|u)$ are close then
so are the associated posteriors. To this end we make the following assumptions
about the likelihoods, in which we view the data $y$ as fixed.

\begin{assumption}\label{a:dh1}
The data defined by \eqref{eq:jc0} and Assumption \ref{a:dh1} has positive probability under the resulting joint distribution on $(u,y)$, so that $Z>0.$ There exist $\delta^+>0$ and $K_1,K_2<\infty$ such that, for all $\delta\in (0,\delta^+),$ 
	\begin{itemize}
	\item[(i)] $|\sqrt{\like(y|u)} - \sqrt{\like_\delta(y|u)}|\leq \phi(u)\delta$, for some $\phi(u)$ 
satsifying $\Expect^{\pr} [\phi^2(u)] \le K_1^2$;
	\item[(ii)] $\sup_{u\in\Ru}(|\sqrt{\like(y|u)}|+|\sqrt{\like_\delta(y|u)}|) \le K_2.$
	\end{itemize}
\end{assumption}




Recall the Hellinger distance\index{distance!Hellinger} $\dhell(\cdot,\cdot)$ 
from Chapter \ref{ch:distances}. The main result of this section is:

\begin{theorem} 
\label{t:wpz}
Under Assumptions \ref{a:jc1} and \ref{a:dh1}, there exists $c\in(0,+\infty)$
and $\Delta>0$ such that, for all $\delta\in(0,\Delta)$,
      \[\dhell(\post^y,\post_\delta^y)\leq c \delta.\]
\end{theorem}

\begin{remark}
We make two observations about Theorem \ref{t:wpz}:

\begin{itemize}
\item After using Lemma \ref{lemmatv}, the theorem ensures 
that expectations of functions of $u$, with $u$ distributed according
to $\post^y$ and $\post_\delta^y$ respectively,
are order $\delta$ apart, provided sufficient moments of those
functions are available;


\item The theorem is prototypical of a variety of stability results for
Bayesian inversion. Here we have viewed data $y$ as fixed and considered error in the likelihood arising from approximation of the forward model;
in Chapter \ref{ch:fsm} we establish a similar result
in the context of machine learning approximations to the
Bayesian inverse problem where the forward model is replaced by a surrogate.
It is also possible to estimate changes in the posterior, in the Hellinger metric, with respect to changes in the data (which of course changes the
likelihood).
\end{itemize}
\end{remark}

 \begin{proof}[Proof of Theorem \ref{t:wpz}]


 
To prove Theorem \ref{t:wpz}, we first characterize the stability
of the normalization\index{normalization constant} constants.
We show that, under Assumption \ref{a:dh1}, there exist $\Delta>0$ and $c_1,c_2\in(0,+\infty)$ such that 
      \[|Z-Z_\delta|\leq c_1\delta\quad \text{and}\quad Z,Z_\delta>c_2,\quad \text{for}\ \delta\in(0,\Delta).\]
To see this, noting that $Z=\int \like(y|u)\pr(u) \, du$ and
$Z_\delta=\int \like_\delta(y|u)\pr(u) \, du$, 
we have
      \begin{align*}
      |Z-Z_\delta|=& \biggl| \int \bigl(\like(y|u)-\like_\delta(y|u)\bigr)\pr(u) \, du    \biggr|   \\
      \leq&\ \Big(\int \Bigl|\sqrt{\like(y|u)}- \sqrt{\like_\delta(y|u)}\Bigr|^2\pr(u) \, du\Big)^{1/2}\Big(\int \Bigl|\sqrt{\like(y|u)}+\sqrt{\like_\delta(y|u)}\Bigr|^2\pr(u) \, du\Big)^{1/2}\\
      \leq&\ \Big(\int \delta^2 \phi(u)^2\pr(u) \, du\Big)^{1/2}\Big(\int K_2^2\pr(u) \, du\Big)^{1/2}\\
      \leq&\ K_1 K_2\delta,\quad \delta\in(0,\delta^+). 
      \end{align*}
      Therefore, for $\delta\leq \Delta\coloneqq\min\{\frac{Z}{2K_1 K_2},\delta^+\}$, we have
      \[Z_\delta\geq Z-|Z-Z_\delta|\geq \frac{1}{2}Z.\]
      Since $Z$ is assumed positive we deduce the lower bound on $Z_\delta$. and take $c_2=\frac12 Z.$
      The Lipschitz stability result follows follows by taking $c_1=K_1 K_2.$
   
 
      
   We now study the Hellinger distance between the two posteriors, aiming to use
   the preceding estimate on the stability of the normalization constants. To this
   end we break the total error into two contributions, one reflecting
the difference between $Z$ and $Z_\delta$, and the other the difference between $\like$ and $\like_\delta$:
      \begin{align*}
      \dhell(\post^y,\post_\delta^y)=&\ \frac{1}{\sqrt{2}}\Bigl\|\sqrt{\post^y}-\sqrt{\post_\delta^y}\Bigr\|_{L^2}\\
      =&\  \frac{1}{\sqrt{2}}\Bigg\|\sqrt{\frac{\like\pr}{Z}}-\sqrt{\frac{\like\pr}{Z_\delta}}+\sqrt{\frac{\like\pr}{Z_\delta}}-\sqrt{\frac{\like_\delta\pr}{Z_\delta}}\Bigg\|_{L^2}\\
      \leq&\ \frac{1}{\sqrt{2}}\Bigg\|\sqrt{\frac{\like\pr}{Z}}-\sqrt{\frac{\like\pr}{Z_\delta}}\Big\|_{L^2}+\frac{1}{\sqrt{2}}\Big\|\sqrt\frac{\like\pr}{Z_\delta}-\sqrt{\frac{\like_\delta\pr}{Z_\delta}}\Bigg\|_{L^2}.
      \end{align*}
From the stability estimate on the normalization constants we have, 
for $\delta\in(0,\Delta)$, 
      \begin{align*}
      \Bigg\|\sqrt{\frac{\like\pr}{Z}}-\sqrt{\frac{\like\pr}{Z_\delta}}\Bigg\|_{L^2}=&\ \Bigg|\frac{1}{\sqrt{Z}}-\frac{1}{\sqrt{Z_\delta}}\Bigg|\Bigg(\int \like(y|u)\pr(u) \, du\Bigg)^{1/2}\\
      =&\ \frac{|Z-Z_\delta|}{(\sqrt{Z}+\sqrt{Z_\delta})\sqrt{Z_\delta}}\\
      \leq&\ \frac{c_1}{2c_2}\delta,
      \end{align*}
      and 
      \[\Bigg\|\sqrt{\frac{\like\pr}{Z_\delta}} - \sqrt{\frac{\like_\delta\pr}{Z_\delta}}\Bigg\|_{L^2}=\frac{1}{\sqrt{Z_\delta}}\Bigg(\int\Bigl|\sqrt{\like(y|u)}- \sqrt{\like_\delta(y|u)}\Bigr|^2\pr(u) \, du\Bigg)^{1/2} \leq \sqrt{\frac{K_1^2}{c_2}}\delta.\]
      Therefore
      \[\dhell(\post^y,\post_\delta^y)\leq \frac{1}{\sqrt{2}}\frac{c_1}{2c_2}\delta+\frac{1}{\sqrt{2}}\sqrt{\frac{K_1^2}{c_2}}\delta=c \delta,\]
      with $c=\frac{1}{\sqrt{2}}\frac{c_1}{2c_2}+\frac{K_1}{\sqrt{2c_2}}$,
which is independent of $\delta$.
      \end{proof}







      

\section{Model Error}\index{model error}
\label{sec:ME}

The underlying concept behind this entire section is that the data $y$, which we use
to determine unknown parameter $u$, is not actually generated by the identity \eqref{eq:jc0}.
In short the computer code defining forward model $G(\cdot)$ does not exactly represent the physical
reality that gave rise to the data, a situation referred to as model error or model misspecification. 
We describe three approaches to addressing this issue. The starting point for all of them is that the data $y$ arises
from noisy observation of a physical process $\Gp: \Ru \to \Ry$ so that
\begin{equation}
\label{eq:jcKOH}
 y = \Gp(u) + \eta. 
\end{equation}
The assumption is that $\Gp$ is not available to us, but that we have
a (family of) computational model(s) $\Gs$ which we can use in place of
$\Gp$ to determine $u$ from $y.$ 

The three approaches we describe, all used
in the literature, address the issue of 
\emph{model error}\index{model error}: namely addressing the fact that
$\Gs$ does not exactly represent the true physical process $\Gp$ generating
the data. The reader will appreciate that it is also possible to combine\
each of the three approaches to devise more general approaches to model error.

\subsection{Representing Error in Data Space}
\label{ssec:KOH}

This first approach makes the assumption that $\Gp: \Ru \to \Ry$ is related to computer code  $\Gs: \Ru \to \Ry$ in the sense that
\begin{equation}
\label{eq:shift}    
\Gp(u)=\Gs(u)+\bepsilon
\end{equation}
for some unknown vector $\bepsilon \in \Ry$.
Furthermore, random variable $\eta$ is assumed to be drawn from a centered distribution $\nu_\bgamma(\cdot)$, known up to a parameter $\bgamma \in \R^p$.
Thus model error\index{model error} is present both because of the
unknown shift between $\Gp$ and $\Gs$ and because of the unknown parameter
in the distribution of the additive noise.

Rather than just putting a prior $\rho$ on $u$, as in Section \ref{sec:11}, 
we  put a prior $\rho$ on $(u,\bepsilon,\bgamma).$ The inverse problem is now reformulated as determining the distribution $\nu$ of  $(u,\bepsilon,\bgamma)|y.$
Combining \eqref{eq:jcKOH} and \eqref{eq:shift} we obtain
\begin{equation}
\label{eq:jcKOH2}
 y = \Gs(u) + \bepsilon+ \eta, 
\end{equation}
where $\eta \sim \nu_\bgamma.$
By applying Bayes Theorem \ref{t:bayes} we obtain
\begin{equation}\label{eq:bayesformula2}
 \post^y(u,\bepsilon,\bgamma) = \frac{1}{Z} \noise_\bgamma\bigl(y - \Gs(u)-\bepsilon\bigr)\pr(u,\bepsilon,\bgamma),
\end{equation}
where
\[
 Z = Z(y) :=\int_{\Ru \times \Ry \times \R^p} \noise_\bgamma\bigl( y - \Gs(u)-\bepsilon\bigr)\pr(u,\bepsilon,\bgamma) \, du d\bepsilon d\bgamma  >0.\]

 \begin{remark}
 \label{rem:factor}
     In this setting the prior $\pr(u,\bepsilon,\bgamma)$ is typically factored as an independent
     product of priors on $u$ and on each of the hyper-parameters $b$ and $\bgamma.$ 
 \end{remark}




\subsection{Representing Error in Parameter Space}
\label{ssec:EME}
A different approach is to account for model error in parameter space.
To achieve this, parameter $u$ is assumed to be perturbed by a draw
$\vartheta$ from a random variable with distribution $r_\beta$ known, 
up to parameter $\beta \in \R^p.$ Thus we write
\begin{equation}
\label{eq:trep}
y = G(u + \vartheta) + \eta,
\end{equation}
assuming in this setting that $\eta \sim \noise$ and that $\noise$ is completely known.



In principle the parameters $(u,\beta)$ can be found 
by putting a prior $\pr$ on $(u,\beta)$ and determining
the likelihood $\like(y|u,\beta)$ from \eqref{eq:trep}.
Applying Bayes Theorem \ref{t:bayes} we obtain
\begin{equation}\label{eq:bayesformula3}
 \post^y(u,\beta) = \frac{1}{Z} \like(y|u,\beta) \pr(u,\beta),
\end{equation}
where
\[
 Z = Z(y) :=\int_{\Ru  \times \R^p} \like(y|u,\beta) \pr(u,\beta) \, du d\beta  >0.
\]
As in Remark \ref{rem:factor} the prior is usually factored as an independent product, here of 
$u$ and of $\beta.$



A substantial challenge facing this approach 
is to define a tractable likelihood $\like(y|u,\beta).$
Rather than restricting to settings where the likelihood is tractable,
an alternative approach is to use likelihood-free methods such as approximate Bayesian computation\index{approximate Bayesian computation}. We will discuss likelihood-free inference in Section~\ref{sec:likelihood-free}. Here, we illustrate the representation of error in parameter space in the setting of a linear forward model.


\begin{example} For a linear forward model, $G(u) = Au$, the data model
\eqref{eq:trep} becomes
$$y = Au + (A\vartheta + \eta).$$ This can be interpreted as a linear forward model with the additive error $A\vartheta + \eta$. If $\vartheta$ and $\eta$ are independent zero-mean Gaussian random variables, the embedded model error corresponds to a likelihood model with inflated variance where the additional variance is related to the forward model. Then $\like(y|u,\beta)$ is determined
by
$$\bbP(y|u,\beta) = \mathcal{N}\bigl(Au, AC(\beta)A^\top + \Sigma\bigr),$$
where
$$C(\beta)=\text{Cov}(\vartheta), \quad \Sigma=\text{Cov}(\eta).$$
\end{example}



\subsection{Parameterizing the Forward Model}
\label{ssec:UTH}

A third approach to model error postulates that the physically realizable
forward map $\Gp$ is related to a class of computational models 
$\Gs:\Ru \times \R^p \to \Ry$ in the sense that, for all $u \in \Ru,$
and for some $\alpha \in \R^p,$
\begin{equation}
\label{eq:trep2}
\Gp(u) = \Gs(u,\alpha).
\end{equation}
\begin{remark} A parameterized forward model may be a coarse-scale model where unresolved small-scale physical processes are described by parameters $\alpha$. For example, $\alpha$ may describe cloud cover in a climate model $\Gs$. More examples will be provided in Chapter~\ref{ch:DAML}.
\end{remark}

It is assumed that $\alpha$ is not known to us. Thus the problem becomes
one of determining the pair $(u,\alpha)$ from the observation $y.$
Combining \eqref{eq:jcKOH} and \eqref{eq:trep2} suggests consideration of
the Bayesian inverse problem of determining the distribution 
of $(u,\alpha)|y$ given that
\begin{equation}
y = \Gs(u,\alpha) + \eta.
\end{equation}
Here $\eta$ again describes additive noise with known distribution $\noise.$ 
Applying Bayes Theorem \ref{t:bayes} we obtain
\begin{equation}\label{eq:bayesformula4}
 \post^y(u,\alpha) = \frac{1}{Z} \noise\bigl(y - \Gs(u,\alpha)\bigr) \pr(u,\alpha),
\end{equation}
where
\[
 Z = Z(y) :=\int_{\Ru  \times \R^p}  
 \noise\bigl(y - \Gs(u,\alpha)\bigr)\pr(u,\alpha) \, du d\alpha  >0.
\]
Similarly to Remark \ref{rem:factor} the prior is usually factored as an independent product
of priors on $u$ and on $\alpha.$


\section{Bibliography}\label{sec:14}


For Bayesian approach to inverse problems\index{Bayesian!inverse problem} see \cite{kaipio2006statistical,tarantola2005inverse,stuart2010inverse,dashti2013bayesian,lasanen2012non,lasanen2012nonb,nickl}.
For classical optimization-based\index{optimization} 
approaches to \index{inverse problem}inverse problems, 
we refer to the books and lecture notes \cite{tikhonov1977solutions,engl1996regularization,vogel2002computational,bal2012introduction,miller2003fundamentals}.
The concept of \index{MAP estimator}MAP estimators, which links probability to
\index{optimization}optimization, is discussed in the books  
\cite{kaipio2006statistical,tarantola2005inverse,dashti2013map}.
For generalizations see the papers \cite{helin2015maximum,agapiou2017sparsity,lambley2023order}.

The stability and \index{well-posed}well-posedness
of the \index{Bayesian!inverse problem}Bayesian \index{inverse problem}inverse problem was
first studied in \cite{marzouk2009stochastic}, using 
the KL divergence (see Definition \ref{def:KL}),
with respect to perturbations in the data.
The articles \cite{stuart2010inverse,dashti2013bayesian} 
study similar stability and \index{well-posed}well-posedness results
in the Hellinger metric, as we do here.
Related results on stability and \index{well-posed}well-posedness, 
but using other distances and divergences, 
may be found in \cite{latz2020well}.
The papers \cite{hosseini2017well,hosseini2017wellb} discuss generalizations of the \index{well-posed}well-posedness theory to various classes of specific \index{non-Gaussian}non-Gaussian \index{prior}priors. 


The approach to model error outlined in Subsection \ref{ssec:KOH} was introduced
in \cite{kennedy2001bayesian}.
The embedded model error framework of Subsection \ref{ssec:EME} was introduced in~\cite{sargsyan2019embedded}; for an introduction to approximate
Bayesian computation see \cite{sisson2018handbook}. An example of
the approach to model error described in Subsection \ref{ssec:UTH} 
may be found in \cite{cotter2012variational}. Methodologies to identify parameters of structural error models (e.g., within computational models for dynamical processes), often using indirect data, are described in~\cite{wu2023learning, levine_framework_2022}.

Monte Carlo\index{Monte Carlo} methods are a broad class of approaches for characterizing posterior distributions using a sum of Dirac masses; see~\cite{liu2008monte, robert2013monte} for textbooks on the theoretical and computational aspects of these methods. While direct Monte Carlo sampling is possible in some settings, Markov chain Monte Carlo (MCMC)\index{Monte Carlo!Markov chain}\index{MCMC} is a variant that is used in practice when it is not possible to sample exactly from the posterior. Instead, MCMC generates approximate samples by constructing a Markov chain of correlated samples from a kernel whose invariant distribution is the posterior of interest. A general introduction to MCMC is~\cite{gamerman2006markov}. The use of machine learning within Monte Carlo algorithms is discussed in Section~\ref{sec:lfbib}. 











\chapter{\Large{\sffamily{Variational Inference}}} \label{ch:VI}

The variational formulation of any problem in mathematics is useful because it
opens the door to computational methods. Such computational methods seek to minimize the objective
function over a strict subset of the whole space over which the original variational problem
is posed. If the strict subset if chosen judiciously (this is a problem-dependent
choice) then the resulting computational methodology is both tractable and yields
a useful, and interpretable, 
approximation of the solution of the original variational problem
posed on the whole space.
This chapter is devoted to formulating Bayes Theorem \ref{t:bayes}
variationally and using this formulation as the basis for approximate inference. We make the following data assumption:

\begin{dataassumption}
\label{da:vb}
Data $y \in \R^{\dy}$ is given and is assumed to have come from
identity \eqref{eq:jc0}, where $G:\R^{\du} \to \R^{\dy}$ is known
and $\eta$ is an unknown realization of a centered random variable 
whose distribution is known and satisfies Assumption \ref{a:jc1}. 
\end{dataassumption}

Under the above data assumption, and given a prior distribution on $u$, the posterior distribution on $\bbP(u|y)$ is defined by Bayes Theorem \ref{t:bayes}.
In Section \ref{sec:vbay} we show how this theorem can be formulated
variationally as a minimization problem over the set of all probability density functions; 
this leads to the subject of variational inference,\index{inference!variational} the topic of
Section \ref{sec:vvar}. In that section we exhibit two choices of subsets of all probability density functions
over which to approximate the posterior, the mean-field\index{mean-field} and Gaussian\index{Gaussian} subsets. This
leads to two widely-used methods in variational inference.
We conclude the chapter, in Section \ref{sec:vbib}, with bibliographical
remarks.

\section{Variational Formulation of Bayes Theorem}
\label{sec:vbay}

Our starting point in this section is Bayes Theorem \ref{t:bayes}. Because
$y$ dependence is not central to our discussions we write the posterior
as $\post:=\post^y.$
A useful formulation of Bayes Theorem arises from seeking the posterior as the solution of an optimization problem over the space of probability density functions. The objective of the optimization problem measures the discrepancy between the posterior density $\post$ and a candidate density $q$; the objective is constructed to be minimized at $q=\post$. By using
Bayes Theorem \ref{t:bayes} the objective function can be rewritten in terms
of the prior, the likelihood and the normalization\index{normalization constant} 
constant. In what follows we write $\cP=\cP(\R^d)$ for the space 
of all probability density functions over $\R^d.$ 


One natural class of objective functions $\F: \cP \to \R$ is defined by the class
of $\mathsf{f}$-divergences $\D_\mathsf{f}(q\|\post):$
$$\F(q):=\D_\mathsf{f}(q\|\post) = \int \mathsf{f}\left(\frac{q(u)}{\post(u)}\right)\post(u)\, du.$$
See Chapter~\ref{ch:distances} for the definition and properties of this family of
distance-like objects defined on the space of probability densities. By the properties
of all divergences, detailed at the start of Section \ref{sec:div}, we deduce that $\F(q)$
is minimized at $q=\post$  and that this is the unique minimizer.
A particularly useful choice arises from setting $\mathsf{f}(t)=t\log(t),$ 
leading to definition of the objective $\F: \cP \to \R$ given by 
$$\F(q)=\dkl(q\|\post) = \int \log \left(\frac{q(u)}{\post(u)}\right) q(u) \, du,$$
the Kullback--Leibler (KL) divergence.
This choice of objective is convenient because it can be minimized without knowledge of the normalization constant of $\post$; see Remark \ref{rem:yifan}.
Using this KL divergence to formulate
variational inference\index{inference!variational} delivers the following theorem:


\begin{theorem}
\label{t:VariationalForm_Bayes} Consider the Bayesian inverse problem defined
by prior $\pr$ and likelihood $\like(y|u)$ given by \eqref{eq:like}, under Assumptions \ref{a:jc1}.
Define $\J: \cP \to \R$ by 
\begin{subequations}
\label{eq:KLobj_minusZ}
\begin{align} 
\J(q) &= \dkl(q\|\pr) - \mathbb{E}^q[\log \like(y|u)],\\
\qopt &\in \argmin_{q \in \cP} \J(q).
\end{align}
\end{subequations}
Then $\qopt=\post,$ the posterior distribution.
\end{theorem}

\begin{proof}
Note that, by Lemma \ref{l:kllemma}, it follows that
$\F(q)=\dkl(q \|\post)$ is non-negative for all inputs $q$ from the set of
probability density functions. In addition, by Definition \ref{def:KL}, it is
clear that the infimum of $\F(q)$, namely $0$, is attained at $q=\post.$
Furthermore, from Definition \ref{def:hellinger} and Lemma \ref{l:kllemma}, it follows
that the minimizer is unique since the Hellinger distance, and hence the 
KL divergence, between two densities is nonzero unless they are 
identical (strictly speaking in the Lebesgue a.e. sense).
Using the form of the posterior density, we see that
\begin{subequations}
\label{eq:KLobj}
\begin{align} 
\F(q) &= \mathbb{E}^q[\log q - \log \pr(u) - \log \like(y|u) + \log Z] \\
&= \dkl(q \|\pr) - \mathbb{E}^q[\log\like(y|u)] + \log Z\\
&= \J(q) + \log Z. 
\end{align}
\end{subequations}
Because $Z$ is a constant with respect to $q$, the minimizer of $\F(q)$, which
is unique, is equivalent to the minimizer of $\J(\cdot)$ and the proof is complete.
\end{proof}



\begin{remark}
\label{rem:2.3}
Note that, using the loss function \eqref{eq:loss}, we may write
\begin{align} 
\label{eq:KLobj_minusZ2}
\J(q) &= \dkl(q\|\pr) + \mathbb{E}^q[\loss(u)].
\end{align}
Using this formulation of $\J(\cdot)$ we comment on the structure on the minimization
problem \eqref{eq:KLobj_minusZ} in relation to the MAP estimation problem presented in Section \ref{sec:112}. The MAP problem requires minimization of \eqref{eq:MAPO}.
Comparison with \eqref{eq:KLobj_minusZ2} shows that in both cases the objective involves two terms that balance the properties of the prior distribution (the first term) and the fit to the data (the second term); furthermore the second term in \eqref{eq:KLobj_minusZ2} is the
expectation of the second term in \eqref{eq:MAPO}. Note that minimization of~\eqref{eq:KLobj_minusZ2} is more general than minimization of \eqref{eq:MAPO}: the former provides a probability density function rather than the point estimator provided by the latter. 
\end{remark}


\begin{remark}
Because of the desirable property that the objective function can be minimized without knowledge of the normalization constant, we work exclusively with KL divergence to define variational formulations
of Bayes Theorem \ref{t:bayes}. While other objective functions with this property do exist,
they cannot be $\mathsf{f}$-divergences, by Remark \ref{rem:yifan}. 
\end{remark}














\section{Variational Inference\index{inference!variational}}
\label{sec:vvar}

In practice characterizing the posterior distribution is difficult, in general.
One approach to doing so is to approximate the posterior using the variational formulation. We replace the set $\cP$ in~\eqref{eq:KLobj_minusZ} by a tractable class of probability distributions $\mathcal{Q} \subset \cP$ for the purpose of computations and for the
purpose of revealing an explicit, interpretable form. The variational inference\index{inference!variational}
problem is then given by solving the following optimization problem:
\begin{equation} \label{eq:VariationalForm_Bayes}
\qs \in \argmin_{q \in \mathcal{Q}} \J(q).
\end{equation}



In the next two subsections we outline two popular classes of tractable distributions $\mathcal{Q}$: in Subsection \ref{ssec:mf} the product of independent components for each marginal; and in Subsection \ref{ssec:gauss} multivariate Gaussians. The former case is known as \emph{mean-field variational inference}\index{inference!mean-field variational} and the latter as 
\emph{Gaussian variational inference.}\index{inference!Gaussian variational}

\subsection{Mean-Field Family}
\label{ssec:mf}

Mean-field inference\index{inference!mean-field variational} works with a family $\cQ$ of distributions with independent marginals; that is, the density $q$ factorizes into a product of independent components. While this choice does not represent dependencies among its variables, it is often chosen because of the efficiency of methods for finding $\qs$ in this case, and because of the ease
of computing marginal properties once $\qs$ is determined.

\begin{definition}
\label{d:qmf} A probability density function $q$ for $z \in \R^d$ is in the \emph{mean-field}\index{mean-field} family $\cQ$ if its coordinates are independent. That is, its probability density function can be written in the form
$$q(z) = \prod_{i=1}^d q_i(z_i),$$
where $q_i$ is a one-dimensional probability density function for the $i$th coordinates $z_i$.
\end{definition}

With this choice of $\cQ$ the solution of the optimization problem in~\eqref{eq:VariationalForm_Bayes} may be approached by using the
following consistency equations, relating the marginal densities
$\{q_i\}_{i=1}^d$ to one another. All integrals appearing in the statement
and proof of the following proposition are over the whole of Euclidean
space of the relevant dimension.

\begin{proposition} Let $\cQ$ be defined as in Definition \ref{d:qmf}.
Then the optimal 
$\qs= \prod_{i=1}^d \qs_i(u_i)$
solving \eqref{eq:VariationalForm_Bayes} satisfies
$$\qs_i(u_i) \propto \exp \left( \int \log \post(u) \prod_{j \neq i} \qs_j(u_j) \, du_{-i} \right) \quad \text{ for } i=1,\dots,d,$$
 where $u_{-i} \in \R^{d-1}$ denotes all variables except for $u_i$.
\end{proposition}

\begin{proof} Recall that minimizing $\J(\cdot)$ is equivalent to minimizing
$\dkl(\cdot\|\post)$. The KL divergence $\dkl(q\|\post)$ for a density $q$ in the mean-field family is given by
\begin{align*}
  \dkl(q\|\post) &= \int \log \left(\prod_{i=1}^d q_i(u_i) \right) \prod_{i=1}^d q_i(u_i) \, du - \int \log \post(u) \prod_{i=1}^d q_i(u_i) \, du \\
&= \sum_{i=1}^d \int \log q_i(u_i) q_i(u_i) \, du_i  - \int \log \post(u) \prod_{i=1}^d q_i(u_i) \, du,
\end{align*}
where in the last line we used that each integrand only depends on $u_i$ and each $q_i$ is a probability density function that integrates to $1$. Taking the first variation of the KL divergence with respect to each $q_i,$ we have
$$\frac{\delta }{\delta q_i} \dkl(q\|\post) = 1 + \log q_i(u_i) - \int  \log \post(u) \prod_{j \neq i} q_j(u_j) \, du_{-i}.$$
Setting the first variation equal to zero and re-arranging the terms gives us the un-normalized form for each marginal density $q_i^\star$ at any critical point of $\J(\cdot)$
over $\cQ.$
\end{proof}

\begin{remark}
    We note that although the preceding proposition is formulated in terms of
    the posterior density, its statement remains unchanged if $\pi(u)$ is replaced
    by $\pr(u)\like(y|u)$; this simply changes the constant of proportionality. Thus, to use it,
    we do not need to know the normalization constant $Z$ in Bayes Theorem \ref{t:bayes}.
\end{remark}

The proposition defines a set of coupled equations that must be satisfied by the optimal marginal densities in terms of the other marginal densities. Moreover, it prescribes how to set $q_i$ when keeping all other coordinates fixed. Thus, a natural approach to find the minimizer is to perform coordinate updates on each marginal. This algorithm is known as coordinate-ascent variational inference (CAVI).\index{inference!coordinate-ascent variational} \emph{Ascent} because traditionally formulated
in terms of maximizing the $\ELBO$ function (see Definition \ref{d:elbo}) rather than minimizing the KL divergence; we prefer, for consistency with other optimization problems
in the notes, to formulate it in terms of $\J$, and hence \emph{descent.} 

The updates are thus, sequentially for iteration index $\ell \in \bbZ^+$ until convergence, and for 
$i=1,\dots,d\, ,$
\begin{equation}
\label{eq:updates}
q^{\ell+1}_i(u_i) \propto \exp \left( \int \log \post(u) \prod_{j < i} q^{\ell+1}_j(u_j)
 \prod_{j > i} q^{\ell}_j(u_j) \, du_{-i} \right).
\end{equation}

\begin{algorithm}
\caption{Coordinate-Ascent Variational Inference\index{inference!coordinate-ascent variational}}
\begin{algorithmic}[1]
\STATE {\bf Input}: Density $\post$ known up to normalizing constant. Initialization $q^0.$ Number $L$ of iterations. \\
    \STATE For $\ell=0, 1,2, \ldots, L-1,$ compute $q^{\ell+1}$ from $q^{\ell}:$ 
    \STATE Update $q_i^{\ell+1}$ for $i = 1, \ldots, d$ using \eqref{eq:updates}.
\STATE {\bf Output}: Approximation $q^L$ of density $\post.$
\end{algorithmic}
\end{algorithm}

\begin{remark}
    The mean-field methodology has the computational advantage of reducing the inference problem
    in (potentially high) dimension $d$ to one of $d$ independent one-dimensional inference problems.
    As such it can potentially accurately learn marginal information on specific coordinates; but it cannot
    learn correlations. In the next subsection we work in a different subset $\cQ$, the set of Gaussian
    measures, in which it is possible to approximate correlation information.
\end{remark}

\subsection{Gaussian Distributions}
\label{ssec:gauss}



Another tractable variational approach is to seek an approximate distribution $\qs$ 
from within a parametric family $\cQ$ of probability density functions. In many applications, interest
is focused on ultimately estimating the first two moments of $\post^y$; in
this context a natural family to consider is Gaussian distributions. 
In this subsection we derive optimality conditions for the solution to the resulting optimization problem.  
To find a Gaussian approximation, we seek to minimize $\dkl(\cdot\|\post)$ over the set of distributions
\begin{subequations}
\label{eq:GVI}
\begin{align}
\cQ :=& \bigl\{q \in \cP: q= \mathcal{N}(m,\Sigma), (m, \Sigma) \in \cC  \bigr\},\\
\cC :=& \bigl\{ m \in \R^d, \Sigma \in \bbR^{d \times d}_{\textrm{sym}, \ge} \bigr\}.
\end{align}
\end{subequations}

\begin{proposition} \label{prof:VI_Gaussians} 
Let $\cQ$ be defined as in \eqref{eq:GVI}.
Then the optimal  
$\qs=\mathcal{N}(\ms,\Sigmast)$ solving \eqref{eq:VariationalForm_Bayes} satisfies
\begin{equation} \label{eq:GaussianVI_objective}
(\ms,\Sigmast) \in \argmin_{(m,\Sigma)\in \cC} \mathbb{E}^q[-\log \post(u)] - \frac{1}{2}\log\det(\Sigma),  
\end{equation}
where the expectation is with respect to $q= \mathcal{N}(m,\Sigma).$
\end{proposition}

\begin{proof} Recall that $\qs$ minimizes $\dkl(\cdot\|\post)$ over $\cQ.$
The result follows from using the fact that, for $q(u)$ being the density of $\mathcal{N}(m,\Sigma)$, we have
\begin{equation}
    \label{eq:q2}
    q(u)=\frac{1}{(2\pi)^{d/2} \det(\Sigma)^{1/2}}\exp\Bigl(-\frac12|u-m|_{\Sigma}^2\Bigr).
\end{equation}
From this it follows that
    \begin{align*}
      \dkl(q \|\post) & = \int \log q(u) \, q(u) \, du - \int \log \post(u) \, q(u) \, du ,\\
      \int \log q(u) \, q(u) \, du & = -\frac{d}{2}-\frac{d}{2}\log(2\pi) - \frac{1}{2}\log\det(\Sigma).
    \end{align*}
\end{proof}

\begin{remark}
The two terms in the objective function can be interpreted as having a competitive behavior. While the second term can be maximized by a Gaussian distribution of increasing smaller variance centered at the mode of $\post$, the point of highest posterior density, the first term approaches negative infinity if the variance of any marginal approaches zero. Hence, the first term in the objective regularizes the optimization problem to ensure the approximating Gaussian is not degenerate in any direction.
\end{remark}


\begin{proposition} Let $(\ms,\Sigmast) \in \mathcal{C}$ solve the Gaussian variational inference
\index{inference!Gaussian variational} in Proposition~\ref{prof:VI_Gaussians}. The solution satisfies the first-order optimality 
conditions\footnote{Use of $\nabla$ and $D^2$ here denote derivatives with respect to $u$, then evaluated
at $u=\ms + (\Sigmast)^{1/2}\xi.$}
$$\mathbb{E}^\xi[\nabla \log \post(\ms + (\Sigmast)^{1/2}\xi)] = 0, \quad \mathbb{E}^\xi[D^2 \log \post(\ms + (\Sigmast)^{1/2}\xi)] = -(\Sigmast)^{-1},$$
where $\xi \sim \mathcal{N}(0,I_d).$ 
\end{proposition}

\begin{proof} 
Throughout the proof, use of $\nabla$ or $D^2$ without a subscript is to be taken as with respect to variable $u;$ in addition, $q$ the Gaussian density $\mathcal{N}(m,\Sigma)$ given in \eqref{eq:q2}.
The first-order optimality condition for the optimization problem in~\eqref{eq:GaussianVI_objective} is given by
$$\nabla_{(m,\Sigma)} \left. \left[\mathbb{E}^q[-\log \pi(u)] - \frac{1}{2}\log\det(\Sigma) \right] \right|_{(\ms,\Sigmast)} = 0.$$
The gradients of the objective with respect to $m$ and $\Sigma$ are given by
\begin{align*}
\nabla_m &\left[\int -\log \pi(u) q(u) \, du - \frac12 \log\det(\Sigma)\right] = \int -\log \pi(u) \nabla_m q(u) \, du, \\
\nabla_\Sigma &\left[ \int -\log \pi(u) q(u) \, du - \frac12 \log\det(\Sigma) \right] =  \int -\log \pi(u) \nabla_{\Sigma} q(u) \, du - \frac12 \Sigma^{-1}.
\end{align*}
From the symmetry of the Gaussian density with respect to $u$ and $m$, we have 
\begin{align*}
    \nabla_m q(u) &= \nabla q(u),\\
    \nabla_\Sigma q(u) &= q(u)\nabla_\Sigma \log q(u) \\
    &= -q(u)\frac{1}{2}[\Sigma^{-1} -  \Sigma^{-1}(u-m)(u-m)^\top\Sigma^{-1}] \\
    &= \frac{1}{2} D^2 q(u).
\end{align*} 
Substituting these expressions above and applying integration by parts gives us 
\begin{align*}
\int -\log \pi(u) \nabla_m q(u) \, du &= \int -\log \pi(u) \nabla q(u) \, du = \int \nabla \log \pi(u) q(u) \, du,\\
\int -\log \pi(u) \nabla_\Sigma q(u) \, du &= -\frac{1}{2}\int \log \pi(u) D^2 q(u) \, du = -\frac{1}{2} \int D^2 \log \pi(u) q(u) \, du.
\end{align*}
Setting the two gradients equal to zero and re-writing the expectations in terms of a standard Gaussian random variable $\xi \sim \mathcal{N}(0,I_d)$ using the relation $u = m + \Sigma^{1/2}\xi$ for a positive definite covariance $\Sigma$ gives us the result.
\end{proof}



\begin{remark} If $c^- I_d \preceq \nabla^2 \log \pi(u) \preceq c^+ I_d$ for all $u \in \R^d$, then the optimal solution satisfies $\frac{1}{c^+} I_d \preceq \Sigmast \preceq \frac{1}{c^-} I_d$. 
\end{remark}

\subsection{Mode-Seeking Versus Mean-Seeking Variational Inference}
\label{ssec:modemean}

 In the previous subsections, we seek an approximation to the posterior distribution $\pi$ by minimizing,
 over $\mathcal{Q} \subset \mathcal{P}$, the
 function $$q \mapsto \dkl(q\|\pi) = \mathbb{E}_q[\log(q/\pi)];$$ this
 is sometimes referred to as the reverse KL divergence. Using the reverse KL divergence as an objective is computationally convenient in the setting where we can evaluate the likelihood and the prior, but 
 we do not necessarily know the normalization constant, nor do we necessarily have the ability
 to easily sample from the posterior. In comparison, the forward KL divergence 
 $$q \mapsto \dkl(\pi\|q) = \mathbb{E}_\pi[\log(\pi/q)]$$ 
 is more convenient for optimization over $\mathcal{Q}$ when we can sample from $\pi$, but do not necessarily have access to an analytical expression for the target density.

In addition to computational considerations, the two choices of KL divergence lead to different behavior  when minimizing over a subset of probability measures. The reverse KL favors approximate distributions where $\log(q/\pi)$ is small in regions of high probability of $q$. This occurs when $q \approx \pi$ for large $q$ or when $q \ll \pi$. As a result, the minimizers for $q$ tend to fit one mode of multi-modal distributions $\pi$, but miss the other modes. Hence, minimizing the reverse KL is known is also known as \emph{mode-seeking}\index{mode seeking}. In contrast, the minimizers of the forward KL favor approximate distributions $q$ where $\log(\pi/q)$ is small in regions of high probability of $\pi$. This occurs by having $q$ be non-zero everywhere in the support of $\pi$ so the denominator in the log does not approach zero. Placing mass everywhere in the support of $\pi$ leads to a \emph{mean-seeking}\index{mean seeking} behavior, where the minimizer for $q$ corresponds to matching the moments of the target density $\pi$.  In particular,
when $\mathcal{Q}$ comprises Gaussians the minimizer of the forward KL divergence is given by Gaussian $q$
with the same mean and covariance as those moments under $\pi.$ Further discussion on these topics and references to the literature may be found in the bibliography in Section \ref{sec:vbib}. 

\subsection{Evidence Lower Bound}
\label{elb}

We now relate $\J(q)$, defined by (\ref{eq:KLobj_minusZ}a), to an important concept in variational inference:\index{inference!variational}

\begin{definition}\label{d:elbo} The \emph{evidence lower bound}\index{evidence! lower bound} ($\ELBO$) of a probability density $q$ with respect to an unnormalized density $\widetilde{\post}$ is
$$\ELBO(\widetilde{\post},q) = \mathbb{E}^q[\log \widetilde{\post}(u)] - \mathbb{E}^q[\log q(u)].$$
\end{definition}

The reason for the terminology evidence lower bound will be made clear 
through Remarks \ref{r:elbo1}, \ref{r:elbo2}. 
The evidence lower bound is sometimes also known as the negative variational free energy.
\index{free energy}
The definition is often used in the situation where $\widetilde{\post}(u)$ is found from
the joint distribution of random variable $(u,y)$, with $y$ frozen. This is the setting
of the following proposition, which sheds first light on the significance of the $\ELBO$ functional.

\begin{proposition}
\label{p:elbo}
Define the unnormalized density $\widetilde{\post}(u)=\pr(u)\like(y|u)$ and define the normalization constant
$Z$ by $\post=Z^{-1}\widetilde{\post},$ assuming that $Z>0.$
Then, the maximizer $$\qopt \in \argmax_{q \in \mathcal{P}} \ELBO(\widetilde{\post},\cdot)$$
is attained at the posterior distribution $\qopt = \post$. Furthermore, the maximum value
is $\ELBO(\widetilde{\post},\qopt)=\log(Z).$
\end{proposition}

\begin{proof} This follows from recognizing from (\ref{eq:KLobj}a) that, 
with the stated form of $\widetilde{\post}$, 
\begin{equation}
    \label{eq:EJ}
\ELBO(\widetilde{\post},q) = -\dkl(q\|\post) + \log(Z)=-\J(q).
\end{equation}
At optimality we have $\dkl(\qopt\|\post) = 0$, and so $\ELBO(\post,\qopt) = \log(Z)$.
\end{proof}

\begin{remark}
\label{r:elbo1}
Notice that $\widetilde{\post}(u)=\bbP(u,y)$ and that the normalizing constant $Z=\bbP(y)$ is called the \emph{evidence}. Thus the preceding
proposition demonstrates the significance of the quantity $\ELBO(\post,\qopt)$: it
computes the logarithm of the evidence\index{evidence}, namely the log-probability that the observed data $y$ was produced by the proposed statistical model for the joint random
variable $(u,y).$ 
\end{remark}

Recall that variational inference\index{inference!variational}
is performed by solving the following optimization problem over $\mathcal{Q} \subset \mathcal{P}:$
\begin{equation} %
\qs \in \argmin_{q \in \mathcal{Q}} \J(q).
\end{equation}

\begin{remark}
\label{r:elbo2}
The calculations in the proof of Proposition \ref{p:elbo} show that, using \eqref{eq:EJ}, 
$$\log(Z)=\ELBO(\widetilde{\post},\qopt) \ge \ELBO(\widetilde{\post},q^\star)=-\J(q^\star).$$ 
Hence, after variational inference\index{inference!variational} over ${\cal Q}$ is performed, we can 
estimate the normalizing constant, or the evidence,\index{evidence} by $Z \ge \exp\bigl(-\J(q^\star)\bigr).$ 
The terminology \emph{evidence lower bound}\index{evidence!lower bound} is now made clear.
\end{remark}






\section{Bibliography}
\label{sec:vbib}

The paper~\cite{zellner1988optimal} provided impetus for
variational Bayes, highlighting the fact that the posterior is found by minimizing
$\J(\cdot)$ given in \eqref{eq:VariationalForm_Bayes}. 
Our presentation has focused on finding the posterior as the minimizer of the KL divergence, but there are other functionals that may be considered. For instance,~\cite{trillos2018bayesian} showed that the posterior is found by minimizing a functional of the same structural form as~\eqref{eq:KLobj} based on the $\chi^2$ divergence (see Definition \ref{def:chi2}), rather than KL divergence.~\cite{li2016renyi, hernandez2016black} showed how to perform variational inference\index{inference!variational} using the family of Renyi-alpha divergences, which include the KL and $\chi^2$ divergences as well as the Hellinger metric.
Whilst there are many divergences\index{divergence} that could be used to define Bayes Theorem via optimization over the space of measures, the specific choice of forward KL divergence has a special place: amongst a wide class of divergences it is the
unique choice for which the objective function does not require knowledge
of the normalization constant $Z$~\cite{chen2023gradient}. 

Refer to~\cite{hoffman2013stochastic} for a modern approach to variational inference,\index{inference!variational} with applications to large collections of documents and topic models\index{topic models}. 
For applications in graphical models\index{graphical models} see~\cite{wainwright2008graphical}.
An extension to the mean-field model is to include interactions~\cite{jordan1999introduction}.
Natural extensions of Gaussians include Gaussian mixtures in~\cite{lambert2022variational}.
The derivation of the mean-field equations for Gaussians was first shown in~\cite{opper2009variational}. Variational inference for sparsity-promoting Bayesian models \cite{calvetti2019hierachical} is considered in \cite{agrawal2022variational}; see also \cite{law2022sparse}.
Discussion of mean-seeking versus mode-seeking may be found in \cite{sanz-alonso_inverse_2023};
see Sections 4.2 and 4.3 in particular.

The $\ELBO$ objective is commonly used to learn variational auto-encoders~\cite{kingma2019introduction}. 
In this context, the goal is to find an approximate distribution $q(u) = \int p_\theta(u|z) p(z) \, dz,$ for which it is intractable to evaluate the KL divergence. By working with the ELBO, we can maximize a lower bound for the negative KL divergence. The maximum value corresponds to the marginal likelihood for the data under $q$.

The $\ELBO$ is a non-convex functional even for simple potentials; see the example in Appendix G of~\cite{lambert_variational_2023}. Due to this non-convexity, it is often challenging to develop guarantees for VI outside of restricted settings on the distribution. Recently, there have been many statistical and algorithmic guarantees for variational inference.\index{inference!variational}
We refer to~\cite{lambert2022variational} for analysis using gradient flows.

\chapter{\Large{\sffamily{Forward Surrogate Modelling}}}
\label{ch:fsm}


In this chapter our focus is on solving the inverse problem for $u$ given $y$,
defined by \eqref{eq:jc0}. The key idea is to approximate $G: \R^{\du} \to \R^\dy$ with a cheap-to-evaluate surrogate, $G_\delta$, using ideas of supervised learning from Chapter \ref{ch:SL}. Thus, to learn this approximation, we make the following assumption. 

\begin{dataassumption}
    \label{da:surrogate} Data is available in the form 
\begin{align}
\label{eq:datafsm}
\Bigl\{\un, y^{(n)} \Bigr\}_{n=1}^N,
\end{align}
where the $\{\un\}_{n=1}^N$ 
are generated \index{i.i.d.}i.i.d. from probability density function $\Upsilon \in \cP(D)$, for some $D \subseteq \R^d,$ and where
$y^{(n)}=G(\un).$
\end{dataassumption}

\begin{remark}
\label{rem:ce}
    A key point to appreciate is that, since we will use approximation of $G$ to solve the Bayesian
    inverse problem for $\pi^y$ given by Bayes Theorem \ref{t:bayes}, an ideal choice for $\Upsilon$ is that
    it is close to $\pi^y.$ This, of course, leads to a chicken-egg issue. In practice this can be addressed
    by choosing $\Upsilon$ to have generous support, aiming to subsume that of $\pi^y;$ or by 
    generating data in tandem with solving the inverse problem.
\end{remark}

In Section \ref{sec:LForward} we discuss the use of surrogate forward models
to speed-up Bayesian inversion. Section \ref{sec:LForwarda} provides analysis
of the effect of approximating the forward model on the posterior. We briefly
comment on surrogate modelling in the context of MAP\index{MAP estimator}
estimation when model error is also being inferred in Section \ref{sec:LForward2}, slightly generalizing
Data Assimilation \ref{da:surrogate}. We conclude in Section \ref{sec:sbib}
with bibliographic remarks.



\section{\index{forward!model} Accelerating Bayesian Inversion}\label{sec:LForward}

Recall the \index{inverse problem}inverse problem \eqref{eq:jc0} of finding
$u$ from $y$ where
$$y=G(u)+\eta,$$
under the setting summarized in Assumption \ref{a:dh1}.
If the \index{Bayesian}Bayesian approach is adopted and Markov chain Monte Carlo \index{MCMC}(MCMC) is used to sample the \index{posterior}posterior, generating each new sample typically requires evaluating the likelihood, and hence the forward model $G.$  Even when MAP\index{MAP estimator}
estimation is used, multiple evaluations of $G$ may be needed to optimize
the objective function; if model error\index{model error} is being jointly
learned, in the setting of Subsection \ref{ssec:UTH}, 
then multiple MAP estimators may be
required leading to many more evaluations. Thus, when $G$ is computationally 
expensive to evaluate, multiple evaluation may be prohibitive for both MCMC
sampling and MAP estimation. We address
this issue by using cheap computational surrogates $G_\delta$.

The methods described in Chapter \ref{ch:SL} 
can be used to approximate the 
(scalar-valued) \index{likelihood}likelihood $\like$  resulting from $G$, 
by an approximation $\like_{\delta}$
with small error $\delta,$ uniformly over bounded open $D  \subset \R^d $. 
In Chapter \ref{ch:SL} we focus on learning functions taking values
in $\R.$ However all such methods can
be generalized to approximate (vector-valued) $G$
by a uniform  approximation over $D  \subset \R^d $, $G_\delta$, which
in turn results in a uniform approximation $\like_{\delta}$  of the \index{likelihood}likelihood. Such an approximation $G_\delta$
can be learned from Data Assumption \ref{da:surrogate}.
If carefully designed, then
the \index{machine learning}machine learning approximation of the \index{likelihood}likelihood will be much
faster to evaluate than the true \index{likelihood}likelihood and, because of the
approximation properties, will result in accurate \index{posterior}posterior inference,
with errors of size $\delta.$ 
Such results rely on error bounds of the form given in Section \ref{sec:AP} which
(with high probability) can be obtained with a number $N$ of evaluations
of the \index{forward!model}forward model which is often orders of magnitude smaller than the number of evaluations required within \index{MCMC}MCMC, or
even MAP estimation in the context of learning model error.
The resulting method can thus be very efficient.

\section{\index{forward!model} Posterior Approximation Theorem}\label{sec:LForwarda}


We now establish that the approximate \index{posterior}posterior resulting from approximating
the \index{likelihood}likelihood is 
indeed close to the true posterior. We use error bounds of the form
\eqref{eq:eb} within a modification of the 
\index{well-posed}well-posedness theory from Chapter \ref{ch1}.


For notational convenience we drop the dependence of the likelihood\index{likelihood} on $y$ in the remainder of this chapter.
Specifically we let
\[\like(u)=\noise\bigl(y-G(u)\bigr)\quad \text{and}\quad \like_\delta(u)=\noise\bigl(y-G_\delta(u)\bigr)\]
denote the true and approximate \index{likelihood}likelihoods. Thus we may define
the true and approximate \index{posterior}posterior distributions by 
\[\post^y(u)=\frac{1}{Z}\like(u)\pr(u)\quad \text{and}\quad \post_\delta^y(u)=\frac{1}{Z_\delta}\like_\delta(u)\pr(u);\]
here $Z, Z_\delta$ are the corresponding normalizing constants. To
prove our result about the closeness, between the true \index{posterior}posterior and the \index{posterior}posterior with machine-learned likelihood, we specify our assumptions.

\begin{assumption}\label{a:dh1L}
The \index{prior}prior distribution on $u$ with density $\pr$ is supported on bounded open set $D \subset \Ru$
and the data defined by \eqref{eq:jc0} and Assumption \ref{a:dh1} has positive probability under the resulting joint distribution on $(u,y)$, so that $Z>0.$ Furthermore, there exist $\delta^+>0$ and $K_1,K_2 \in (0,\infty)$ such that, for all $\delta\in (0,\delta^+),$ 
	\begin{itemize}
	\item[(i)] $\sup_{u\in D}|\sqrt{\like(u)} - \sqrt{\like_\delta(u)}|\leq K_1\delta;$
	\item[(ii)] $\sup_{u\in D}(|\sqrt{\like(u)}|+|\sqrt{\like_\delta(u)}|) \le K_2.$
	\end{itemize}
\end{assumption}

Parts (i) and (ii) of the assumptions follow from approximation theoretic results of 
the form given in Chapter \ref{ch:SL} on supervised learning, and \eqref{eq:eb} in particular. 
Note also that combining (i) and (ii) gives
\begin{equation}
\label{eq:combine}
\sup_{u\in D}|\like(u) - \like_\delta(u)|\leq K_1 K_2\delta.
\end{equation}


Using the assumption we may state the following approximation result 
for the machine-learned \index{posterior}posterior.
When combined with Lemma \ref{lemmatv}, the following theorem
guarantees that expectations computed with respect to the machine-learned
\index{posterior}posterior commit an error of order $\delta$, the magnitude of the error
in the approximate \index{likelihood}likelihood.



\begin{theorem}
\label{thm1L}
Under Assumptions \ref{a:jc1} and \ref{a:dh1L} there exists $c\in(0,+\infty)$ and $\Delta>0$ such that, for
all $\delta\in(0,\Delta)$,
      \[\dhell(\post^y,\post_\delta^y)\leq c \delta.\]
\end{theorem}



As in the proof of the \index{well-posed}well-posedness Theorem \ref{t:wpz}, we first show 
a lemma which characterizes the normalization constants and their
approximation in the small $\delta$ limit.
In the lemma, and the proof of theorem that follows it, all integrals are over the set $D$
defined in Assumption \ref{a:dh1L}.
   
     \begin{lemma}\label{lem1L} Under Assumptions \ref{a:jc1} and \ref{a:dh1L} there exist $\Delta>0$, $c_1,c_2\in(0,+\infty)$ such that, for all $\delta\in(0,\Delta)$,
      \[|Z-Z_\delta|\leq c_1\delta\quad \text{and}\quad Z,Z_\delta \ge c_2.\]
      \end{lemma}
      \begin{proof} 
Since $Z=\int \like(u)\pr(u) \, du$ and
$Z_\delta=\int \like_\delta(u)\pr(u) \, du,$ 
we have, using \eqref{eq:combine},
      \begin{align*}
      |Z-Z_\delta|=& \biggl| \int \bigl(\like(u)-\like_\delta(u)\bigr)\pr(u) \, du    \biggr|   \\
      \leq&  \int \bigl|\like(u)-\like_\delta(u) \bigr|\pr(u) \, du\\ 
      \leq&\ K_1 K_2\delta,\quad \delta\in(0,\delta^+). 
      \end{align*}
      Therefore, for $\delta\leq \Delta\coloneqq\min\{\frac{Z}{2K_1 K_2},\delta^+\}$, we have
      \[Z_\delta\geq Z-|Z-Z_\delta|\geq \frac{1}{2}Z.\]
      The lemma follows by taking $c_1=K_1 K_2$ and $c_2=\frac{1}{2}Z$, and noting that $K_1,K_2, Z > 0$ by assumption.\\
      \end{proof}   
 
      \begin{proof}[Proof of Theorem \ref{thm1L}]
Following proof of the \index{well-posed}well-posedness Theorem \ref{t:wpz}, we
   decompose the total error into two contributions, reflecting respectively
the difference between $Z$ and $Z_\delta$, and the difference between 
the \index{likelihood}likelihoods $\like$ and $\like_\delta$:
      \begin{align*}
      \dhell(\post^y,\post_\delta^y)
      \leq&\ \frac{1}{\sqrt{2}}\Biggl\|\sqrt{\frac{\like\pr}{Z}}-\sqrt{\frac{\like\pr}{Z_\delta}}\Biggr\|_{L^2}+\frac{1}{\sqrt{2}}\Biggl\|\sqrt\frac{\like\pr}{Z_\delta}-\sqrt{\frac{\like_\delta\pr}{Z_\delta}}\Biggr\|_{L^2}.
      \end{align*}
      Using Lemma \ref{lem1L} we have, for $\delta\in(0,\Delta)$, 
      \begin{align*}
      \Biggl\|\sqrt{\frac{\like\pr}{Z}}-\sqrt{\frac{\like\pr}{Z_\delta}}\Biggr\|_{L^2}=&\ \Biggl|\frac{1}{\sqrt{Z}}-\frac{1}{\sqrt{Z_\delta}}\Biggr|\Bigg(\int \like(u)\pr(u) \, du\Bigg)^{1/2}\\
      =&\ \frac{|Z-Z_\delta|}{(\sqrt{Z}+\sqrt{Z_\delta})\sqrt{Z_\delta}}\\
      \leq&\ \frac{c_1}{2c_2}\delta,
      \end{align*}
      and 
      \[\Biggl\|\sqrt{\frac{\like\pr}{Z_\delta}} - \sqrt{\frac{\like_\delta\pr}{Z_\delta}}\Biggr\|_{L^2}=\frac{1}{\sqrt{Z_\delta}}\Bigg(\int\Bigl|\sqrt{\like(u)}- \sqrt{\like_\delta(u)}\Bigr|^2 \pr(u) \, du\Bigg)^{1/2} \leq \sqrt{\frac{K_1^2}{c_2}}\delta.\]
      Therefore
      \[\dhell(\post^y,\post_\delta^y)\leq \frac{1}{\sqrt{2}}\frac{c_1}{2c_2}\delta+\frac{1}{\sqrt{2}}\sqrt{\frac{K_1^2}{c_2}}\delta=c \delta,\]
      with $c=\frac{1}{\sqrt{2}}\frac{c_1}{2c_2}+\frac{1}{\sqrt{2}}\sqrt{\frac{K_1^2}{c_2}}$ independent of $\delta$.
      \end{proof}

      \section{\index{forward!model} Accelerating MAP Estimation}\label{sec:LForward2}
This section is centred on the approach to model error described in Subsection \ref{ssec:UTH}.
For this purpose, recall the Bayesian inverse problem to jointly estimate unknown parameter 
$u$ and unknown model error parameter $\alpha$ defined in \eqref{eq:bayesformula4}. 
Thus we have access to a parameterized family of computational models 
$\Gs(\cdot; \alpha):\Ru \times \R^p \to \Ry$, for $\alpha \in \R^p.$ 
Our data assumption is as follows:

\begin{dataassumption}
    \label{da:surrogate2} Data is available in the form 
\begin{align}
\label{eq:datafsm2}
\Bigl\{\un, \alpha^{(n)}, y^{(n)} \Bigr\}_{n=1}^N,
\end{align}
where the $\{\un, \alpha^{(n)}\}_{n=1}^N$ 
are generated \index{i.i.d.}i.i.d. from probability density function $\Upsilon \otimes q \in \cP(D \times \R^p)$, for some $D \subseteq \R^d,$ and where
$y^{(n)}=\Gs(\un,\alpha^{(n)}).$
\end{dataassumption}

From this we may learn a cheap surrogate for $\Gs,$ using
the techniques of Chapter \ref{ch:SL}. This may be used to
accelerate Bayesian inference for $\bbP(u,\alpha|y),$ similarly
to what is outlined in the previous section. Here we provide another
example of the value of surrogate modeling by focussing, instead,
on the MAP estimation problem.



The MAP estimation problem requires minimization, over the pair 
$(u,\alpha)$, of
$$\J(u,\alpha)=-\log \noise\bigl(y - \Gs(u,\alpha)\bigr)-\log \pr(u,\alpha).$$
Some methods for this problem work by alternating minimization over
$u$ and over $\alpha$; a prototypical such method is to iterate, for $\ell$
until convergence, starting from initial $\alpha^0 \in \R^p:$
    \begin{align*}
        u^{\ell +1 }&\in\arg \min_{u \in \Ru} \J \bigl(u,\alpha^{\ell} \bigr),\\
        \alpha^{\ell+1}&\in \arg \min_{\alpha \in \R^p} \J \bigl(u^{\ell+1},\alpha \bigr).
    \end{align*}
For each $\ell,$ multiple evaluations of $\Gs(\cdot,\cdot)$ may be required
and use of a surrogate may make the method more efficient.

      





\section{Bibliography}
\label{sec:sbib}

Using emulators to speed up forward model evaluations, for
example in the context of \index{likelihood}likelihood evaluation in \index{Bayesian!inversion}Bayesian inversion, was first introduced as a systematic methodology in \cite{sacks1989design},
and taken further in the realm of \index{Bayesian}Bayesian \index{model error}model error estimation
in \cite{kennedy2001bayesian}. The paper \cite{stuart2018posterior}
studies the use of \index{Gaussian!process}Gaussian processes for emulation, and derives
errors bounds quantifying the effect of emulation error 
on the \index{posterior}posterior. The methodology is developed for a range of applications 
in the geosciences in \cite{cleary2021calibrate}; in particular that paper addresses the issue
of how to determine $\Upsilon$ in tandem with solution of the inverse problem as discussed
in Remark \ref{rem:ce}.
A specific application of the idea in climate science may 
be found in \cite{dunbar2021calibration}. Data-driven discretizations of \index{forward!model}forward models for \index{Bayesian!inversion}Bayesian inversion are studied in \cite{bigoni2020data}.
A recent approach to directly learning parameter to solution (forward) and solution to parameter (inverse)
surrogate maps may be found in \cite{vadeboncoeur2023fully}. 

An important aspect of learning forward models is to choose the pair of supervised training data over which we would like to find an accurate surrogate model. While we would ideally like to be accurate over the support of the posterior, finding such a surrogate model requires being able to sample the posterior. Instead, it is common to seek the approximate surrogate model to be accurate over the support of the prior. To address this, several recent methods use approximate posteriors to iteratively refine the approximation of the surrogate model~\cite{cleary2021calibrate, helin2023introduction}.

\chapter{\Large{\sffamily{Learning Prior and Regularizers}}}


In Bayesian inference the prior acts as a form of regularization.
This can be seen explicitly in two ways.
First, by considering MAP estimation as described in Section \ref{sec:112}, where the objective function to be minimized
is the sum of two terms, one of which, the regularizer, is the
negative logarithm of the prior $\pr.$ 
Second, by considering the variational
form of Bayes theorem as described in Remark \ref{rem:2.3},
 where the posterior minimizes an objective over probability densities comprising two terms, one of which,
the regularizer, is the KL divergence\index{divergence!Kullback--Leibler} between the putative minimizer $q$ and the prior $\pr.$
However, defining a prior from data can be challenging. Often
modellers make simple choices, such as Gaussians, because this
limits the space of potential regularizers to consider. Here we consider data-driven approaches to determining the prior.

In Section \ref{sec:LP} we discuss learning the prior measure from data, relating this problem to the unsupervised learning task studied in Chapter \ref{ch:UL}. Then, in Section \ref{sec:pertp3}, we discuss representing the prior via a pushforward, a setting that often arises
when the prior is learned from data as a transport. Section \ref{sec:pertp} contains a theoretical analysis of the
effect of errors in the prior on errors in the posterior. 
Section \ref{sec:RMAP} is devoted to finding regularizers for MAP
estimation. This topic is generalized in Section \ref{sec:carGB}
to a probabilistic setting. Section \ref{sec:pbib} contains concluding
bibliographic remarks. We make three separate data assumptions:
Data Assumption \ref{da:4a} in Sections \ref{sec:LP} and \ref{sec:pertp}; Data Assumption \ref{da:4b} in Section \ref{sec:RMAP} and Data Assumption \ref{a:LBI0} in Section \ref{sec:carGB}.

\section{Learning the \index{prior}Prior}\label{sec:LP}
Recall the Bayesian \index{inverse problem!Bayesian}inverse problem of finding $u \in \R^d$ from $y \in \R^k$ 
when related by \eqref{eq:jc0}, so that $$y=G(u)+\eta.$$ 
Under the assumptions of Theorem \ref{t:bayes}, the \index{posterior}posterior distribution  is given by \eqref{eq:bayesformula}:
\begin{equation}
\label{eq:cf1}
 \post(u) = \frac{1}{Z} \noise\bigl(y - G(u)\bigr)\pr(u);
\end{equation}
we have dropped the explicit dependence of the \index{posterior}posterior on $y$ 
for notational convenience. In this section we describe the idea of learning 
the prior from data. We make the following data assumption to
enable this:

\begin{dataassumption}
\label{da:4a} We are given samples $\{u^{(n)}\}_{n=1}^N$ assumed
to be drawn i.i.d. from prior measure $\rho$ on $u$ which is unknown.
\end{dataassumption}

Compare this to Data Assumption \ref{assumption:unsupervised} in Chapter \ref{ch:UL}, which arises in unsupervised learning, and notice that both assumptions are identical by taking $\Upsilon := \rho.$
Thus in this chapter we assume that the prior is only given to us through data, and we may seek to approximate it using the generative modelling\index{generative modelling} techniques of Chapter \ref{ch:UL}.
To clearly understand the methodology of this section
 it is important to distinguish between the one piece of data, $y$,
for which we wish to solve the inverse problem defined by 
\eqref{eq:jc0},  and the
\emph{training data}\index{training data} $\{u^{(n)}\}_{n=1}^N$ which we assume 
are available to us, and which we use to learn about the prior.


\section{Representing the Prior via a Pushforward}
\label{sec:pertp3}
Our focus is on the posterior distribution $\post$ defined from the prior $\pr$ by
\eqref{eq:cf1}:
\begin{equation*}
 \post(u) = \frac{1}{Z} \noise\bigl(y - G(u)\bigr)\pr(u).
\end{equation*}
When the prior $\pr$ is only known through an empirical approximation $\pr^N \approx \pr$  
it is possible to use ideas from transport\index{transport},
described in Chapter \ref{ch:UL}, to find map $g$ that (approximately) pushes forward a given density 
 $\zeta$ on latent
space $\R^{\dz}$ into the prior; that is, $\pr \approx g_\sharp \zeta.$ In the remainder of
this section we assume that $\pr = g_\sharp \zeta,$ noting that the effects of approximating
this identity will be discussed in the next section. Regarding
the pushforward representation of the prior we have the following useful result:

\begin{proposition}
\label{prop:push}
Let $ \dz  =d$ and assume that  $\pr=g_\sharp \zeta$ and that $g$ is invertible.
Define
\begin{equation}
\label{eq:cf2}
 \postg(z) = \frac{1}{Z} \noise\Bigl(y - G\bigl(g(z)\bigr)\Bigr)\zeta(z).
\end{equation}
It follows that $\post=g_\sharp \postg.$ 
\end{proposition}
\begin{remark}
\label{rem:push}
The significance of Proposition \ref{prop:push} is that it implies that we can
solve the Bayesian inverse problem \eqref{eq:cf2}, posed in the latent space, and push forward under
$g$ to find solutions of the original Bayesian inverse problem defined
by \eqref{eq:cf1}. For example if we generate samples under $\postg$ in the latent space, then application of $g$ to those samples will generate samples
under $\post$ in the original space. 

Hence,
if pair $(g,\zeta)$ are known, then the original \index{Bayesian!inverse problem}Bayesian 
inverse problem for $\post$ on $\R^d$
may be converted to one for $\postg$ on $\R^{\dz}$;
pushforward\index{pushforward} of $\postg$ under $g$ yields solution to the original problem. A similar expression to \eqref{eq:cf2} may be established even if $\dz <d$, but it no longer follows that $\post=g_\sharp \postg$ because $g$ is not invertible.
\end{remark}

\begin{proof}[Proof of Proposition \ref{prop:push}]
From Lemma \ref{lem:cov} with $u=g(z)$, and \eqref{eq:cov} in particular, 
\begin{align*}
g_\sharp \postg(u)&= \bigl(\postg \circ g^{-1}\bigr)(u) {\rm det} 
D\bigl(g^{-1}\bigr)(u)\\
&= \frac{1}{Z} \noise\bigl(y - G(u)\bigr) \bigl(\zeta \circ g^{-1}\bigr)(u) 
{\rm det} D\bigl(g^{-1}\bigr)(u)\\ 
&= \frac{1}{Z} \noise\bigl(y - G(u)\bigr) g_\sharp \zeta(u)\\ 
&= \frac{1}{Z} \noise\bigl(y - G(u)\bigr) \pr(u),\\
&= \post(u) 
\end{align*}
as required.
\end{proof}






\section{Perturbations to the Prior}
\label{sec:pertp}



Remark \ref{rem:push} shows that, if we learn an exact transport map $g$ satisfying $\rho = g_\sharp \zeta,$ then we 
have access to the true posterior with prior $\pr.$ In practice, however,
we learn $g$ from $\pr^N \approx \pr$ and so we cannot hope to recover an exact transport map; the issue of lack of exactness is further compounded by only learning the transport map over a parametric family of densities and by not iterating
the optimization solver to convergence. In Subsections \ref{ssec:pertp1} 
and \ref{ssec:pertp2} we prove two theorems which address this effect. 
In Theorem \ref{thm:prior_stability} we assume that the approximation of
the exact transport map leads to an approximate smooth prior, in the space of $u$, and look at
the effect on the posterior on the distance between this prior and the true prior.
In Theorem \ref{thm:emp_prior_perturbation} we study a related problem, namely the
effect on the posterior of replacing the prior by an empirical approximation.


\subsection{Smooth Approximation of the Prior}
\label{ssec:pertp1}


Consider the inverse problem arising for use of a smooth approximate prior $\pr' \approx \pr.$
This gives rise to an approximate posterior, $\post':$
\begin{equation}
\label{eq:cf11}
 \post'(u) = \frac{1}{Z'} \noise\bigl(y - G(u)\bigr)\pr'(u).
\end{equation}
It is thus important to know that a small change in the prior leads
to a small change in the posterior. We prove this in the following
theorem which exhibits conditions under which the prior to posterior
map is Lipschitz in the Hellinger metric. In the proof of the theorem,
and conditions that precede it, we let $\like(u)=\noise\bigl(y - G(u)\bigr)$, suppressing dependence on $y$.

\begin{assumption}\label{a:dh2L}
The \index{prior}prior distributions $\pr$ and $\pr'$ are both supported on bounded open set $D \subset \Ru$. There exists $K \in (0,\infty)$ such that $\sup_{u \in D}\like(u)=K.$
\end{assumption}

\begin{theorem} \label{thm:prior_stability} Let Assumption \ref{a:dh2L} hold. Consider posteriors
$\post, \post'$ in \eqref{eq:cf1}, \eqref{eq:cf11} corresponding, respectively, to priors
$\pr, \pr'$. Then, we have
\begin{equation}
\dhell(\post,\post') \leq \left(\frac{2K}{(\sqrt{Z} + \sqrt{Z'}) \sqrt{Z'}} + \frac{\sqrt{K}}{\sqrt{Z'}} \right) \dhell(\pr,\pr').
\end{equation}
\end{theorem}

\begin{proof} In the proof all $L^2$ norms are over domain $D$ and all integrals are restricted to domain $D$. With this notation we have that
\begin{align*}
    \dhell(\post,\post') &= \frac{1}{\sqrt{2}}\left\|\sqrt{\frac{\like\pr}{Z}} - \sqrt{\frac{\like\pr'}{Z'}} \right\|_{L^2} \\
    &\leq \frac{1}{\sqrt{2}}\left\|\sqrt{\frac{\like\pr}{Z}} - \sqrt{\frac{\like\pr}{Z'}} \right\|_{L^2} + \frac{1}{\sqrt{2}}\left\|\sqrt{\frac{\like\pr}{Z'}} - \sqrt{\frac{\like\pr'}{Z'}} \right\|_{L^2} \\
    &= \frac{1}{\sqrt{2}}\left|\frac{1}{\sqrt{Z}} - \frac{1}{\sqrt{Z'}} \right| \sqrt{Z}+ \frac{1}{\sqrt{2}\sqrt{Z'}}\|\sqrt{\like\pr} - \sqrt{\like\pr'}\|_{L^2}.
\end{align*}
The first term can be written as $$\left|\frac{1}{\sqrt{Z}} - \frac{1}{\sqrt{Z'}} \right| \sqrt{Z} = \frac{|Z - Z'|}{(\sqrt{Z} + \sqrt{Z'})\sqrt{Z'}}.$$ The 
difference between the normalization constants can be bounded, using Lemma
\ref{l:dh1}, by 
\begin{align*}
    |Z - Z'| &\le \int |\like(u)\pr(u) - \like(u)\pr'(u)| \, du \\
    &\leq K \int |\pr(u) - \pr'(u)| \, du \\
    &= 2K \dtv(\pr,\pr') \\
    &\leq 2K\sqrt{2} \dhell(\pr,\pr').
\end{align*}
For the second term, we have 
$$\|\sqrt{\like \pr} - \sqrt{\like \pr'} \|_{L^2} \leq \sqrt{K}\|\sqrt{\pr} - \sqrt{\pr'}\|_{L^2} = \sqrt{2K}\dhell(\pr,\pr').$$
Collecting the bounds for the two terms, we obtain the result.
\end{proof}

\subsection{Empirical Approximation of the Prior}
\label{ssec:pertp2}

Theorem~\ref{thm:prior_stability} applies with priors $\pr,\pr'$ that have a probability density function. 
Here we consider the setting where the approximate prior is specified empirically by a collection random samples $u^{(n)}$ for $n = 1,\dots,N$ from the true prior $\pr$.
Then we have the \emph{random probability measure}\index{probability measure! random}
$$\pr^N(u) = \frac{1}{N}\sum_{n=1}^N \delta(u - u^{(n)}).$$
With this prior we obtain posterior
\begin{equation}
\label{eq:cf12}
 \post^N(u) = \frac{1}{Z} \noise\bigl(y - G(u)\bigr)\pr^N(u).
\end{equation}
We wish to compare $\post$ with $\post^N$. 
In this setting, it is natural to use the following metric from Subsection \ref{ssec:rpm}:
\begin{equation}
    \label{eq:rpmd}
d(\post,\post^N) = \sup_{|f|_{\infty} \leq 1} \left|\mathbb{E}\left[\left(\post(f) - \post'(f)\right)^2\right]\right|^{1/2},
\end{equation}
where $\pi(f):= \mathbb{E}^{u \sim \pi}[f(u)]$ and $\pi^N(f):= \mathbb{E}^{u \sim \pi^N}[f(u)]$. 
We note, because it will be useful in what follows, that 
\begin{equation}
    \label{eq:rpmd2}
\sup_{|f|_{\infty} \leq F} \left|\mathbb{E}\left[\left(\post(f) - \post^N(f)\right)^2\right]\right|^{1/2} \le F\,d(\post,\post^N).
\end{equation}
Recall that this reduces to the total variation metric for non-random
measures as discussed in
Remark \ref{rem:rtv}; and that, furthermore, the square root of the total
variation metric upper bounds the Hellinger metric, by Lemma \ref{l:dh1}.

The following proposition uses this metric on random probability
measures to quantify the distance between the true and approximate posterior when one prior is specified using samples:

\begin{theorem} \label{thm:emp_prior_perturbation} Let Assumption~\ref{a:dh2L} hold and let $\post,\post^N$ be the posteriors given by \eqref{eq:cf1} and \eqref{eq:cf12} respectively. Then,
\begin{equation} \label{eq:emp_prior_stability}
d(\post,\post^N) \leq \frac{2K}{Z}d(\pr,\pr^N).
\end{equation}
\end{theorem}




\begin{proof} For the true and approximate posterior, we can write the integrals required to estimate
$d(\post,\post^N)$, with distance given in \eqref{eq:rpmd}, by
$$\post(f) = \frac{\pr(\like f)}{\pr(\like)},\quad \post^N(f) = \frac{\pr^N(\like f)}{\pr^N (\like)}.$$
Then we have
\begin{align*}
    \post(f) - \post^N(f) &= \frac{\pr(\like f)}{\pr(\like)} -   \frac{\pr^N(\like f)}{\pr^N (f)}\\
    &= \frac{\pr(\like f) - \pr^N(\like f)}{\pr(\like)} - \frac{\pr^N(\like f)\bigl(\pr(\like) - \pr^N(\like)\bigr)}{\pr(\like)\pr^N(\like)}\\
    &= \frac{\pr(\like f) - \pr^N(\like f)}{\pr(\like)} - \frac{\post^N(f)\bigl(\pr(\like) - \pr^N(\like)\bigr)}{\pr(\like)}. 
\end{align*}
Using the basic inequality $(a-b)^2 \leq 2(a^2 + b^2)$, \eqref{eq:rpmd2}, that $|\post^N(f)|^2 \leq 1$ for all $|f|_{\infty} \leq 1$ and that $|\like|_{\infty}|, |\like f|_{\infty} \leq K$ 
\begin{align*}
    \left|\mathbb{E}\left[\left(\post(f) - \post'(f)\right)^2\right]\right| &\leq \frac{2}{\pr(\like)^2} \Biggl(\mathbb{E}\Bigl[\bigl(\pr(\like f) - \pr^N(\like f)\bigr)^2\Bigr] + \mathbb{E}\left[ \bigl(\post^N(f)\bigr)^2 \bigl(\pr(\like) - \pr^N(\like) \bigr)^2\right] \Biggr) \\
   &\leq \frac{4K^2}{\pr(\like)^2} d(\pr,\pr^N)^2.
\end{align*}
Taking the supremum over test functions on the left-hand side and using that $\pr(\like) = Z$ gives us the desired result.
\end{proof}

We note that so far we did not specify how the samples $u^{(n)}$ defining the perturbed prior $\pr^N$ were generated. In fact, the result above holds for any empirical measure. If $u^{(n)} \sim \post$ are sampled i.i.d., however, $\pr^N$ is a Monte Carlo approximation of $\pr$. Moreover, we can appeal to convergence results for Monte Carlo to show the convergence rate of $\post^N$ to the true posterior $\post$.

\begin{corollary} Let $\pr^N$ be a Monte Carlo estimator of $\pr$ in Theorem~\ref{thm:emp_prior_perturbation}. Then, we have 
$$d(\post,\post^N) \leq \frac{2K}{Z}\frac{1}{\sqrt{N}}.$$
\end{corollary}

\begin{proof} By Theorem \ref{t:MC},  $d(\pr,\pr^N)^2 \leq \frac{1}{N}$. Using this in the right-hand side of~\eqref{eq:emp_prior_stability} gives the desired result.
\end{proof}





\section{Learning Regularizers for MAP Estimation\index{MAP estimator}}
\label{sec:RMAP}

Again recall the \index{inverse problem}inverse problem of finding $u \in \R^d$ from $y \in \R^k$ 
when related by \eqref{eq:jc0}: $$y=G(u)+\eta.$$
We describe the idea of bilevel optimization\index{optimization!bilevel} to determine
parameter $\theta \in \Theta \subseteq \R^p$ defining a regularizer in MAP\index{MAP estimator} estimation. The data assumption here differs from
that employed in Section \ref{sec:LP}. We now assume
(see Remark \ref{rem:minus1}): 

\begin{dataassumption}
\label{da:4b} We are given samples $\{y^{(n)},u^{(n)}\}_{n=1}^N$ assumed to be drawn i.i.d. from
the joint probability distribution $\joint$ on $(y,u) \in \Ry \times \Ru$ defined by equation \eqref{a:jc1} and Assumption \ref{a:jc1}.
\end{dataassumption}





Such data is exactly what is required for
the ideas of supervised learning from Chapter \ref{ch:SL}, where
we use it to learn map from $u \in \R^\du$ to $y \in \R$, though this is readily
generalized to vector-valued output $y$.
Note that, to solve the inverse problem, we would like 
to learn the inverse map from the data  $y \in \R^\dy$ to
the state  $u \in \R^\du.$ We could try and do this directly using supervised
learning. However, for inverse problems in which $\dy<\du$
learning such a map may be difficult because of a lack of uniqueness; furthermore there is
noise present in the $y^{(n)}$ which needs to be carefully accounted for.
For these reasons it is arguably more informative to learn, from
the supervised data defined by Data Assumption \ref{da:4b}, how to regularize the inverse problem. 
This is the viewpoint we take here.

To understand the proposed methodology
clearly it is important to distinguish between the one piece of data $y$
for which we wish to solve the inverse problem defined by 
\eqref{eq:jc0}  and the
\emph{training data pairs} $\{ u^{(n)},y^{(n)}\}_{n=1}^N$ 
(supervised data) which we assume 
are available to us, and which we use to learn the regularizer.
This is different from the previous sections in this chapter where the training data
from which we learn or define the prior was unsupervised data $\{u^{(n)}\}_{n=1}^N.$





We recall the \index{posterior}posterior probability density function $\post^y(u)$ on $u|y$ from \index{Bayes theorem}Theorem \ref{t:bayes}, but assume that prior $\pr$
depends on an unknown parameter $\theta \in \Theta \subseteq \R^p$ so that the posterior has form 
\begin{equation} \label{eq:param_posterior}
\post^y (\vct u;\theta) = \frac{1}{Z(\theta)} \noise \bigl(\vct y- \vct G(\vct u) \bigr) \pr (\vct u;\theta).
\end{equation}
We will determine $\theta$ by choosing it
so that MAP estimators for the inverse problem defined by data $y^{(n)}$ best match the paired data point $u^{(n)}$. 

To this end recall the  \index{loss}\emph{loss function} $\loss$ on 
data space $\Ry$
and the now $\theta-$dependent \emph{regularizer}\index{regularizer}
$\reg$ defined by
\begin{equation}
\label{eq:lossandreg}
\loss (\vct u;y) = - \log \noise \bigl(\vct y-\vct G(\vct u)\bigr)= - \log \like(y|u), \quad \reg(\vct u;\theta) = - \log \pr(\vct u;\theta),
\end{equation}
leading to
an \index{objective}\emph{objective function} of the form
\begin{equation}
\label{eq:MAPP}
\J(\vct u;y,\theta) = \loss(\vct u;y) + \reg(\vct u;\theta).
\end{equation}
We have reverted to including the $y-$dependence in the likelihood.
Note that we have also emphasized the parametric dependence of the loss and the objective function on $y \in \Ry$, something we did not do in Section \ref{sec:112}.
The \index{MAP estimator}MAP estimator can be viewed as a function, for each $\theta,$ 
$\umap(\cdot; \theta): \Ry \to \Ru$:
\begin{align*}
\umap(y;\theta) & \in \arg \min_{u \in \Ru} \J(u;y,\theta).
\end{align*} 

We now introduce a loss function defined through a distance-like deterministic
scoring rule  $\D: \Ru \times \Ru \to \R^+,$  as defined in Definition \ref{def:det_score}; the canonical example is the squared Euclidean norm. We then define the choice of $\theta$ through the optimization problem
\begin{align*}
\thetas &\in \arg \min_{\theta \in \Theta} \bbE^{(y,u) \sim \joint}\, \D\bigl(u,\umap(y;\theta)\bigr).
\end{align*} 


This is referred to as bilevel optimization\index{optimization!bilevel} because of the optimization to
find $\umap$ which is used within the optimization
to find $\thetas$. This procedure corresponds to hyperparameter tuning of $\theta$ on the validation set $\{y^{(n)}, u^{(n)}\}_{n=1}^N$. In practice the determination of $\thetas$ is implemented using $\joint^N$ in place of $\joint:$
\begin{align*}
\thetas &\in \arg \min_{\theta \in \Theta} \frac{1}{N}\sum_{n=1}^N \D\bigl(u^{(n)},\umap(y^{(n)};\theta)\bigr).
\end{align*} 

\section{Learning Regularizers for Posterior Approximation}
\label{sec:carGB}

In this section we generalize the setting from the previous one to the more general problem of learning parameters in the prior to best approximate the posterior. We work under the following data assumption. 

\begin{dataassumption}
\label{a:LBI0}
We are able to evaluate the likelihood $\like(y|u)$ for any
pair $(y,u) \in \R^\dy \times \R^\du.$ We are given data in the form of samples $\{y^{(n)}\}$ 
from the marginal distribution $\marg$ and samples $\{u^{(n)}\}$ 
from the prior distribution $\pr.$
\end{dataassumption}


It is again helpful to recall the notation from Remark \ref{rem:minus1}. The goal is to choose parameters $\theta$ in the prior so that the resulting posterior $\post^y(u;\theta)$ in~\eqref{eq:param_posterior} is as close as possible to the true posterior $\post^y(u)$ corresponding to the joint distribution $\joint(y,u) = \Prob(y|u)\pr(u)$ underlying the data given in Data Assumption \ref{a:LBI0}. We 
identify the parameters by minimizing the posterior error with respect to the KL divergence,
in expectation over the data marginal on $y$ which, recall, has probability density function $\marg$:
\begin{equation} \label{eq:expected_KLdiv}
    \J(\theta):=\mathbb{E}^{y}\Bigl[ \dkl\bigl(\post^y\|\post^y(\cdot;\theta)\bigr)\Bigr] = \int \left[\int  \log \left(\frac{\post^y(u)}{\post^y(u;\theta)}\right) \post^y(u) du \right] \marg(y)\, dy.
\end{equation}
Let
\begin{equation} \label{eq:optimal_parameters_paramprior}
\thetas \in \argmin_{\theta \in \Theta} \J(\theta).
\end{equation}

The following result shows that the optimal parameters can be computed without needing to evaluate the true posterior density. 
\begin{theorem} The optimal parameter $\thetas$ in~\eqref{eq:optimal_parameters_paramprior} corresponds to the solution of the optimization problem
$$\thetas \in \argmin_{\theta \in \Theta} \biggl(\mathbb{E}^{u \sim \pr} \left[-\log\pr(u;\theta)\right] + \mathbb{E}^{y \sim \marg}\left[\log \int \nu\bigl(y - G(u')\bigr) \pr(u';\theta)\, du' \right]\biggr).$$
\end{theorem}

\begin{proof} First note that $\joint(y,u)=\post^y(u)\marg(y).$ The expected KL divergence in~\eqref{eq:expected_KLdiv} can be decomposed into two terms as
\begin{align} \label{eq:KLdecomposition_approxprior}
    \mathbb{E}^{y}\Bigl[\dkl\bigl(\post^y \|\post_\theta^y(\cdot;\theta)\bigr)\Bigr] &=  \int \joint(y,u)\left[ \log\left(\frac{\like(y|u)\pr(u)}{Z^y}\right) \nonumber - \log\left(\frac{\like(y|u)\pr(u;\theta)}{Z^y(\theta)}\right)\right] \, dudy \\ 
    &= \int \joint(y,u)\Bigl[\bigl(\log \pr(u) - \log Z^y\bigr) - \bigl(\log \pr(u;\theta) - \log Z^y(\theta)\bigr) \Bigr] \, dudy.
\end{align}
Noticing that the first two terms are constant with respect to $\theta$, we only need to minimize with respect to the second term. That is,
$$\thetas \in \argmin_{\theta \in \Theta} \int \joint(y,u) \left[-\log\pr(u;\theta) + \log Z^y(\theta) \right] \, du dy.$$
Using the form of the normalizing constant $Z^y(\theta) = \int \nu\bigl(y - G(u')\bigr)\pr(u';\theta) \, du'$, we arrive at the objective above, after noticing that in the first term integration over $y$ is redundant, and in the
second integration over $u$ is redundant.
\end{proof}

\begin{remark} The expected KL divergence in~\eqref{eq:KLdecomposition_approxprior} can also be written as 
\begin{align*}
    \mathbb{E}^{y}\Bigl[ \dkl\bigl(\post^y \|\post_\theta^y(\cdot;\theta)\bigr) \Bigr] &= \int \pr(u)\left[\log \pr(u) - \log \pr(u;\theta)\right] \, du + \int \marg(y) \log \Biggl(\frac{Z^y(\theta)}{Z^y} \Biggr) \, dy.\\
    &= \dkl \bigl(\pr \|\pr(\cdot;\theta)\bigr) - \dkl \bigl(\marg \|\marg(\cdot;\theta)\bigr),
\end{align*}
where in the last line we recognize that the normalizing constants $Z^y, Z^y(\theta)$ are equivalent to the marginal distributions of the observations $\marg(y) = \int \nu\bigl(y - G(u')\bigr)\pr(u') \, du'$ and $\marg(y;\theta) = \int \nu\bigl(y - G(u')\bigr)\pr(u';\theta) \, du'$, respectively. Thus, the objective in~\eqref{eq:expected_KLdiv} involves two competing terms, the first relating only to the prior and the second only to the likelihood.
\end{remark}

\section{Bibliography}
\label{sec:pbib}

The idea of learning \index{prior}prior probabilistic models from data is
overviewed in \cite{asim2020invertible}. An application is
described in \cite{patel2021gan} where a \index{generative adversarial network}generative adversarial
network  (GAN) is used to determine a mapping from a \index{Gaussian}Gaussian
to the space of \index{prior}prior data samples. The paper \cite{gao2023image} also implicitly learns
a prior, through simultaneous consideration of multiple inverse problems; but it also learns the
posterior distribution for each of these inverse problems at the same time, linking to 
the two subsequent Chapters \ref{ch:transport} and \ref{ch:data-dependence}.
Many methods of this type
reduce the dimension of the unknown parameter space, determining
a \index{latent}latent space of low effective dimension. A different approach to learning this mapping is to use invertible maps
\cite{kingma2018glow} and the work on
\index{normalizing flow}normalizing flows \cite{tabak2010density,song2020score};
see \cite{asim2020invertible} for application of invertible
maps to \index{prior}prior construction for inversion. 
This idea can be combined with \index{variational!Bayesian method}variational inference to solve
\index{sampling}sampling problems in general, and \index{inverse problem}inverse problems in particular
\cite{rezende2015variational,sun2020deep,gabrie2021efficient,ongie2020deep}.
The use of triangular \index{transport}transport maps for \index{Bayesian!inference}Bayesian inference was introduced in \cite{el2012bayesian}.

The idea of learning regularizers from data, to define \index{objective}objective functions
for the optimization approach to inversion, is overviewed in
\cite{arridge2019solving} and~\cite{benning2018modern}. The paper \cite{soh2019learning} provides
a framework for the subject which employs structured factorizations of 
data matrices to learn semidefinite regularizers.
The paper \cite{lunz2018adversarial} develops an adversarial approach
to the problem. Inspired by the Neumann series, the work \cite{gilton2019neumann} proposes an end-to-end learning approach that utilizes data-driven nonlinear regularizers. 


A collection of stability results relating the posterior error to perturbations in the prior measure with respect to various metrics and divergences (e.g., KL divergence, $\chi^2$ divergence and Wasserstein-1 metric) can be found in~\cite{garbuno2023bayesian, sprungk2020local}. We refer to Chapter \ref{ch:distances} for background on these and other distances and divergences. While the stability results presented in this chapter are with respect to distance between two priors, the results can also be translated to stability with
respect to the distance between the transport maps that define the prior. A set of these stability results for various metrics and divergences can be found in~\cite{baptista2023approximation}.

\chapter{\Large{\sffamily{Transporting to the Posterior}}} \label{ch:transport}

In this chapter we formulate various transport approaches to determining the posterior distribution,
building on the material relating to transport in Chapter \ref{ch:UL}.
In Section \ref{sec:LPrtoPo} we discuss mapping the prior to the posterior. Section \ref{sec:cvi}
sets this work in the context of variational inference\index{variational inference}. In
Section \ref{sec:LOtoPo} we generalize and consider mapping general latent spaces, typically 
not the prior, to the posterior. Bibliographic remarks are contained in Section \ref{sec:tbib}.

\section{Learning the \index{prior}Prior to \index{posterior}Posterior Map}\label{sec:LPrtoPo}

Consider \index{Bayes theorem}Bayes theorem written as map relating \index{prior}prior $\pr$
to \index{posterior}posterior $\post$ via the relation
\begin{subequations}
\label{eq:thisagain}
\begin{align}
 \post(u) &= \frac{1}{Z} \like(u) \pr(u),\\
Z &= \bbE^{u \sim \pr}\, \bigl[ \like(u) \bigr].
\end{align}
\end{subequations}
We drop explicit dependence on $y$ since we do not exploit it in this chapter.
Equation~\eqref{eq:thisagain} defines a map $\pr \mapsto \post$ on the space of probability density functions. 
We now ask whether we can realize this map via an invertible
transport map $T$ on $\R^d$ with the property $\post=T_\sharp \pr;$ equivalently, since $T$ is invertible,
$\pr = (T^{-1})_\sharp \post$.  Specifically, following the approach in Section~\ref{sec:transport2} as outlined in Remark \ref{rem:invparam}, we seek to find 
$\theta \in \Theta \subseteq \R^p$ to minimize
\begin{equation}
\label{eq:waya}
\mathsf{F}(\theta)=\dkl\bigl(\pr \| T^{-1}(\cdot; \theta)_\sharp \post\bigr).
\end{equation}
From \eqref{eq:OT}, 
we deduce that minimizing $\mathsf{F}(\cdot)$ over a class of diffeomorphisms (i.e., differentiable and invertible maps) $T$ is equivalent to minimizing $\J(\cdot)$
given by
\begin{equation*}
\J(\theta) 
 =  -\bbE^{u \sim \pr} \Bigl[\log \post \circ T(u;\theta)+ \log {\rm det}  
D_u T(u;\theta) \Bigr].
\end{equation*}
Using the expression \eqref{eq:thisagain} for the \index{posterior}posterior in terms of 
the \index{prior}prior, and noting
that $Z$ is a constant with respect to $\theta$, we may instead write
\begin{equation}
\label{eq:OT50}
\J(\theta)
 =  -\bbE^{u \sim \pr} \Bigl[\log \pr \circ T(u;\theta)+ 
\log \like \circ T(u;\theta)+\log {\rm det}  
D_u T(u;\theta) \Bigr].
\end{equation}
Finally, we set
\begin{equation} \label{eq:optimal_parameters_paramprior2}
\thetas \in \argmin_{\theta \in \Theta} \J(\theta),
\end{equation}
and employ \index{transport}transport map $T^\star=T(\cdot;\thetas).$
We observe that it is not necessary to know the normalization constant
for the posterior in order to apply the methodology of this section. 

\begin{remark}
We have sought the \index{posterior}posterior as transport from the \index{prior}prior. This
is natural in applications where the \index{prior}prior distribution is easy to sample from,
and hence $\J(\theta)$ can be empirically approximated by Monte Carlo, for example.
A key advantage of seeking transports, rather than directly learning 
an approximation to $\pi$ as in Chapter~\ref{ch:VI}, is that it 
provides an easy approach to sample the posterior. In particular, 
if $z^{(n)} \sim \pr$ are i.i.d.\thinspace reference samples, 
then $T^\star \bigl(z^{(n)}\bigr) \sim \pi$ are i.i.d.\thinspace posterior samples. 
In this setting where $\pr$ corresponds to the prior density, 
we say that $T$ is a \emph{prior-to-posterior transport map.}\index{transport!prior-to-posterior}
\end{remark}

\begin{remark} The terms in objective~\eqref{eq:OT50} are competitive. Minimizing the first two terms
alone is achieved by setting $T(u;\theta) = u_{\rm MAP}$ for all $u \in \R^d$:
thus $T(u;\theta)$ maps to the MAP point of the posterior density, regardless of the input. On the
other hand, the third and last term ensures the map remains strictly monotone, i.e., $D_u T(u;\theta) \succ 0$ for all $u \in \R^d$. This ensures that the map does not concentrate mass at a single point by returning a constant (and hence, non-invertible) function. The optimal solution is an invertible map taking prior samples $u \sim \pr$ to 
samples from the posterior. 
\end{remark}

The following gives insight into how to parameterize the pushforward map $T$ if the posterior
density is log-concave, by considering minimization of $\J(\cdot)$ over an infinite class of transports:

\begin{theorem} 
\label{thm:tconvex}
If the posterior density $\pi^y(u) \propto \pr(u)\like(u)$ is log-concave, then the optimization problem
$$\argmin_{T \in \mathcal{T}} -\mathbb{E}^{u \sim \pr}\Bigl[\log\pr \circ T(u) + \log \like \circ T(u) + \log\det D_u T(u) \Bigr]$$
over the space of diffeomorphic, i.e., smooth and invertible, maps $$\mathcal{T} = \Bigl\{T \in C^1(\R^d;\R^d), \; \det D_u T(u) > 0 \text{ for all } u \in \R^d \Bigr\}$$
is convex.
\end{theorem}



\begin{proof} If $\pi^y(u)$ is log-concave, then $-\log\bigl(\pr(u)\like(u)\bigr) = -\log\pr(u) - \log\like(u)$ is convex. By the convexity of $u \mapsto -\log\pr(u) - \log\like(u)$ and $u \mapsto -\log\det(u)$ we have that $T \mapsto \mathbb{E}^{u \sim \pr}\bigl[-\log\pr\bigl(T(u)\bigr) - \log\like \bigl(T(u)\bigr) -\log\det D_u T(u)\bigr]$ is convex.

Given that $t T_1 + (1-t) T_2 \in \mathcal{T}$ for all $T_1,T_2 \in \mathcal{T}$ and $t \in [0,1]$, then $\mathcal{T}$ is a convex set. Then minimizing a convex functional over a convex set yields the result.
\end{proof}



\begin{remark} 
This theorem demonstrates that, if the posterior is log-concave, then 
parameterization of $\theta \mapsto T(u;\theta)$ restricted to $\mathcal{T}$ will lead to
a desirable objective function for the purpose of optimization.
If $\pi^y$ is not strongly log-concave, or the map parameterization $\theta \mapsto T(u;\theta)$ is not convex for all $u \in \R^d$, then the optimization problem of minimizing~\eqref{eq:OT50} is in general non-convex.
\end{remark}

\section{Connection to Variational Inference}
\label{sec:cvi}


 In this section we consider parameterized transports. Let 
$$\mathcal{T} := \Bigl\{T(\cdot;\theta) \in C^1(\R^d;\R^d), \theta \in \Theta \, \Bigl| \det D_u T(u;\theta) > 0 \text{ for all } (u,\theta) \in \R^d \times \Theta \Bigr\}$$ be a space of smooth and invertible maps depending on parameters $\theta$.

\begin{theorem} Let 
$\mathcal{Q} := \{q: q = T_\sharp \pr, T \in \mathcal{T} \}.$ Then, the optimal parameters $\thetas$
solving \eqref{eq:optimal_parameters_paramprior2}, with $\J(\cdot)$ defined by \eqref{eq:OT50},
also solve the variational inference problem 
$$\qs \in \argmin_{q \in \mathcal{Q}} \dkl(q\|\pi),$$
by setting $\qs \coloneqq T(\cdot;\thetas)_\sharp \pr$.
\end{theorem}




\begin{proof}
We showed above that solving the optimization problem \eqref{eq:optimal_parameters_paramprior2},
with $\J(\cdot)$ defined by \eqref{eq:OT50}, is equivalent to minimizing $\mathsf{F}(\cdot)$ from \eqref{eq:waya}.
But, from Theorem~\ref{thm:invariance} on the invariance of the KL divergence under invertible and differentiable transformations, we have that $$\dkl(\pr\|T^{-1}(\cdot,\theta)_\sharp \pi) = \dkl(T(\cdot;\theta)_\sharp \pr \|\pi).$$ Thus
$$\argmin_{\theta \in \Theta} \J(\theta) = \argmin_{\theta \in \Theta} \dkl(T(\cdot;\theta)_\sharp \pr \|\pi).$$
Lastly, $T(\cdot,\thetas): \Ru \to \Ru$ is a differentiable map, and its derivative has positive determinant; it
is thus an invertible map. Thus $T(u;\thetas)_\sharp \pr \in \mathcal{Q}$.  
\end{proof}

\begin{example}
\label{ex:cholGVI}
Consider the setting where the prior is a standard Gaussian $\cN(0,I).$
Now assume that that $T$ is affine:
$T(u) = Au + m$, for a positive definite matrix $D_u T(u) = A \in \mathbb{R}_{\geq 0}^{d \times d}$ and vector
$m \in \mathbb{R}^d$. An affine transformation of a standard Gaussian yields a Gaussian random variable. In fact, the class of approximate posterior distributions then consists of multivariate Gaussians of the form 
$$\mathcal{Q} = \Bigl\{q = \mathcal{N}(m, AA^\top), \; m \in \R^d, A \in \R_{\geq 0}^{d \times d} \Bigr\}.$$
Hence,  solving the optimization problem for $\J(\cdot)$ is equivalent to the Gaussian variational 
inference problem considered in Chapter \ref{ch:VI}, parameterizing the Gaussian covariance 
through a square root; for example it is possible to parameterize the covariance using its Cholesky factorization by considering triangular matrices $A \in \R^{d\times d}$ in $\mathcal{Q}$ with positive diagonal entries.
\end{example}

\begin{example} Let $\pr$ be a probability density function in the mean-field family in
Definition~\ref{d:qmf}. Furthermore let $T$ be a diagonal map of the form 
$T(u) = \bigl(T_1(u_1),\dots,T_d(u_d)\bigr)$ where $T_i \colon \R \rightarrow \R$ are 
univariate differentiable and invertible transformations: that is $D_{u_i} T_i(u_i) > 0$ for all $u_i \in \R$. 
Then, the class of approximate posterior distributions corresponds to
$$\mathcal{Q} = \left\{q(u) = \prod_i q_i(u_i), \; q_i = (T_i)_\sharp \pr_i \right\}.$$
\end{example}

\section{Learning Other \index{posterior}Posterior Maps}\label{sec:LOtoPo}

So far we looked for a map pushing forward the prior to the posterior. This is advantageous when we would like the posterior to inherit certain properties of the prior. For example, if the prior and posterior have the same tail behavior, then the transport map $T$ only needs to depart from an identity map in the bulk of the distribution. Similarly, if the posterior and prior only differ on a low-dimensional subspace of the parameters $u \in \R^d,$ then the map $T$ can be represented using a {\emph{ridge function}} \index{ridge function} that is constant for inputs orthogonal to the subspace of interest.

In some settings, it may be computationally expedient to seek $\post$
which is the pushforward\index{pushforward} of a different, easy-to-sample, reference density $\refT(u)$ on $\Ru$, (such as a multivariate Gaussian) rather than the prior $\pr(u)$ (when it is not Gaussian). This is particularly convenient when it is challenging to sample from the prior density. In these cases we may minimize a similar objective to~\eqref{eq:OT50} that changes only in the definition of the measure over which we take the expectation. That is, we may learn the parameters $\theta \in \Theta$ of the map $T$ by minimizing 
\begin{equation}
\J(\theta)
 =  -\bbE^{u \sim \refT} \Bigl[\log \pr \circ T(u;\theta)+ 
\log \like \circ T(u;\theta)+\log {\rm det}  
D_u T(u;\theta) \Bigr].
\end{equation}
Letting $\thetas$ denote the optimal parameters, the resulting posterior approximation is given by $\pi^y \approx T(\cdot,\thetas)_\sharp \refT$.

\begin{remark} Unlike the variational inference problem in Chapter~\ref{ch:VI}, we now have two degrees of freedom: the reference measure and the map. In principle, one may even parameterize the reference measure $\refT(\cdot,\vartheta)$ (e.g., as a mixture of Gaussians with unknown means, covariances, and mixture weights) and learn its parameters $\vartheta$ simultaneously to learning the map $T(\cdot,\theta)$. 
\end{remark}



\section{Bibliography}
\label{sec:tbib}

The approach to seek prior-to-posterior maps was proposed in~\cite{el2012bayesian}. In particular
that paper parameterized $T$ as a monotone-triangular map known as the Knothe-Rosenblatt rearrangement;
the advantage of this choice of map is that the determinant Jacobian, required to define the
minimization, is easy-to-evaluate. The approach was extended to compositions of triangular maps, 
commonly referred to as normalizing flows, in~\cite{rezende2015variational}. An approach to seek 
prior to posterior maps that are optimal with respect to minimizing a transportation distance (see Subsection \ref{sec:OPT} for a discussion on optimal transport) was proposed in~\cite{taghvaei2022optimal}.

An alternative to seeking the transport map is to construct the map incrementally by learning a map that is a small perturbation of the identity that minimizes the distance between the current approximation and the actual posterior distribution. Stein-Variational Gradient Descent is one such algorithm; it proceeds by seeking the map in a reproducing kernel Hilbert space in which the distance is measured by the KL divergence~\cite{liu2016stein}. Another approach learns the dynamics of a (possibly stochastic) differential equation to define the transport from its flow map as in~\cite{kerrigan2024dynamic, chemseddine2024conditional, albergostochastic}.

To handle certain classes of target distributions, it is sometimes desirable to consider objectives other than the KL divergence; examples include use of $\alpha$-divergences~\cite{hernandez2016black}, or the development of
tailored transport map approximations for heavy-tailed posteriors~\cite{liang2022fat}.

\chapter{\Large{\sffamily{Learning Dependence on Data}}}\label{ch:data-dependence}

Again our focus is on the inverse problem of finding $\post^y(u)$ given by
\begin{subequations}
\label{eq:thisagain2}
\begin{align}
 \post^y(u) &= \frac{1}{Z} \like(y|u) \pr(u),\\
Z &= \bbE^{u \sim \pr}\, \bigl[ \like(y|u) \bigr].
\end{align}
\end{subequations}
In this chapter, unlike the previous one, dependence of the target measure on $y$ is important,
and so we retain it explicitly in the notation $\post^y.$ Employing
the notation from 
Remark \ref{rem:minus1}, we describe the focus of this chapter.
We assume that $\post^y(u)$ is defined by conditioning
the joint distribution $\joint(y,u)$ on a specific realization $y;$ we recall that 
$\marg(y) = \int \joint(y,u) \, du$ denotes the marginal distribution for the observations.
Our goal, then, is to learn a map depending on the observation $y$ that can be used to sample from the posterior corresponding to \emph{any} realization of $y$. 
The resulting model can then be repeatedly used for different realizations, rather than having to re-learn a different map for each $y$. This reduces the cost of multiple inference procedures to training a single model. Hence it is known as \emph{amortized inference}\index{inference!amortized}. We will introduce approaches to amortized inference where the likelihood $\like(y|u)$ can be evaluated during training in Section~\ref{sec:likelihood-based}; and we will introduce likelihood-free approaches in Section~\ref{sec:likelihood-free}. In Section~\ref{sec:likelihood-free} we discuss the consequence of having block-triangular pushforwards;
and we discuss the learning of block-triangular transport maps, encoding data dependence in a natural way.
Section \ref{sec:LLM!} discusses the learning of likelihoods.
Our methodology sections conclude with a brief discussion of learning observation
data dependence on MAP estimators\index{MAP estimator} in Section~\ref{sec:MAPd}.
We end with Section \ref{sec:lfbib} containing bibliographic remarks.

\section{Likelihood-Based Inference} \label{sec:likelihood-based}

In this section we generalize variational inference\index{inference!variational} to learn the dependence of the optimal approximation on the data $y.$ Our assumptions
about the set-up in this section are as follows:

\begin{dataassumption}
\label{a:LBI}
We are able to evaluate the likelihood $\like(y|u)$ for any
pair $(y,u) \in \R^\dy \times \R^\du.$ We are given data in the form of independent samples $\{y^{(n)}\}_{n=1}^N$ 
from the marginal distribution $\marg$ and independent samples $\{u^{(n)}\}_{n=1}^N$ from the prior distribution $\pr.$
\end{dataassumption}

\begin{remark}
    In the preceding Data Assumption \ref{a:LBI} the set of independent samples $\{y^{(n)}\}_{n=1}^N$
    and the set of independent samples $\{u^{(n)}\}_{n=1}^N$ do not need to be independent of one another,
    and the same number of each is not required. However, in practice they are often found by marginalizing
    the data set  of samples $\{(y^{(n)},u^{(n)})\}_{n=1}^N$  from the joint distribution $\joint$ and then
    it is natural to have the same number of samples of each.
\end{remark}


With the goal of generalizing variational inference to learn the dependence of the optimal approximation on the data, we define the optimization problem
\begin{subequations}
\begin{align*}
    \qs &\in \argmin_{q \in \mathcal{Q}} \mathbb{E}^{y \sim \marg} \bigl[\dkl(q(\cdot;y)\|\post^y)\bigr].
\end{align*}  
\end{subequations}
As in standard variational inference from Chapter~\ref{ch:VI}, $\mathcal{Q}$ may for instance be the mean-field family or a parameterized family of probability density functions on $\Ru$. In the latter case, the parameters may be themselves be parameterized to reflect dependence on the observations $y \in \Ry$. 

\begin{example}
\label{rem:VIy}
This generalized variational inference problem can be implemented by seeking a mean-field approximation or a Gaussian approximation where the parameters are functions of the observations. For instance, $\mathcal{Q}$ may contain  multivariate Gaussian densities $q(\cdot;y) = \mathcal{N}\bigl(m(y),\Sigma(y)\bigr)$ where the mean $m(y)$ and covariance $\Sigma(y)$ depend on the observation. This dependence on $y$ will itself need to be parameterized,
for example as a linear function, or using neural networks, random features or Gaussian processes (see Chapter \ref{ch:SL}) constrained to ensure the covariance is a positive semi-definite matrix for all $y$.
\end{example}



Generalizing the transport approach to variational inference described in Chapter~\ref{ch:transport}, we can define the family of approximating distributions by using a transport map that pushes forward a simple reference distribution (for instance the prior $\pr$) and is also parameterized by $y.$ In this case, we seek a transport map $T \colon \R^{\du} \times \R^{\dy} \times \R^p \rightarrow \R^d$ that depends on both input parameters and observations so that $u \mapsto T(u;y,\theta)$ defines an invertible transport map approximating the pushforward of $\pr$ to the posterior $\pi^y(u)$, for each choice of the observations $y$. We seek this transport as the minimizer of the following objective
\begin{subequations}
\label{eq:thetaVIy}
\begin{align}
    \F(\theta) 
    &=\mathbb{E}^{y \sim \marg}\bigl[\dkl\bigl(T(\cdot;y,\theta)_\sharp \pr\|\pi^y\bigr)\bigr]\\
    &=  \mathbb{E}^{y \sim \marg}\bigl[\dkl\bigl(\pr \|T^{-1}(\cdot;y,\theta)_\sharp\pi^y\bigr)\bigr],\\
\thetas &\in \argmin_{\theta \in \Theta} \F(\theta),
\end{align}  
\end{subequations}
where $\Theta \subseteq \R^p.$ (In going from (\ref{eq:thetaVIy}a) to (\ref{eq:thetaVIy}b) we have used the
invariance of the KL divergence under invertible transformations, Theorem~\ref{thm:invariance}).
Following the approach in Chapter~\ref{ch:transport}, we can rewrite this objective for the parameters via minimization of a loss that may be approximated empirically: \footnote{This is the analog of equation~\eqref{eq:OT50}, the objective function in the case of a fixed single instance of data $y.$}
$$\J(\theta) = -\mathbb{E}^{(y,u) \sim \marg \otimes \pr}\Bigl[\log\rho\bigl(T(u;y,\theta)\bigr) + \log\like\bigl(y|T(u;y,\theta)\bigr) + \log\det D_u T(u;y,\theta) \Bigr].$$




\section{Likelihood-Free Inference} \label{sec:likelihood-free}

A common setting arising in many inverse problems is one in which
the likelihood $\like(y|u)$ is not analytically available or tractable to evaluate. We work in this section under the following assumption, which should be compared with Assumption \ref{a:LBI}.

\begin{dataassumption}
\label{a:LFI}
We are able to sample from the likelihood $\like(\cdot|u)$ for any $u \in \R^d.$ 
We are given data in the form of independent samples $\{(y^{(n)},u^{(n)})\}_{n=1}^N$ 
from the joint distribution $\joint.$
\end{dataassumption}

Thus here we show how to construct posterior approximations without requiring evaluations of $\like(\cdot|\cdot)$, unlike in Section~\ref{sec:likelihood-based}. Instead, we rely on sampling the joint distribution $\joint(y,u)$ to learn the dependence between states and observations. Sampling $\joint$ is 
feasible by sampling $u$ from the prior $\pr(u)$ and then sampling a 
synthetic observation $y$ from the likelihood model conditioned on $u$. Hence, this is known as \emph{likelihood-free}\index{inference!likelihood-free} or \emph{simulation-based}\index{inference!simulation-based} inference. 
Note, in particular, that we are assuming that sampling from the likelihood is
straightforward, even though evaluation of it is not.

\begin{remark} \label{rem:integrated_like}
The likelihood function may require marginalizing with respect 
to a latent random variable $z.$ That is,
\begin{equation} \label{eq:likelihood_latent}
  \like(y|u) = \int_{\R^{\dz}} \bbP(y|u,z)\bbP(z|u)\,dz.  
\end{equation}
When $\dz \gg 1$, it will be difficult to evaluate the integration over $z.$ But
we can simulate from the joint distribution $\bbP(y,u) = \like(y|u)\bbP(u),$ with likelihood 
as in \eqref{eq:likelihood_latent}, as follows. First sample $u$ from the prior $\pr$; 
then sample latent state $z$ from $\bbP(z|u)$;  and finally sample $y$ from 
$\bbP(y|u,z)$. The collection $(y,z,u)$ is a sample from the distribution $\Prob(y,z,u)$. The subset of pairs $(y,u)$ are then samples from the distribution $\like(y|u)\pr(u)$.
\end{remark}

\begin{example} \label{ex:integrated_like}
A likelihood with high-dimensional latent variables arises when performing parameter inference in a \emph{hidden Markov model}\index{hidden Markov model} given noisy observations of the hidden state. That is, let $z = (z_1,\dots,z_J)$ and $y = (y_1,\dots,y_J)$ be the states and observations of a dynamical system, respectively, with $z_j \in \R^{dz}$ and $y_j \in \R^\dy$. The states and observations follow the dynamics and observation models
\begin{align*}
    z_{j+1} &= \Psi(z_{j};u) + \xi_j, \quad \xi_j \sim \mathcal{N}(0,\Sigma), \\
    y_{j+1} &= h(z_{j+1}) + \eta_{j+1}, \quad \eta_{j+1} \sim \mathcal{N}(0,\Gamma), 
\end{align*}
for $j=0,\dots,J-1$ where $\Psi \colon \R^{d_z} \times \R^{\du} \rightarrow \R^{d_z}$ is a nonlinear map depending on the parameters $u$, the initial condition $z_0 \in \R^{d_z}$ is known, and $h \colon \R^{\du} \rightarrow \R^{\dy}$. The conditional probabilities in~\eqref{eq:likelihood_latent} have the closed forms
\begin{align*} \label{eq:likelihood_latent_elements}
   \bbP(y|u,z) &= \prod_{j=1}^{J} \mathcal{N} \bigl(y_{j}; h(z_j),\Gamma \bigr), \\
   \bbP(z|u) &= \prod_{j=0}^{J-1} \mathcal{N} \bigl(z_{j+1}; \Psi(z_j;u),\Sigma \bigr).
\end{align*}
However, the likelihood for the marginal variables is not available in closed-form due to the possible non-linearity in $\Psi$ and $h$.
\end{example}

\subsection{Consequences of Block-Triangular Pushforward}

In this setting the approach we introduce is to 
construct a map to approximate the joint distribution  $\joint(y,u)$
in such a way that we can extract the $y-$parameterized family of conditionals $\post^y(u)$. 
To this end, we make the following assumption:
\begin{assumption}
\label{a:blockt}
Let $\refT(y,u)=\refT_1(y)\refT_2(u)$ be a product reference density on $\Ry \times \Ru$
and $T\colon \Ry \times \Ru \to  \Ry \times \Ru$ be a transport map with the property 
that the joint density $\joint(y,u) = \marg(y)\pi^y(u)$ is a pushforward under $T$, i.e.,
$\joint = T_\sharp \refT.$ Assume also that $T$ is 
\emph{block-triangular}: \index{triangular!block}\footnote{The map is called block-triangular because, if the map is differentiable,
then its Jacobian is given by a block-triangular matrix.}
\begin{equation}
    \label{eq:trimap}
    T(y,u) = \begin{bmatrix*}[l] T_{1}(y) \\ T_{2}(y,u)\end{bmatrix*},
\end{equation}
where $T_1: \Ry  \to \Ry$ is invertible and $T_2(y,\cdot):\Ru \to \Ru$ is invertible for every $y \in \Ry.$
\end{assumption}

\begin{remark}
    \label{rem:inversemap_forpushforrward}
We discuss training based on the pushforward of a block-triangular map in Subsection
\ref{ssec:learning_maps}, a context in which $T^{-1}$ arises. To avoid inverting the map during training, it is often convenient to directly work with the inverse map $S \coloneqq T^{-1}$. For a block-triangular $T$, the inverse $S$ is also a block-triangular map of the form
\begin{equation}
    \label{eq:trimap_inverse}
    S(y,u) = \begin{bmatrix*}[l] S_{1}(y) \\ S_{2}(y,u)\end{bmatrix*},
\end{equation}
where $S_1: \R^\dy \to \R^\dy$ is the inverse of $T_1$ and $S_2(y,\cdot): \R^\du \to \R^\du$ is the inverse of $T_2(T_1^{-1}(y),\cdot)$ for each $y \in \R^\dy$. By writing $T_\sharp \refT = (S^{-1})_\sharp \refT,$ the push-forward density can be more easily evaluated in terms of the map $S$, rather than the inverse of $T$. As well as being useful computationally, these definitions of $S_1, S_2$ simplify various
expressions in the proof of the following theorem.
\end{remark}




The next theorem motivates the choice of tensor-product reference measure:
such a choice ensures that the block-triangular form of $T$ provides a map that 
can be used to readily characterize the posterior density.

\begin{theorem} 
\label{t:data}
Let Assumption \ref{a:blockt} hold. Then
$(T_1)_\sharp \refT_1 = \marg$ and 
\begin{equation} \label{eq:posterior_sampling_map}
  T_2(T_1^{-1}(y),\cdot)_\sharp \refT_2 = \post^y.
\end{equation}
\end{theorem}

\begin{remark}
    \label{rem:BTS}
The theorem shows that, if $w \sim \refT_2$ then $T_2\bigl(T_1^{-1}(y),w\bigr) 
\sim \post^y.$ Choosing $\refT_2$ to be an easy distribution to sample,
and learning $T$  from data, then leads to a method for sampling from the
posterior. In other words, imposing block-triangular structure on the map and the product form for the reference measure  yields a map that meets our goal of characterizing the posterior distribution. 
\end{remark}



\begin{proof}[Proof of Theorem \ref{t:data}]
We first prove that $(T_1)_\sharp \refT_1 = \marg.$ Let $S = T^{-1}$ be the inverse map of the form in~\eqref{eq:trimap_inverse}. 
By Lemma~\ref{lem:cov} we have that
\begin{subequations}
\label{eq:eno}
\begin{align}
T_\sharp \refT(y,u) & = \refT_1\bigl(S_1(y)\bigr) \det DS_1(y)
\refT_2\bigl(S_2(y,u)\bigr) \det D_uS_2(y,u),\\
(T_1)_\sharp \refT_1(y) & = \refT_1\bigl(S_1(y)\bigr) \det DS_1(y),\\
\bigl(T_2(T_1^{-1}(y),\cdot)\bigr)_\sharp \refT_2(u) & = \refT_2\bigl(S_2(y,u)\bigr) \det D_uS_2(y,u).
\end{align}
\end{subequations}
Integrating the last identity, using that the left-hand side is
a probability density function, gives for all $y \in \R^\dy,$
$$1=\int_{\R^{\du}}\refT_2\bigl(S_2(y,u)\bigr) \det D_uS_2(y,u) \, du.$$
Hence, multiplying identity (\ref{eq:eno}a) by an arbitrary test
function $\psi: \R^\dy \to \R$ and integrating over $y$ and $u$ we obtain
\begin{equation}
\label{eq:owt}
\int_{\R^\dy}\int_{\R^\du} \psi(y)T_\sharp \refT(y,u) \, dy du=
\int_{\R^\dy} \psi(y)\refT_1\bigl(S_1(y)\bigr) \det DS_1(y) \, dy.
\end{equation}
But $T_\sharp \refT(y,u)=\joint(y,u)=\marg(y)\pi^y(u).$
Thus, using the fact that, for all $y \in \R^\dy,$
$$1=\int_{\R^{\du}}\pi^y(u) \, du$$
we see that \eqref{eq:owt} simplifies to give
\begin{equation}
\label{eq:eerht}
\int_{\R^\dy} \psi(y) \marg(y) \, dy=
\int_{\R^\dy} \psi(y)\refT_1\bigl(S_1(y)\bigr) \det DS_1(y) \, dy.
\end{equation}
Since this is true for all $\psi$ we deduce that
$\marg(y)=\refT_1\bigl(S_1(y)\bigr) \det DS_1(y)$
and this, by Lemma \ref{lem:cov}, is the desired result.


We now prove identity \eqref{eq:posterior_sampling_map}.
Recall from Remark \ref{rem:inversemap_forpushforrward} that $$S_2(y,\cdot)=T_2^{-1}(T_1^{-1}(y),\cdot)$$ for each fixed $y$.  
Multiplying and dividing the right-hand side of~(\ref{eq:eno}c) by the right-hand side of (\ref{eq:eno}b), 
we have
\begin{align}
T_2(T_1^{-1}(y),\cdot)_\sharp \refT_2(u) &= \refT_2\bigl(S_2(y,u)\bigr)
\det D_{u} S_2(y,u) \nonumber \\
&= \frac{\refT_1\bigl(S_1(y)\bigr)\refT_2\bigl(S_2(y,u)\bigr)}
{\refT_1\bigl(S_1(y)\bigr)}\frac{\det DS_1(y)}{\det DS_1(y)}
\det D_{u} S_2(y,u) \nonumber \\
&= \frac{\refT\bigl(S(y,u)\bigr)\det D_{(y,u)} S(y,u)}{\refT_1\bigl(S_1(y)\bigr)\det DS_1(y)}. \label{eq:pushforward_density_S2}
\end{align}
In the last equality we used the product form of the reference probability density function and we
used the fact that the determinant of a block-triangular matrix can be written 
as a product of the determinant of its diagonal blocks.

Now, note that the numerator of~\eqref{eq:pushforward_density_S2} is the joint density $T_\sharp \refT(y,u) = \joint(y,u)$ and the denominator is the marginal $\marg(y)$ on $y$ under $\joint,$ as shown in~\eqref{eq:eerht}.  Thus, by conditioning the joint density 
$\joint(y,u)$ on $y$ we find that
$$\frac{\refT\bigl(S(y,u)\bigr)\det D_{(y,u)} S(y,u)}{\refT_1\bigl(S_1(y)\bigr)\det D S_1(y)}= \frac{\joint(y,u)}{\marg(y)} = \post^y(u).$$
Hence we have shown the desired result that
\begin{align*}
T_2(T_1^{-1}(y),\cdot)_\sharp \refT_2(u) = \frac{\joint(y,u)}{\marg(y)} = \post^y(u).
\end{align*}
\end{proof}

\begin{remark}
While a block-triangular map can sample from conditional distributions, it does not uniquely determine a particular map with the desired property. Indeed, when such a map exists, there may exist an infinite number of maps with the structure in Assumption~\ref{a:blockt}. We refer to Section~\ref{sec:transport2} for discussion
of computational methods to find transports from data.
\end{remark}

\begin{remark} \label{rem:DataMargRef} The reference measure $\refT$ is a degree of freedom in the measure transport framework. A useful choice is $\refT(y,u) = \marg(y)\refT_2(u)$; that is, to choose $\refT_1(y)=\marg(y).$
It then follows that the identity map $T_1(y) = y$ is a valid transport, trivially pushing forward 
$\refT_1(y)=\marg(y)$ to $\marg(y)$.  This choice avoids the inversion of $T_1$ in~\eqref{eq:posterior_sampling_map} and makes sampling from $\post_1$ straightforward: once we have determined $T_2$ compatible with this choice
of $T_1$ then for all $y \sim \marg$ we have 
$$T_2(y,u) \sim \post^y, \quad \text{for} \quad u \sim \refT_2.$$
\end{remark}

\begin{example}
Let $\refT(y,u)$ be the standard Gaussian distribution on $\Ry \times \Ru$ and let $\joint(y,u)$ be the Gaussian distribution $\mathcal{N}(m,\Sigma)$ on $\Ry \times \Ru$  with mean and covariance
$$m = \begin{bmatrix*}[l] m_y \\ m_u \end{bmatrix*}, \qquad \Sigma = \begin{bmatrix*}[l] \Sigma_{yy} & \Sigma_{yu} \\ \Sigma_{uy} & \Sigma_{uu} \end{bmatrix*},$$
where $\Sigma_{uy}=\Sigma_{yu}^\top.$
Let $T \colon \Ry  \times \Ru \rightarrow \Ry \times \Ru$ be a 
block-triangular transport map of the form
$$T(y,u) = \begin{bmatrix*}[l] T_1(y) \\ T_2(y,u) \end{bmatrix*} = \begin{bmatrix*}[l] m_y + \Sigma_{yy}^{1/2} y \\
m_{u|y}(m_y + \Sigma_{yy}^{1/2} y) + \Sigma_{u|y}^{1/2}u \end{bmatrix*},$$
where $m_{u|y}(y) \coloneqq m_u + \Sigma_{uy}\Sigma_{yy}^{-1}(y - m_y)$ and $\Sigma_{u|y} \coloneqq \Sigma_{uu} - \Sigma_{uy}\Sigma_{yy}^{-1}\Sigma_{yu}$ denote the conditional mean and covariance matrix of $u$ given $y$. Note that
$$T(y,u) = \begin{bmatrix*}[l] m_y + \Sigma_{yy}^{1/2} y \\
m_u + \Sigma_{uy}\Sigma_{yy}^{-1/2}y + \Sigma_{u|y}^{1/2}u \end{bmatrix*}.$$
For $(y,u)$ distributed according to the standard Gaussian distribution on $\Ry \times \Ru$ straightforward calculation
shows that $T(y,u)$ has distribution $\mathcal{N}(m,\Sigma)$ on $\Ry \times \Ru$.

Alternatively we may show that $T_\sharp \refT = \joint$ by
working with densities.
To this end we will compute the pushforward density $T_\sharp \refT(y,u) = \refT \bigl(T^{-1}(y,u)\bigr)\det \nabla T^{-1}(y,u)$. First, the inverse map has the form
$$T^{-1}(y,u) = \begin{bmatrix*}[l] T_1^{-1}(y) \\ T_2^{-1}(y,u) \end{bmatrix*} = \begin{bmatrix*}[l] \Sigma_{yy}^{-1/2}(y - m_y) \\ \Sigma_{u|y}^{-1/2}\bigl(u - m_{u|y}(y)\bigr) \end{bmatrix*}.$$ 
Then, for the standard Gaussian reference $\refT$ we have
\begin{align*}
\refT \bigl(T^{-1}(y,u)\bigr) &= \frac{1}{\sqrt{(2\pi)^{\dy+\du}}}\exp\left(-\frac{1}{2}|\Sigma_{yy}^{-1/2}(y - m_y)|^2 -\frac{1}{2}|\Sigma_{u|y}^{-1/2} \bigl(u - m_{u|y}(y)\bigr)|^2 \right) \\ 
&= \frac{1}{\sqrt{(2\pi)^{\dy+\du}}}\exp\left(-\frac{1}{2} \left|\begin{bmatrix*}\Sigma_{yy}^{-1/2} & 0 \\ -\Sigma_{u|y}^{-1/2}\Sigma_{uy}\Sigma_{yy}^{-1} & \Sigma_{u|y}^{-1/2} \end{bmatrix*} \begin{bmatrix*} y - m_y \\[0.1cm] u - m_u \end{bmatrix*} \right|^2 \right) \\ 
&= \frac{1}{\sqrt{(2\pi)^{\dy+\du}}}\exp\left(-\frac{1}{2} \left|\Sigma^{-1/2} \begin{bmatrix*} y - m_y \\[0.1cm] u - m_u \end{bmatrix*} \right|^2 \right),
\end{align*}
where $\Sigma^{-1/2}$ denotes the inverse of the block Cholesky factor of $\Sigma$. We note that the block-Cholesky factor $\Sigma^{1/2}$ satisfies
$$\Sigma^{1/2} (\Sigma^{1/2})^\top = \begin{bmatrix*} \Sigma_{yy}^{1/2} & 0 \\ \Sigma_{uy}\Sigma_{yy}^{-1/2} & \Sigma_{u|y}^{1/2} \end{bmatrix*} \begin{bmatrix*} \Sigma_{yy}^{1/2} &  \Sigma_{yy}^{-1/2}\Sigma_{yu} \\ 0 & \Sigma_{u|y}^{1/2} \end{bmatrix*} = \begin{bmatrix*} \Sigma_{yy} & \Sigma_{yu} \\ \Sigma_{uy} & \Sigma_{uu} \end{bmatrix*} = \Sigma.$$
Moreover, the determinant of the block-triangular Jacobian of $T^{-1}$ is given by the product of the determinant of the Jacobian's diagonal elements. That is, 
$$\det \nabla T^{-1}(y,u) = \det \Sigma_{yy}^{-1/2} \det \Sigma_{u|y}^{-1/2} = (\det \Sigma_{yy})^{-1/2} (\det \Sigma_{u|y})^{-1/2} = (\det \Sigma)^{-1/2},$$
where in the last equality we used the formula for the determinant of a block matrix with invertible diagonal elements. 

Thus, the pushforward density is given by $$\refT \bigl(T^{-1}(y,u)\bigr)\det \nabla T^{-1}(y,u) = \frac{1}{\sqrt{(2\pi)^{\dy+\du} \det \Sigma}}\exp \left(-\frac{1}{2} \begin{bmatrix*} y - m_y \\[0.1cm] u - m_u \end{bmatrix*}^\top \Sigma^{-1} \begin{bmatrix*} y - m_y \\[0.1cm] u - m_u \end{bmatrix*}\right).$$
That is, the pushforward is a multivariate Gaussian with mean $m$ and covariance $\Sigma$, which matches the density for $\joint$. Moreover, $T_1(y) = m_y + \Sigma_{yy}^{1/2}y$ pushes forward $\refT_1 = \mathcal{N}(0,I_k)$ to $\marg = \mathcal{N}(m_y,\Sigma_{yy})$, and so by Theorem~\ref{t:data} we have that 
$$T_{2}(T_{1}^{-1}(y),u) = m_{u|y}(y) + \Sigma_{u|y}^{1/2}u$$
pushes forward $\mathcal{N}(0,I_d)$ to the posterior $\post^y$ for each $y$.
\end{example}


\subsection{Learning Block-Triangular Pushforward Maps} \label{ssec:learning_maps}

Once again, recall the notation of Remark \ref{rem:minus1}.
In this subsection we discuss the learning of block-triangular transport maps, given data pairs 
$\{(y^{(n)},u^{(n)})\}_{n=1}^N$ from the joint distribution $\joint(y,u).$  Let $\theta \in \Theta \subseteq \R^p$ denote the parameters of the block-triangular map $T(u,y;\theta)$ given by \eqref{eq:trimap}. Our goal is to find the optimal parameters by minimizing the KL divergence between the pushforward distribution $T_\sharp \refT$ and the joint distribution $\joint$. That is,
\begin{equation}
\label{eq:tsd}
 \thetas \in  \argmin_{\theta\in \Theta} \dkl(\joint\|T(\cdot;\theta)_\sharp \refT).
\end{equation}

\begin{remark}
Compare with the minimization problems \eqref{eq:waya} and \eqref{eq:thetaVIy} for which the
reference measure appears in the left-hand argument of $\dkl(\cdot\|\cdot).$ This choice is dictated by the form
of the data, drawn from the joint distribution; and specifically drawn by sampling from prior on $u$ and then
from likelihood on $y|u.$  The following theorem shows that the optimal parameters can then be identified from an optimization objective that only depends on the joint distribution $\joint(y,u)$ through an expectation, and hence can be solved using an empirical approximation of the objective.
\end{remark}

\begin{theorem} \label{thm:BlockTriangularLearning} Let $T$ be a block-triangular transport map of the form in Assumption~\ref{a:blockt}, let $\refT(y,u) = \marg(y)\refT_2(u)$ be a reference distribution as in Remark~\ref{rem:DataMargRef} with $T_1(y) = y$ and let $\thetas$ be defined by \eqref{eq:tsd}. Then, the optimal parameters for the map $T_2$ are given by
$$\thetas \in \argmin_{\theta \in \Theta} -\mathbb{E}^{(y,u) \sim \joint}\Bigl[\log \refT_2 \circ T_2^{-1}(y,u;\theta) + \log\det{D_u T_2^{-1}(y,u;\theta)}\Bigr],$$
where $T_2^{-1}(y,u;\theta)$ denotes the inverse of the function $u \mapsto T_2(y,u;\theta)$ for each given
pair $(y,\theta)$.
\end{theorem}

\begin{proof} From the chain rule for the KL divergence, Lemma \ref{lemma:chainrule}, we have
\begin{equation} \label{eq:KLdecomposition_post}
    \dkl(\joint\|T(\cdot;\theta)_\sharp \refT) = \dkl(\marg \|(T_1)_\sharp \marg) + \mathbb{E}^{y \sim \marg}\left[\dkl(\post^y(u) \|T_2(y,\cdot;\theta)_\sharp \refT_2)\right].
\end{equation}
Setting $T_1(y) = y$, the first term in~\eqref{eq:KLdecomposition_post} is zero, and the second term is given by 
\begin{align*}
\mathbb{E}^{y \sim \marg}\left[\dkl(\post^y \|T_2(y,\cdot;\theta)_\sharp \refT_2)\right] &= \int \int \marg(y) \post^y(u) \Bigl[\log \post^y(u) - \log \bigl(T_2(y,\cdot;\theta)_\sharp \refT_2(u)\bigr)\Bigr] \, dydu \\
&= c - \int \int \joint(y,u) \log \bigl(T_2(y,\cdot;\theta)_\sharp \refT_2(u)\bigr)\, \, dudy,
\end{align*}
where $c$ is a constant that is independent of the parameters $\theta$. Therefore, minimizing the second term achieves the minimum of the objective as stated in the theorem, by use of Lemma \ref{lem:cov}.
\end{proof}

\begin{remark}
    \label{rem:worthnoting}
As in Remark~\ref{rem:inversemap_forpushforrward}, it is common to parameterize the inverse map $T_2^{-1}(y,\cdot; \theta)$ directly by letting $S_2(y,\cdot;\theta) \coloneqq T_2^{-1}(y,\cdot;\theta)$. This choice avoids inversion during learning, however it requires inverting the map $S_2$ to sample from the posterior $\pi^y$ after learning.
\end{remark}

The following result shows that the optimization problem in Theorem~\ref{thm:BlockTriangularLearning} over the space of inverse transports is convex for certain reference distributions.

\begin{theorem} \label{thm:Sconvex} If $\refT_2$ is a log-concave reference density, then the optimization problem 
\begin{equation} \label{eq:OptDataDependentMap_Convex}
    S_2^\star \in \argmin_{S_2 \in \mathcal{S}} -\mathbb{E}^{(y,u) \sim \joint} \Bigl[\log \refT_2 \circ S_2(y,u) + \log\det{D_u S_2(y,u)}\Bigr],
\end{equation}
over the space of invertible and diffeomorphic maps
$$\mathcal{S} = \Bigl\{S_2 \in C^1(\R^{k+d};\R^d), D_u S_2(y,u) \succ 0 \text{ for all } u \in \R^d, y \in \R^k \Bigr\}$$
is convex.
\end{theorem}

\begin{proof} The proof follows the steps of Theorem~\ref{thm:tconvex} by replacing the posterior $\pi^y$ with the reference density $\refT_2$.
\end{proof}

\begin{remark} 
Theorem \ref{thm:Sconvex} does not imply that the optimization problem in Theorem~\ref{thm:BlockTriangularLearning} is convex in $\theta$. In particular when $S$ has a non-linear parameterization  based on neural networks, the
problem will be non-convex.
\end{remark}

\begin{example} Let $\refT_2(u) = (2\pi)^{-d/2}\exp(-\frac{1}{2}|u|^2)$ be the standard Gaussian reference density. Then, $\log\refT_2(u) = -\frac{d}{2}\log(2\pi) - \frac{1}{2}|u|^2$. Ignoring the first term that is a constant, 
Theorem \ref{thm:Sconvex} shows that optimal map $S_2$ is found as solution of the optimization problem
$$\argmin_{S_2} \mathbb{E}^{(y,u) \sim \joint}\left[\frac12 \left|S_2(y,u)\right|^2 - \log\det{D_u S_2(y,u)}\right].$$
By Theorem~\ref{thm:Sconvex}, the optimization problem for $S_2$ is convex. The first term in the objective minimizes the squared norm of $S_2(y,u)$, which encourages the map's output to be at zero, the MAP point of the reference distribution $\refT_2$. The second term prevents the map from concentrating the output at a single point. Moreover, the second term acts a log-barrier for the space of invertible maps by adding a large penalty as the derivative of $S_2$ approaches zero.
\end{example}

The convexity of the objective yields uniqueness of the solution to~\eqref{eq:OptDataDependentMap_Convex} when a minimizer exists. The following result provides a concrete example for the closed-form solution when $\mathcal{S} $ is restricted to the space of affine maps. 

\begin{theorem} \label{thm:ClosedFormAffineTransportMaps} 
Let $\refT_2(u) = (2\pi)^{-d/2}\exp(-\frac{1}{2}|u|^2)$ be Gaussian and let $(y,u) \sim \joint$. We consider $\mathcal{S}$ be the space of affine maps 
$$\mathcal{S} = \Bigl\{S_2(y,u) = A(u + By + c), A \in \R^{\du \times \du}, A \succ 0, B \in \R^{\du \times \dy}, c \in \mathbb{R}^\du \Bigr\},$$
where $A$ is also constrained to be a triangular matrix. Then, the optimal map in the sense of solving~\eqref{eq:OptDataDependentMap_Convex} has the form
$$S_2(y,u) = \Sigma_{u|y}^{-1/2}\left(u - \mathbb{E}[u] + \Sigma_{uy}\Sigma_{yy}^{-1}(y - \mathbb{E}[y])\right),$$
where $\Sigma_{u|y} \coloneqq \Sigma_{uu} - \Sigma_{uy}\Sigma_{yy}^{-1}\Sigma_{yu}.$ The matrices $\Sigma_{uu}$, $\Sigma_{yy}$ and $\Sigma_{uy}$ denote the covariance of $u$, covariance of $y$, and cross-covariance of $(u,y)$ under $\joint$, respectively. 
\end{theorem}
\begin{proof} The optimization problem has the form
$$(A^\star,B^\star,c^\star) \in \argmin_{A,B,c} \mathbb{E}^{(y,u) \sim \joint}\left[\frac12(u + By + c)^\top A^\top A(u + By + c) - \log\det A \right].$$
For fixed $A$ and $B$, taking the gradient of the objective with respect to $c$ and setting it equal to zero, we have 
\begin{align*}
    c^\star &= -\mathbb{E}[u] - B\mathbb{E}[y].
\end{align*}
Substituting the optimal $c^\star$ in the objective, we then define the loss for $B$ given a fixed $A$ to be
$$\loss(B;A) \coloneqq \mathbb{E}^{(y,u) \sim \joint}\left[\frac12 \bigl(u - \mathbb{E}[u] + B(y -\mathbb{E}[y]\bigr)^\top A^\top A \bigl(u \mathbb{E}[u] + B(y -\mathbb{E}[y] \bigr) - \log\det A \right].$$
Taking the gradient with respect to $B$ and setting it equal to zero we have $\nabla_B \loss(B;A) = 2A^\top A(B \Sigma_{yy} + \Sigma_{uy}) = 0,$ where $\Sigma_{yy}$ and $\Sigma_{uy}$ denote the covariance and cross-covariance of $y$ and $(u,y)$. Re-arranging for $B$ gives us
$$B^\star = -\Sigma_{uy}\Sigma_{yy}^{-1}.$$
Substituting the optimal $B^\star$ in the loss $\loss$, we notice that the optimization problem for $A^\top A$ corresponds to the Gaussian variational inference problem in~\eqref{eq:GaussianVI_objective}. The optimal solution for $A^\star$ is given by the inverse Cholesky factor of the covariance matrix
$$(A^\star)^{-1}(A^\star)^{-\top} = \Bigl(\mathbb{E}\Bigl[ \bigl(u - \mathbb{E}[u] - \Sigma_{uy}\Sigma_{yy}^{-1}(y - \mathbb{E}[y]) \bigr)\bigl(u - \mathbb{E}[u] - \Sigma_{uy}\Sigma_{yy}^{-1}(y - \mathbb{E}[y])\bigr)^\top \Bigr]\Bigr)^{-1}.$$
Expanding the squared terms yields
\begin{align*}
   (A^\star)^{-1}(A^\star)^{-\top} &= \Sigma_{uu} - \Sigma_{uy}\Sigma_{yy}^{-1}\Sigma_{yu} - \Sigma_{uy}\Sigma_{yy}^{-1}\Sigma_{yu} + \Sigma_{uy}\Sigma_{yy}^{-1}\Sigma_{yy}\Sigma_{yy}^{-1}\Sigma_{yu} \\
   &=\Sigma_{uu} - \Sigma_{uy}\Sigma_{yy}^{-1}\Sigma_{yu} \\
   &= \Sigma_{u|y},
\end{align*}
which gives us the final result, $(A^\star)^{-1} = \Sigma_{u|y}^{1/2}$.
\end{proof}


\section{Learning Likelihood Models}
\label{sec:LLM!}

The framework in Section~\ref{sec:likelihood-free} can also be used to learn the likelihood function in an inverse problem on the basis of data. 
We again work in the setting of Assumption \ref{a:LFI}.
Learning the likelihood is particularly useful in inverse problems where the likelihood is unknown analytically or intractable to evaluate as in Example~\ref{ex:integrated_like}. Given an approximation to the likelihood function and a known prior density, we have access to the approximate posterior density up to a normalizing constant. The resulting density can be used in algorithms such as Markov chain Monte Carlo to sample from the posterior distribution. 

For this purpose we define a block-triangular map $T$, identical to the form in \eqref{eq:trimap}, but
with a reversed ordering for the variables $(u,y)$; that is
\begin{equation} \label{eq:triangular_map_likelihood}
T(u,y) = \begin{bmatrix*}[l] T_1(u) \\ T_2(u,y) \end{bmatrix*}.
\end{equation}
We use a map of this form, assumed for now to exactly pushforward the product reference density $\refT(y,u):=\refT_1(u)\refT_2(y)$ to $\joint(y,u)$; later we approximate this pushforward. In this
section we factor $\joint(y,u)=\rho(u)\like(y|u).$
By Theorem~\ref{t:data}, with the roles of $u$ and $y$ reversed, the map $y \mapsto T_2(T_1^{-1}(u),y)$ pushes forward $\refT_2(y)$ to $\like(y|u)$ for each $u$. We choose the first marginal of the reference density to 
be the prior,  $\refT_1(u) = \pr(u)$. Then, letting $T_1(u) = u$, the likelihood function is given by
\begin{equation}
\like(y|u) = \refT_2 \bigl(T_2^{-1}(u,y)\bigr)\det{\nabla_y T_2^{-1}(u,y)},
\end{equation}
where $T_2^{-1}(u,\cdot)$ denotes the inverse of the function $y \mapsto T_2(u,y)$. 

\begin{example} \label{ex:map_Gaussian_lik} 
Let $\refT_2(y)$ be the standard Gaussian on $\Ry.$
Choosing $T_2(u,y) = G(u) - \Gamma^{1/2}y$ for some map $G \colon \Ru \rightarrow \Ru$ and a positive definite matrix $\Gamma \in \Ry \times \Ry$, we have the Gaussian likelihood function 
\begin{align*}
    \like(y|u) &= \refT_2\Bigl(\Gamma^{-1/2}\bigl(y - G(u)\bigr)\Bigr)\det \Gamma^{-1/2} \\
    &= \frac{1}{\sqrt{(2\pi)^k \det{\Gamma}}} \exp \left(-\frac{1}{2}|y - G(u)|_\Gamma^2 \right)\\
    &= \mathcal{N}(G(u),\Gamma).
\end{align*}
\end{example}

Following the approach in Subsection~\ref{ssec:learning_maps}, we learn the parameters $\theta$ to define a map $T(u,y;\theta)$ which approximates the  exact pushforward.
Thus we solve the optimization problem
\begin{equation} \label{eq:KL_transportmap_lik}
    \thetas \in \argmin_{\theta \in \Theta} \dkl(\joint \|T(\cdot;\theta)_\sharp \refT).
\end{equation}

The next theorem shows that we can find the parameters $\thetas$ by minimizing a loss function that only depends on the joint distribution $\joint$ via an expectation, and thus is amenable to learning from paired data.
The proof is analogous to that of Theorem \ref{thm:BlockTriangularLearning} but with the roles of $y$ and $u$ reversed.

\begin{theorem} Let $T$ be a block-triangular transport map of the form in~\eqref{eq:triangular_map_likelihood}. Let the reference density be $\refT(u,y) = \pr(u)\refT_2(y)$ and $T_1(u) = u$. The optimal parameters $\thetas$
from \eqref{eq:KL_transportmap_lik} also solve the  optimization problem
\begin{equation} \label{eq:map_likelihood_loss}
 \thetas \in    \argmin_{\theta \in \Theta} -\mathbb{E}^{(y,u) \sim \joint} \left[ \log \refT_2 \circ T_2^{-1}(u,y;\theta) + \log\det D_y T_2^{-1}(u,y;\theta) \right].
\end{equation}
\end{theorem}

\begin{proof}
From the chain rule for the KL divergence, Lemma \ref{lemma:chainrule}, we have
\begin{equation} \label{eq:KLdecomposition}
    \dkl(\joint \|T(\cdot;\theta)_\sharp \refT) = \dkl(\pr\|(T_1)_\sharp \pr) + \mathbb{E}^{u \sim \pr}\bigl[\dkl(\like(\cdot|u) \|T_2(u,\cdot;\theta)_\sharp \refT_2)\bigr].
\end{equation}
Setting $T_1(u) = u$, the first term in~\eqref{eq:KLdecomposition} is zero, and the second term is given by
\begin{align*}
\mathbb{E}^{u \sim \pr}\left[\dkl(\like(\cdot|u)\|T_2(u,\cdot;\theta)_\sharp \refT_2)\right] &= \int \rho(u) \like(y|u) \Bigr[\log \like(y|u) - \log\bigl(T_2(u,\cdot;\theta)_\sharp \refT_2(y)\bigr)\Bigl] \, dydu \\
&= c - \int \joint(y,u) \log\bigl(T_2(u,\cdot;\theta)_\sharp \refT_2(y)\bigr) \, dudy,
\end{align*}
where $c$ is a constant that is independent of $\theta$. Therefore, minimizing the second term achieves the minimum of the objective as stated in the theorem, by use of Lemma \ref{lem:cov}.
\end{proof}

Given a collection of $N$ paired samples
$\{(y^{(n)},u^{(n)})\}_{n=1}^N$ from the joint distribution $\joint(y,u)$
we may approximate the expectation  in~\eqref{eq:map_likelihood_loss}. This leads to the
problem of minimizing the following empirical loss function to find the approximate likelihood
\begin{equation} \label{eq:map_likelihood_loss_empirical}
    \argmin_{\theta \in \Theta} -\frac{1}{N}\sum_{n=1}^N \log \refT_2 \circ T_2^{-1}(u^{(n)},y^{(n)};\theta) + \log\det D_y T_2^{-1}(u^{(n)},y^{(n)};\theta).
\end{equation}



\begin{example} Let $\refT_2$ be a standard Gaussian density of dimension $\Ry$ and let $T_2$ be a parameterized transport map of the form $T_2(u,y;\theta) = G(u;\theta) - \Gamma^{1/2}y$ as in Example~\ref{ex:map_Gaussian_lik} where $\Gamma \succ 0$ is known. Then, minimizing the loss function in~\eqref{eq:map_likelihood_loss_empirical} corresponds to solving the problem
\begin{align*}
\argmin_{\theta \in \Theta} & \,\, \Biggl\{ \frac{1}{N}\sum_{n=1}^N \frac{1}{2}\left|T_2^{-1}(u^{(n)},y^{(n)};\theta)\right|^2 + \log \det D_y T_2^{-1}(u^{(n)},y^{(n)};\theta) \Biggr\} \\
= \argmin_{\theta \in \Theta} & \,\, \Biggl\{ \frac{1}{N}\sum_{n=1}^N \frac{1}{2}\left|\Gamma^{-1/2}\bigl(y^{(n)} - G(u^{(n)};\theta)\bigr)\right|_\Gamma^2 + \log \det \Gamma^{-1/2} \Biggr\} \\
= \argmin_{\theta \in \Theta} & \,\, \frac{1}{N}\sum_{n=1}^N \frac{1}{2}\left|y^{(n)} - G(u^{(n)};\theta)\right|_\Gamma^2. \\
\end{align*}
Hence, finding the transport map is equivalent to seeking an approximate forward model as the solution of a mean-squared regression problem. This generalizes the approach of learning forward surrogate models in Chapter~\ref{ch:fsm}.
\end{example}



\section{Amortized MAP Estimation}
\label{sec:MAPd}

\index{Bayes theorem}Theorem \ref{t:bayes} delivers the posterior
\[
\post^y (\vct u) = \frac{1}{Z} \noise \bigl(\vct y- \vct G(\vct u)\bigr) \pr (\vct u).
\]
Recall that the \index{MAP estimator}MAP estimator of $u$ given data $y$ is  defined as any point solving the maximization problem
$$\umap \in \argmax_{\vct{u}\in\Ru}\post^{\vct{y}}(\vct{u}).$$

We make the following assumption: 

\begin{dataassumption}
We are given multiple pairs of observations and numerically computed MAP estimators 
$\bigl\{ \bigl(y^{(n)},\umap^{(n)}\bigr)\bigr\}_{n=1}^N$, drawn i.i.d. from probability measure $\mu$ on $\Ry \times \Ru$.
\end{dataassumption}

\begin{remark}
    The measure $\mu$ may be constructed as the product of a measure on $\Ry$ and its pushforward under a deterministic algorithm to
find the MAP estimator in $\Ru$ from data in $\Ry;$ however, as the MAP estimation
algorithm may be random (for example stochastic gradient descent) we work with
a general measure $\mu.$
\end{remark}

Given measure $\mu$ we may try and learn the dependence of the \index{MAP estimator}MAP estimator on observations. To this end we seek
a parameterized function $u\colon \Ry \times \Theta \to \Ru$ for $\Theta \subseteq \R^p.$ We aim to find $\thetas \in \Theta$ for which $u(\cdot;\thetas):
\Ry \to \Ru$ approximates the mapping from observed data to the MAP estimator.
Recall Definition \ref{def:det_score} from Subsection \ref{ssec:dldsc}
on distance-like deterministic scoring rules $\D$\index{scoring rule!distance-like deterministic}.  We may use this to compare the point estimator $u(y;\theta)$
at point $y$ to $\umap$ obtained from that same $y$. 
We then define $\thetas$ by

\begin{align}\label{eq:MAPL}
\begin{split}
\J(\theta) &= \bbE^{(y,\umap) \sim \mu} \, \bigl[\D\bigl(u(y;\theta),\umap\bigr) \bigr],\\
\thetas &\in \argmin_{\theta \in \Theta} \J(\theta).
\end{split}
\end{align}
In practice we replace the expectation over $\mu$ in \eqref{eq:MAPL} with expectation with respect to  $\mu^N,$ the empirical measure
defined by $\bigl\{ \bigl(y^{(n)},\umap^{(n)} \bigr)\bigr\}_{n=1}^N$.

\section{Bibliography}
\label{sec:lfbib}

The variable $z$ over which we marginalize is often referred to as a \emph{nuisance} 
or auxiliary random variable; this is often used in the setting where $z$ is not the 
primary parameter of interest in the inverse problem. An alternative approach to those
described here seeks the joint posterior of $(u,z)$, and then marginalizes after the 
computation. While the corresponding likelihood for the joint posterior doesn't involve 
a marginal or integrated likelihood, it can lead to a challenging problem for high or 
even infinite-dimensional latent variables. We refer to~\cite{basu1977nuissance} for 
more details on integrated likelihoods. In MCMC algorithms, these integrated likelihoods are commonly addressed using pseudo-marginal methods that work with unbiased estimators of the likelihood~\cite{andrieu2009pseudo}.

Approximate Bayesian computation (ABC) is a classic inference method for performing likelihood-free inference with latent variables or other intractable likelihoods; see~\cite{sisson2018handbook} for a comprehensive overview on ABC. These approaches define a distance function that compare simulated observations to the true observation and reject parameter samples that are not consistent with the true observation based on a small tolerance. ABC methods can be shown to be consistent in the limit of the tolerance approaching zero, but typically require large sample sizes with high-dimensional observations.

Learning approaches have appeared as alternatives to ABC; machine learning-based approaches for simulation-based inference are outlined in~\cite{cranmer2020frontier}. Methodologies for both posterior and  likelihood approximation in this setting are implemented using various unsupervised learning architectures (see Chapter~\ref{ch:UL})  including: conditional normalizing flows~\cite{winkler2019learning, papamakarios2019sequential}, conditional generative adversarial networks~\cite{ray2023solution}, conditional diffusion models~\cite{batzolis2021conditional}. 
Triangular transport maps are a core element of these architectures for solving inverse problems. They are related to the well known Knothe-Rosenblatt transport, which has been used for conditional density estimation in~\cite{marzouk2016sampling, baptista2023representation}. The design and analysis of block-triangular maps on function space is investigated in~\cite{baptista2020conditional, hosseini2023conditional}.

Amortized inference\index{inference!amortized} is overviewed in \cite{zhang2018advances}. Variational autoencoders\index{variational!autoencoder|see{autoencoder, variational}}\index{autoencoder!variational}, 
which were proposed concurrently in  
\cite{kingma2013auto} and \cite{rezende2014stochastic}, introduced
the concept of amortized inference in the specific context of autoencoding.
The idea of iterating amortized inference was introduced in
\cite{marino2018iterative}; this approach is designed to close
the amortization gap\index{amortization gap} caused by failing to reach
optimality when training.

Transport approaches have also been useful within classic Monte Carlo methods. For example, transports learned from samples of a target posterior distribution have been used to pre-condition the target and to perform Markov chain Monte Carlo (MCMC) sampling in the (e.g., approximately Gaussian) reference space of the map~\cite{hoffman2019neutra}, to learn proposal distributions for importance sampling~\cite{muller2019neural}, and to learn Markov kernels that are better adapted to the structure of the posterior distribution and to accelerate MCMC~\cite{parno2018transport, gabrie2022adaptive}. 

\chapter{\Large{\sffamily{Filtering and Smoothing Problems}}}\label{lecture7}








This chapter is devoted to \index{data assimilation}\emph{data assimilation} problems. 
We study both the \index{filtering}\emph{filtering problem} and the \index{smoothing}\emph{smoothing problem.} Consider the \index{stochastic dynamics model}{\em stochastic dynamics model} 
given by 
\begin{subequations}
\label{eq:sdm}
\begin{align}
\vd_{j+1} &= \Psi(\vd_j) + \xid_j, \quad j \in \Z^+,\\
\vd_0 &\sim \Nc(m_0, C_0), \quad \xid_j \sim \Nc(0, \Sigma) \: \index{i.i.d.}\text{i.i.d.}\,, 
\end{align}
\end{subequations}
where we assume that the i.i.d.\thinspace sequence $\{ \xid_j \}_{j \in \bbZ^+}$ 
is independent of initial condition $\vd_0;$ 
this is often written as $\{ \xid_j \}_{j \in \bbZ^+} \ind \vd_0.$ 
The \index{data model}{\em data model} is given by
\begin{subequations}
\label{eq:dm}
\begin{align}
\yd_{j+1} &= h(\vd_{j+1}) + \etad_{j+1} , \quad j \in \Z^+,\\
\etad_j &\sim \Nc(0, \Gamma) \quad \index{i.i.d.}\text{i.i.d.}\,,
\end{align}
\end{subequations}
where we assume that the i.i.d. sequence $\{\etad_j\}_{j \in \bbN} \ind \vd_0$ and 
that the two i.i.d. sequences in the dynamics and data models
are independent of one another: $\{ \xid_j \}_{j \in \bbZ^+} \ind \{\etad_j\}_{j \in \bbN}.$


Broadly speaking, \index{data assimilation} data assimilation seeks to
find the state $\{\vd_j\}$, over some set of time indices $j \in \{0,1,\dots,J\}$
based on realized observations $\{\yd_j\}$ from \eqref{eq:dm}. We define, for a given and fixed integer $J,$
\begin{equation}
\label{eq:VdYd}
\Vd := \{\vd_0, \ldots, \vd_J\}, \: \Yd := \{\yd_1, \ldots, \yd_J\}, 
\: \text{and} \: \Yd_j := \{\yd_1, \ldots, \yd_j\}. 
\end{equation}
There are two core problems in data assimilation:
one known as \index{filtering}\emph{filtering}, 
and the other as \index{smoothing}\emph{smoothing}. The goal of the \index{filtering}filtering problem is to approximate the sequence of probability distributions, $\mathbb{P}(\vd_j | \Yd_j)$, for the state of the system
$\vd_j$ at index $j$ conditioned on data $\Yd_j := \{\yd_1, \ldots, \yd_j\}$; and
furthermore to do so as it arrives sequentially.
The \index{smoothing}smoothing problem, in
contrast, is to estimate the probability distribution on an entire sequence of states $\Vd$ given the entire dataset $\Yd$, $\mathbb{P}(\Vd | \Yd)$. The sequence $\Vd$ is often termed the \index{signal}{\em signal} and the sequence
$\Yd$ the {\em data}. Note that $\Vd \in \R^{\du(J+1)}$ and $\Yd \in \R^{\dy J}$ represent sequences over a window of length $J+1$ and $J$, respectively.



\begin{remark}
When trying to solve these probabilistic filtering and smoothing problems,
we will refer to \emph{probabilistic estimation.} On the other hand many
optimization-based filtering and smoothing algorithms exist with the aim being simply to estimate the
state itself, conditioned on data. We refer to this as \emph{state estimation.} 
\end{remark}


\begin{remark}
Because filtering is defined by conditioning on data arriving sequentially,
such algorithms may be used \emph{online}\index{algorithm!online}, the probability distribution over states being updated every time
a new data point arrives. Smoothing gives rise to  methodologies that are most 
naturally used, in their most basic form, in an \emph{offline}\index{algorithm!offline} fashion. 
However, smoothing algorithms may also be used sequentially, in block form with respect to discrete time index $j$, as we
now explain.

In the above we assumed data $\yd_j$ given on the
index set $j \in \{1,\ldots, J\}.$
Now let us assume that the data $\yd_j$ is in fact given
for all $j \in \N$ and use integer $J$ to break up the
data into finite time segments. We first solve the
smoothing problem defined on the index set
$j \in \{0,\ldots, J\}.$
Taking the solution at time $J$ as starting point we
may then solve a smoothing problem 
on index set $j \in \{J,\ldots, 2J\}.$
This idea may be iterated, working on index set $j \in \{kJ,\ldots, (k+1)J\}$, then on  index set $j \in \{(k+1)J,\ldots, (k+2)J\}$ and so on. Such methods are known as 
\emph{fixed-interval smoothers}.
At overlap points, which are a multiple
of $J$, some form of Gaussian projection will be needed to
restart the process on the next time-interval as the assumption made above is that the initial condition is Gaussian; however, this can be relaxed.
\end{remark}

Before describing the \index{filtering}filtering and \index{smoothing}smoothing problems we
outline assumptions that are made in the remainder of the chapters 
devoted to data assimilation. 

\begin{assumption}
\label{a:fas} 
The matrices $C_0,$ $\Sigma$ and $\Gamma$ are \index{positive definite}positive definite.
Furthermore the nonlinear maps $\Psi$ and $h$ are continuous: $\Psi \in C(\Ru, \Ru)$ and $h \in C(\Ru, \Ry)$. 
\end{assumption}


In Sections \ref{sec:filtering} and \ref{sec:smoothing}, respectively, we formulate the
filtering and smoothing problems. Section \ref{sec:kalman} recalls the
Kalman filter\index{Kalman filter}, applicable in the linear and Gaussian setting. Sections \ref{sec:3dvar}, \ref{sec:exkf}, \ref{sec:enkf}, and \ref{sec:pf} recall 3DVar, the extended Kalman filter\index{Kalman filter!extended} (ExKF), and the ensemble Kalman filter\index{Kalman filter!ensemble} (EnKF); Sections
\ref{sec:pf} and \ref{sec:opf} concern the bootstrap particle
filter\index{particle filter!bootstrap} and the optimal particle
filter\index{particle filter!optimal} approaches to filtering. Section \ref{sec:4dvar} is devoted to the 4DVar approach
to smoothing, followed by a discussion of reanalysis\index{reanalysis} in
Section \ref{sec:rean}. In Section \ref{sec:meda} we discuss model error in the context of filtering and smoothing problems. Section \ref{sec:dabib} contains bibliographic notes.

\begin{remark}
\label{rem:gen}
    We conclude this introductory discussion with some remarks on generalizations
    of the setting we adopt in these notes. First we observe that the stochastic
    dynamics model \eqref{eq:sdm} and data model \eqref{eq:dm} are readily generalized
    to settings in which the maps $\Psi(\cdot)$ and $h(\cdot),$ as well as the covariances
    $\Sigma$ and $\Gamma$, are dependent on the time-index $j.$ It is also possible
    to allow degenerate noises (positive semi-definite), 
    and the case where no noise is present in the
    dynamics ($\Sigma \equiv 0$) arises frequently. Furthermore, all of the
    sections in this chapter, with the exception of the Kalman filter\index{Kalman filter} which leverages Gaussian structure, 
    admit generalizations to settings in which the noises
    $\{\xid_j\}_{j \in \Z^+}, \{\etad_j\}_{j \in \N}$ are independent i.i.d. centred but \emph{non-Gaussian}\index{Gaussian!non-} sequences.
    Adding \emph{correlation}\index{correlation} to the noises is also possible.
    For example it is possible to consider correlation across the discrete time index $j$. 
    This significantly complicates filtering, but it is possible to accommodate it if
    the noise itself is generated by a Markov process.
    Adding correlation to the noises across the discrete time index $j$ 
    also complicates smoothing, but can also be handled, typically at additional
    computational cost. In addition, allowing for correlation between 
    the dynamics and observational noise is also possible. Finally we note
    that continuity of the maps $\Psi(\cdot), h(\cdot)$ is also not necessary.
\end{remark}


\section{Formulation of the \index{filtering}Filtering Problem}
\label{sec:filtering}



\begin{definition}
The \index{filtering}{\em filtering problem} is to find, and update sequentially in $j$, the probability densities 
$\post_j(\vd_j):=\Prob(\vd_j|\Yd_j)$ on $\Ru$ for $j=1, \dots, J.$
We refer to $\post_j$ as the {\em \index{filtering!distribution}filtering distribution at time $j.$}
\end{definition}

Filtering may be understood as the sequential interleaving of prediction, using the
\index{stochastic dynamics model} stochastic dynamics model \eqref{eq:sdm}, with inversion,
using the \index{data model}data model \eqref{eq:dm}.
To explain this perspective it is helpful to introduce 
$\hat{\post}_{j+1}=\Prob(\vd_{j+1}|\Yd_j)$ and to decompose the sequential updating 
$\post_j \mapsto \post_{j+1}$ into the following two steps:
\begin{align}\label{eq:pna}
\begin{split}
&{ \text{ \bf  Prediction Step:}} ~~~~\;  \hat{\post}_{j+1} = \Pred \post_j.  \index{prediction} \\
& {\text{  \bf Analysis Step:}} ~~~~~\,\,\,\,\,  \post_{j+1} = \An(\hat{\post}_{j+1};\yd_{j+1}). \index{analysis} 
\end{split}
\end{align}
The combination of the \index{prediction}prediction and \index{analysis}analysis steps is shown 
schematically in Figure \ref{fig:interaction} and leads to the update 
\begin{equation}
\label{eq:An}
\post_{j+1} = \An (\Pred\post_j;\yd_{j+1}). 
\end{equation}
Here $\Pred$ is a linear map, defining the Markov process underlying the 
\index{stochastic dynamics model} stochastic dynamics model and $\An(\cdot,\yd_{j+1})$ is a 
nonlinear \index{likelihood}likelihood map  defined by application of \index{Bayes theorem}Bayes Theorem
\ref{t:bayes} to solve the inverse problem for $\vd_{j+1}|\yd_{j+1}$, with prior $\hat{\post}_{j+1}.$

\begin{figure}[h]
  \begin{center}
    \includegraphics[width=0.8\textwidth]{figures/filtering.pdf}
  \end{center}
  \caption{Prediction and analysis steps combined.} \label{fig:interaction}
\end{figure}

The linear operator $\Pred$ is defined as follows:
\begin{equation}\label{eq:pred_operator}
    \Pred \pi(u) = \frac{1}{\sqrt{(2\pi)^d \det \Sigma}}\int \exp \left( - \frac{1}{2} |u - \Psi(v)|_{\Sigma}^2 \right) \pi(v) \, dv.
\end{equation}
Given any probability density function $\pi$ on $\R^d$ we can extend to a joint
density $\nu_\pi$ on state-data space $\R^{d} \times \R^k:$
\[
\nu_\pi(u, y) = \frac{1}{\sqrt{(2\pi)^k \det \Gamma}}
\exp \left( - \frac{1}{2} \bigl\lvert y - h(u) \bigr\rvert_{\Gamma}^2 \right)
\pi(u).
\]
Using this we can define the nonlinear 
operator $\An(\cdot,\yd_{j+1})$ by
\begin{equation}
  \An(\pi,\yd)(u) = \frac{\nu_\pi(u,\yd)}{\int_{\R^d} \nu_\pi(u,\yd) \, d u}.\label{eq:filter_bayes_inference}
\end{equation}

The following theorem shows that the filtering distribution has an
interesting property relating its mean to its variance;
later we will use this to motivate study of the 
spread--error ratio\index{spread--error ratio} of forecasts that
have a probabilistic interpretation.


\begin{theorem}
\label{t:ser}
In the following the pair $(\vd_j,\Yd_j)$ is distributed according
to the joint distribution under the dynamics/data model \eqref{eq:sdm}, \eqref{eq:dm}, with expection denoted $\mathbb{E}^{(\vd_j,\Yd_j)}$. Furthermore $\vd_j$
and $\Yd_j$ are
distributed according to their respective marginals with respect to
this distribution, with expectation under the latter denoted $\mathbb{E}^{\Yd_j}$. And  $v_j$ is distributed according to the 
conditional $\vd_j | \Yd_j,$ the filtering distribution with 
expectation denoted by $\mathbb{E}$. Then
   \begin{equation*}
        \frac{\mathbb{E}^{\Yd_j}\mathbb{E}\Bigl|v_j - \mathbb{E}v_j\Bigr|^2}{\mathbb{E}^{(\vd_j,\Yd_j)}\Bigl|\vd_j-\mathbb{E}v_j\Bigr|^2} = 1.
    \end{equation*}
\end{theorem}
\begin{proof}
    This is a consequence of the properties of conditional probability,
    using that $\mathbb{P}(\vd_j,\Yd_j)$ can be factored as 
    $\mathbb{P}(\vd_j|\Yd_j)\mathbb{P}(\Yd_j).$ 
\end{proof}
\begin{remark}
This theorem motivates discussion of the 
\emph{spread-error ratio}\index{spread--error ratio} in
Chapter \ref{ch:LG}. This terminology is used because
the denominator is the mean square \emph{error} of the mean under
the filtering distribution, with respect to the true signal underlying
the data, averaged
over the joint distribution of the model; the numerator is
the variance under the filtering distribution (the \emph{spread}), 
averaged over the marginal on the data. The theorem explains
the sense in which the variance of the filter provides an estimate
of the error made by using the mean under the filter.
    Note also that the preceding statement and proof can be
    generalized to the smoothing distribution 
    $\mathbb{P}(\vd_j | \Yd)$ if $\Yd_j$ is replaced by $\Yd$.
\end{remark}














\section{Formulation of the \index{smoothing}Smoothing Problem}
\label{sec:smoothing}

Recall definitions of $\Vd, \Yd$ and $\Yd_j$ from \eqref{eq:VdYd}.
We note that the stochastic dynamics model \eqref{eq:sdm}
defines a probability distribution on $\Vd$, with density $\rho(\Vd),$ defined
through the Markovian structure as
\begin{equation}
\label{eq:sprior}
\rho(\Vd) \propto \exp\Bigl(-\frac12|\vd_0-m_0|_{C_0}^2-\frac12\sum_{j=0}^{J-1}|\vd_{j+1}-\Psi\bigl(\vd_j\bigr)|_{\Sigma}^2\Bigr).
\end{equation}





\begin{definition}
The \index{smoothing}{\em smoothing problem} is to find the probability density 
$\Pi^{\Yd}(\Vd):=\Prob(\Vd|\Yd) = \Prob(\{\vd_0, \ldots, \vd_J\}|\Yd_j)$ in
$\mathcal{P}(\R^{\du(J+1)})$ 
for some fixed integer $J.$ We refer to $\Pi^{\Yd}$ as the \index{smoothing!distribution}{\em  smoothing distribution}.
\end{definition}

To make connection with the Bayesian inverse problems of Chapter \ref{ch1} we define
$$\etad := \{\etad_1, \ldots, \etad_J\} \in \R^{\dy J},$$
noting that $\etad \sim \Nc(0, \Gammas)$, where $\Gammas$ is block diagonal with $\Gamma$ in 
each diagonal block. If we then define $\hs:\R^{\du(J+1)} \to \R^{\dy J}$ by
$$\hs(\Vd):=\bigl\{h(\vd_1), \ldots, h(\vd_J) \bigr\}$$
then the \index{data model}data model may be written as
$$\Yd=\hs(\Vd)+\etad.$$
We are interested in finding $\Prob(\Vd|\Yd)=\Pi^{\Yd}\!(\Vd).$ We may apply Bayes Theorem \ref{t:bayes},
with prior $\rho$ noting that, under this prior, $\Vd \ind \etad,$ the standard setting for Bayesian inversion
from Chapter \ref{ch1}. We obtain
\begin{equation}
\label{eq:spost}
\Pi^{\Yd}\!(\Vd) \propto \exp\Bigl(-\frac12|\Yd-\hs(\Vd)|_{\Gammas}^2\Bigr)\rho(\Vd),
\end{equation}
also a probability density function in $\mathcal{P}(\R^{\du(J+1)})$.
Recall from Chapter \ref{ch1} the likelihood\index{likelihood} which here has the form
\begin{equation}
    \label{eq:likes}
    \like(\Yd|V) \propto \exp\Bigl(-\frac12|\Yd-\hs(V)|_{\Gammas}^2\Bigr),
\end{equation}
enabling us to write \eqref{eq:spost} in the form
\begin{equation}
\label{eq:spost2}
\Pi^{\Yd}\!(V) \propto \like(\Yd|V)\rho(V).
\end{equation}
Note that $V$ is a dummy variable, explaining why we have dropped the $\dagger$ on it, but not on the fixed instance of the data $\Yd.$






\section{Kalman Filter}\index{Kalman filter}
\label{sec:kalman}

Suppose that at time $j$, $\Psi(\cdot) = A_j \cdot$ and $h(\cdot) = H_j \cdot$: the model and observation operator are linear, but can change in time. Then the solution to the filtering problem is Gaussian and $\pi_j=\cN(v_j, C_j)$,
$\hat{\post}_{j+1}=\cN(\hat{v}_{j+1},\hat{C}_{j+1}).$ The update rules for the mean and covariance are given by the \emph{Kalman filter}\index{Kalman filter}: the mean updates according to
\begin{subequations}\label{eq:kalman_mean}
\begin{align}
\hat{v}_{j+1} &= A_j v_j,\\ 
v_{j+1} &= \hat{v}_{j+1} + K_{j+1} \bigl(\yd_{j+1}-H_{j+1}\hat{v}_{j+1}\bigr);
\end{align}
\end{subequations}
here the \emph{Kalman gain}\index{Kalman gain} $K_j$ is determined by the
update rule for the covariances
\begin{subequations}
\begin{align}
\label{eq:udc}
\hat{C}_{j+1} &= A_j C_{j} A_j^\top + \Sigma,\\
K_{j+1} &= \hat{C}_{j+1} H_{j+1}^\top \bigl(H_{j+1} \hat{C}_{j+1} H_{j+1}^\top + \Gamma\bigr)^{-1},\\
C_{j+1} &= (I - K_{j+1}H_{j+1})\hat{C}_{j+1}.
\end{align}
\end{subequations}

Note that the update for the covariance evolves independently of the update
for the mean. Furthermore, the covariance update is independent of the data.
To motivate 3DVar, which we describe in the next section, we note that if $A_j = A$ and $H_j = H$ are constant in time, and
the covariance is in steady state, then $C_{j+1}=C_j=C_\infty$ and 
$\hC_{j+1}=\hC_j=\hC_\infty.$ Under appropriate controllability and observability assumptions,  
 \index{Kalman filter!steady state}the steady-state covariance and gain can be obtained by finding the unique solution $(\hC_\infty, K_{\infty})$ to the equations
\begin{subequations}
\label{eq:ss_kalman}
\begin{align}
    \hC_\infty &= A (I - K_{\infty}H)\hC_{\infty} A^\top + \Sigma,\\
    K_\infty &= \hC_\infty H^\top (H \hC_\infty H^\top + \Gamma)^{-1} ,\label{eq:ss_kalman_gain}
\end{align}
\end{subequations}
and setting 
\begin{equation}
\label{eq:ss_kalman2}
C_{\infty} = (I - K_{\infty}H)\hC_{\infty}.
\end{equation}

Using the steady-state Kalman gain from (\ref{eq:ss_kalman}), 
the state updates become
\begin{subequations}
\label{eq:ssK}
\begin{align}
\hat{v}_{j+1} &= A v_j,\\ 
v_{j+1} &= \hat{v}_{j+1} + K_\infty \bigl(\yd_{j+1}-H\hat{v}_{j+1}\bigr).
\end{align}
\end{subequations}
We note the form of this update of the mean $v_j \mapsto v_{j+1}:$ it comprises
a prediction\index{prediction} step $v_j \mapsto \hv_{j+1},$ derived from the stochastic dynamics model, and an analysis\index{analysis} 
step $\hv_{j+1} \mapsto v_{j+1}$ defined by the data model.

\section{3DVar}\index{3DVar}\index{variational!3-dimensional|see{3DVar}}
\label{sec:3dvar}

Motivated by the form \eqref{eq:ssK} of the mean update equations 
for the Kalman filter,
when the gain is in steady state, we propose the following generalization
to the setting of nonlinear $(\Psi,h):$
\begin{subequations}
\label{eq:pred3DVAR}
\begin{align}
\hat{v}_{j+1} &= \Psi(v_j)+s\xi_{j},\\ 
v_{j+1} &= \hat{v}_{j+1} + K \bigl(\yd_{j+1}-h(\hat{v}_{j+1})\bigr).	
\end{align}
\end{subequations}
The most basic form will use $s=0$; this is then consistent with
the Kalman filter with frozen gain \eqref{eq:ssK}. If $s=1$ is used, to mimic the true forward model, then $\xi_{j} \sim \Nc(0,\Sigma)$ is an i.i.d. sequence.


\begin{remark}
\label{rem:cycled}
    We make some comments on the terminology 3DVar\index{3DVar} that we employ here. The
    approach is in fact more properly termed \emph{cycled 3DVar}\index{3DVar!cycled}. 
    In this context the \emph{3DVar} component of the nomenclature refers to the analysis step (\ref{eq:pred3DVAR}b), and its formulation via an optimization problem, which we detail below; the \emph{cycled} component of the nomenclature refers to repeatedly solving this optimization problem, as each data point is acquired, and interleaving this with the prediction step (\ref{eq:pred3DVAR}a). The use of  3D refers to the fact that, in weather
    forecasting, the optimization problem is for a field in three physical
    space dimensions.
    
    To appreciate this connection to optimization we consider the case where $\Psi$ is allowed to be nonlinear, but $h(\cdot)=H\cdot$ is linear. The predict-then-optimize viewpoint then leads to 3DVar above if $v_{j+1}$ is computed from $(\hv_{j+1},\yd_{j+1})$ by solving the optimization problem
    \begin{subequations}
\begin{align} 
\J_j(v) &= \frac{1}{2}|v-\hv_{j+1}|^2_{\hC}+\frac12|\yd_{j+1}-Hv|^2_{\Gamma},\\
v_{j+1} &\in \argmin_{v \in \R^d} \J_j(v).
\end{align}
\end{subequations}
This minimization is equivalent to (\ref{eq:pred3DVAR}b), in the case $h(\cdot)=H\cdot$,
provided that
\begin{equation}
\label{eq:gain3}
    K = \hC H^\top (H \hC H^\top + \Gamma)^{-1}.
\end{equation}


In particular this indicates a methodology for choosing $K$: instead
choose an estimate of the uncertainty in the prediction, $\hC$, and use this to
define $K.$ This approach to modeling $\hC$, and then deducing $K$, is natural because the uncertainty in the prediction is an interpretable quantity.
\end{remark}

\section{Extended Kalman Filter (ExKF)}\index{Kalman filter!extended}\label{sec:exkf}

The extended Kalman filter (ExKF) generalizes the Kalman filter to nonlinear dynamics and observation operators by linearizing these functions in order to compute the gain and propagate the covariance. We define the Jacobians of these functions and evaluate them at the outputs $v_j$ and $\hat{v}_j$ of a putative
filtering algorithm:
\begin{subequations}
\label{eq:lin}
\begin{align}
    A_j &:= D\Psi(v_{j}),\\
    H_j &:= Dh(\hat{v}_j).
\end{align}
\end{subequations}
These Jacobians may be known analytically; otherwise, auto-differentiation\index{auto-differentiation} (Section \ref{sec:auto-differentiation}) can be used to obtain them.

The mean update is then done using the nonlinear $\Psi$ and $h$,
similarly to 3DVar \eqref{eq:pred3DVAR} with $s=0$ and with an evolving gain:
\begin{subequations}\label{eq:ekf_mean}
\begin{align}
\hat{v}_{j+1} &= \Psi(v_j),\\ 
v_{j+1} &= \hat{v}_{j+1} + K_j \bigl(\yd_{j+1}-h(\hat{v}_{j+1})\bigr).
\end{align}
\end{subequations}
The computation of $K_j$, and the covariances involved in its
definition, uses \eqref{eq:udc}, but with evolving $(A_j,H_j)$
defined by \eqref{eq:lin}:
\begin{subequations}
\begin{align}
\hat{C}_{j+1} &= A_j C_{j} A_j^\top + \Sigma,\\
K_{j+1} &= \hat{C}_{j+1} H_{j+1}^\top \bigl(H_{j+1} \hat{C}_{j+1} H_{j+1}^\top + \Gamma\bigr)^{-1},\\
C_{j+1} &= (I - K_{j+1}H_{j+1})\hat{C}_{j+1}.
\end{align}
\end{subequations}

\begin{remark}
\label{rem:cycled2}
    The extended Kalman filter recovers the true filtering distribution in the case of linear $\Psi$ and $h$, in which case it reduces to the standard Kalman filter. It can often perform well beyond the linear Gaussian setting:
    when $\Psi$ and $h$ are close to linear; or when small covariances are assumed in both the dynamics and data
    models, in order to justify linearization of the predictive and analysis
    distributions about the mean. 
\end{remark}

Despite the simplicity of the ExKF,
computing covariances when $\du$ or $\dy$ is large can be prohibitively
expensive. This motivates the ensemble methods we describe next.

\section{Ensemble Kalman Filter (EnKF)}\index{Kalman filter!ensemble}\index{EnKF|see{Kalman filter, ensemble}}
\label{sec:enkf}

\subsection{The EnKF Algorithm}\label{ssec:enkf}

The content of Remark \ref{rem:cycled}, concerning 3DVar, is to shift 
the problem of choosing $K$ to one of
choosing $\hC$, an estimate of the uncertainty in the predictions.
In Remark \ref{rem:cycled2}, concerning ExKF, it is discussed how 
this may be achieved via linearization.
The ensemble Kalman filter (EnKF)\index{Kalman filter!ensemble}\index{Kalman filter!ensemble}
builds on this idea by running an ensemble of $N$ 3DVar-like algorithms,
with a time dependent gain $K_{j+1}$, estimated
via empirical estimates of the covariances of the predicted states
$\{\hat{v}_{j+1}^{(n)}\}_{n=1}^N$ and 
$\{h(\hat{v}_{j+1})^{(n)}\}_{n=1}^N$,
their mappings under $h$.

The ensemble $\{v_j^{(n)}\}_{n=1}^N \mapsto \{v_{j+1}^{(n)}\}_{n=1}^N$ according to
the following algorithm:
\begin{subequations}
\label{eq:predEnKF}
\begin{align}
\widehat{v}_{j+1}^{(\sam)} &= \Psi(v_{j}^{(\sam)})+\xi^{(\sam)}_{j}, \quad \sam=1,\ldots,\Sam, \label{eq:predEnKF_model}\\
v_{j+1}^{(\sam)} &= \widehat{v}_{j+1}^{(\sam)}+K_{j+1}\bigl(\yd_{j+1}-\eta_{j+1}^{(\sam)}-h(\widehat{v}_{j+1}^{(\sam)})\bigr),\quad \sam=1,\ldots,\Sam. 
\end{align}
\end{subequations}
Here $\xi_{j}^{(\sam)} \sim \Nc(0,\Sigma), \quad \eta_{j+1}^{(\sam)} \sim \Nc(0,\Gamma)$
are independent sequences of i.i.d. random vectors with respect to both $j$ and $n$, and
the two sequences themselves are independent of one another. The gain matrix $K_{j+1}$ is calculated according to
\begin{subequations}
\label{eq:gainEnKF}
\begin{align}
\widehat{m}_{j+1} &= \frac{1}{\Sam}\sum^{\Sam}_{\sam=1} \widehat{v}_{j+1}^{(\sam)}, \\
\widehat{h}_{j+1} &= \frac{1}{\Sam}\sum^{\Sam}_{\sam=1} h(\widehat{v}_{j+1}^{(\sam)}), \\
\widehat{C}_{j+1}^{vh} &= \frac{1}{\Sam}\sum^{\Sam}_{\sam=1}\bigl(\widehat{v}^{(\sam)}_{j+1}-\widehat{m}_{j+1}\bigr)\otimes \bigl(h(\widehat{v}^{(\sam)}_{j+1})-\widehat{h}_{j+1}\bigr),\\
\widehat{C}_{j+1}^{hh} &= \frac{1}{\Sam}\sum^{\Sam}_{\sam=1}\bigl(h(\widehat{v}^{(\sam)}_{j+1})-\widehat{h}_{j+1}\bigr)\otimes \bigl(h(\widehat{v}^{(\sam)}_{j+1})-\widehat{h}_{j+1}\bigr),\\
\widehat{C}_{j+1}^{yy} &= \widehat{C}_{j+1}^{hh}+\Gamma,\quad
K_{j+1} = \hat{C}_{j+1}^{vh}\bigl(\hat{C}_{j+1}^{yy}\bigr)^{-1}.
\end{align}
\end{subequations}

\begin{remark}
    \label{rem:lh}
We note that in the case where $h(\cdot)=H\cdot$ (and is hence linear) we may calculate the gain
through estimation of a single covariance, as follows:
\begin{subequations}
\begin{align}
\label{eq:lh}
\widehat{C}_{j+1} &= \frac{1}{\Sam}\sum^{\Sam}_{\sam=1}\bigl(\widehat{v}^{(\sam)}_{j+1}-\widehat{m}_{j+1}\bigr)\otimes \bigl(\widehat{v}^{(\sam)}_{j+1}-\widehat{m}_{j+1}\bigr),\\
K_{j+1} &= \hat{C}_{j+1} H^\top \bigl(H \hat{C}_{j+1} H^\top + \Gamma\bigr)^{-1}.\label{eq:single_cov}
\end{align}
\end{subequations}
This should be compared with \eqref{eq:gain3}, used in 3DVar. The analysis mean and covariance can be estimated as
\begin{subequations}
    \begin{align}
        {m}_{j+1} &= \frac{1}{\Sam}\sum^{\Sam}_{\sam=1} {v}_{j+1}^{(\sam)},\\
        {C}_{j+1} &= \frac{1}{\Sam}\sum^{\Sam}_{\sam=1}\bigl({v}^{(\sam)}_{j+1}-{m}_{j+1}\bigr)\otimes \bigl({v}^{(\sam)}_{j+1}-{m}_{j+1}\bigr).
    \end{align}
\end{subequations}
\end{remark}

The ensemble may be used to furnish an approximation of the filtering distribution
by simply forming an empirical measure from the ensemble members: we approximate\
$\pi_j \approx \pie_j$ where
\begin{equation}
\label{eq:empEnKF}
    \pie_j = \frac{1}{N}\sum_{n=1}^N \delta_{v_j^{(n)}}.
\end{equation}

\begin{remark}
\label{rem:enkf}
Conditions under which \eqref{eq:empEnKF} provides a good approximation of
the true filtering distribution are discussed in the bibliography Section \ref{sec:dabib}, and revolve around Gaussian approximations. When the true filtering distribution
is far from Gaussian the method will not provide a good
approximation.

However ensemble Kalman filters are widely used in high
dimensional problems because they do not suffer from the weight
collapse that plagues the particle filters of Sections \ref{sec:pf} and \ref{sec:opf}.
Ensemble Kalman filters often need inflation and localization to perform well for high-dimensional systems, for chaotic dynamical systems, and for small ensemble sizes.  Inflation and localization are discussed in the following two subsections.
\end{remark}

\subsection{Inflation}\label{sec:inflation}\index{inflation}

For simplicity we confine the discussion to the case of linear
observation operator $h(\cdot)=H\cdot.$ The ensemble Kalman gain
is then determined by $\widehat{C}_{j+1}$, as explained in Remark \ref{rem:lh}.
We assume that the covariance at infinite sample size $N=\infty$ 
leads to the optimal gain; this is provably true for linear $\Psi$,
as discussed in the bibliography. From this perspective,
ensemble Kalman filters suffer from sampling error due to finite ensemble size
$N$. Sampling error in the forecast covariance matrix $\widehat{C}_{j+1}$ leads systematically to underestimation of the analysis covariance ${C}_{j+1}$. In severe cases, this can lead to filter divergence,\index{filter divergence} whereby repeated underestimation of the forecast covariance leads to the filter putting increasingly more weight on the forecasts than observations, eventually becoming unresponsive to observations.

The underestimation of the analysis covariance is often mitigated by inflating the covariance of the forecast ensemble, although it can also be applied to the analysis ensemble instead. The most common form of inflation is \emph{multiplicative inflation}, whereby the forecast ensemble is modified as
\begin{equation}\label{eq:inflation}
    \widehat{v}_{j+1}^{(\sam)} \to \widehat{m}_{j+1} + \alpha (\widehat{v}_{j+1}^{(\sam)} - \widehat{m}_{j+1}),
\end{equation}
with $\alpha \geq 1$ being the inflation parameter. This corresponds to scaling the covariance $\widehat{C}_{j+1}$ by $\alpha^2$.

We provide two illustrative examples motivating the underestimation of the analysis covariance.

\begin{example}\label{ex:sampling_error}
Suppose that we assimilate a scalar observation of the $k$th variable into the $i$th variable, i.e., $H$ is a $1\times d$ vector with a 1 in the $k$th position and zeros elsewhere. It may then be shown that
    \begin{equation*}
       (C)_{ii} - (\widehat{C})_{ii} =  \frac{-(\widehat{C})_{ik}^2}{(\widehat{C})_{kk} + (\Gamma)_{kk}}.
    \end{equation*}
    Now, suppose that variables $i$ and $k$ are in fact uncorrelated, i.e., $(\widehat{C})_{ik} = 0$ when estimated with an infinite ensemble $N\to\infty$. In an EnKF, due to sampling error resulting from a finite ensemble, the estimated $(\widehat{C})_{ik} \neq 0$, leading to a spurious reduction in the analysis covariance, with respect to its value in
    the predicted ensemble.
    \end{example}


\begin{example}\label{ex:sampling_error2}
Inflation is also used to compensate for an unknown $\Sigma$. If the $\xi^{(\sam)}_{j}$ are excluded in \eqref{eq:predEnKF_model}, then the covariance $\widehat{C}_{j+1}$ will be underestimated in (\ref{eq:lh}).
\end{example}

Theoretical results on the impact of sampling error on EnKFs, including results on the optimal value of the inflation parameter under assumptions on the model dynamics, are referenced in the bibliography, Section \ref{sec:dabib}.

\subsection{Localization}\label{sec:localization}\index{localization}

In addition to the undersampling effects from the previous subsection,
further negative impacts of sampling errors on EnKFs can arise in spatially extended systems. In such physical systems there is typically decay of correlations with distance; sampling error\index{sampling error} can induce
spurious long-range correlations. In the empirical covariance matrices computed by the EnKFs, nearby points in space are likely to be truly correlated, while ones that are farther apart may only have spurious correlations from sampling error. These spurious correlations not only lead to an underestimation of the analysis covariance, as discussed in Example \ref{ex:sampling_error}, but also lead to degraded state estimate due to spurious information transfer between uncorrelated variables.

\emph{Localization}\index{localization} damps covariances in the empirical covariance matrices computed by the EnKF according to distance. A common way of implementing localization is by taking the Hadamard\index{Hadamard product} product\footnote{Also known as Schur\index{Schur product} product, this computes the elementwise product of two matrices
of the same dimension.} of the empirical covariance with a localization matrix $L$:
\begin{equation}\label{eq:loc_cov}
    \widehat{C}_{j+1}\to L \circ \widehat{C}_{j+1}.
\end{equation}
Typically, $L$ is constructed such that the covariance between between the $i$th and $k$th locations is exponentially damped according to the distance $D_{ki}$ between them, with some characteristic length scale $\ell$:
\begin{equation}\label{eq:loc}
    (L)_{ik} = e^{-D_{ik}^2/\ell}.
\end{equation}
The choice of $\ell$ will depend on the ensemble size, the correlation scales in the system, and the time between analysis steps (since this will control how far information has had time to propagate). Localization can also be implemented in other ways, such as domain localization and observation localization, discussed in the bibliography, Section \ref{sec:dabib}; we will restrict our discussion to covariance localization \eqref{eq:loc_cov}.

\begin{remark}
\label{r:loc1}    
If $h(\cdot)$ is linear, the localized $\widehat{C}_{j+1}$ is used to compute the gain as per \eqref{eq:single_cov}. If $h(\cdot)$ is nonlinear, then localization needs to be applied to both $\widehat{C}_{j+1}^{vh}$ and $\widehat{C}_{j+1}^{hh}$. If the $h(\cdot)$ is such that each observation has a corresponding spatial location, then localization can be applied as discussed above. If some observations correspond to, e.g., spatially integrated quantities, then localization is not straightforward to apply.
\end{remark}

\begin{remark}
\label{r:loc2}  
Besides the sampling error considerations discussed above, localization is also important in increasing the rank of the forecast covariance matrix. When the ensemble size $N$ is less than the system dimension $d$, the forecast covariance will be rank deficient. This implies that the analysis ensemble will lie in the span of the forecast ensemble, and thus that analysis increments are restricted to an $N$-dimensional subspace. Localization typically increases the rank of the forecast covariance, bypassing this subspace problem.
\end{remark}

\section{Bootstrap Particle Filter}\index{particle filter}\index{particle filter!bootstrap}
\label{sec:pf}

A more general methodology for approximating the filtering distribution
with an interacting ensemble is the particle filter (PF). We make the empirical approximation to the filtering distribution
$\pi_j \approx \pip_j$. Here $\pip_0=\pi_0=\cN(m_0,C_0)$
and, for $j \in \mathbb{N}$,
\begin{equation}
\label{eq:pip2}    
\pip_j = \sum_{n=1}^N w_{j}^{(n)}\delta_{\widehat v_{j}^{(n)}},
\end{equation}
where the particles $\widehat v_{j}^{(n)}$ and weights $w_{j}^{(n)}$
evolve according to
\begin{subequations}
\label{eq:bpf2}
\begin{align}
    \widehat v_{j+1}^{(n)} &= \Psi \bigl(v_j^{(n)}\bigr) + \xi_j^{(n)},\qquad v_{j}^{(n)} \overset{\rm i.i.d.} {\sim} \pip_j,\\
    \ell_{j+1}^{(n)} &= \exp \left( - \frac{1}{2} \bigl\lvert \yd_{j+1} - h\bigl(\widehat v_{j+1}^{(n)}\bigr) \bigr\rvert_{\Gamma}^2 \right),\\
w_{j+1}^{(n)}&= \ell_{j+1}^{(n)}\Big/\Bigl(\sum_{m=1}^N \ell_{j+1}^{(m)}\Bigr).
\end{align}
\end{subequations}
Here $\xi_{j}^{(n)} \sim \cN(0, \Sigma)$  are Gaussian random variables,
i.i.d.\ with respect to both $n$ and $j.$ 

At each step, the particle filter alternates sampling from the Markovian dynamics, the prediction\index{prediction} $\Pred$, implemented in (\ref{eq:bpf2}a), followed by an application of Bayes theorem, the 
analysis\index{analysis} $\An(\cdot;\yd_{j+1})$ which is implemented using importance sampling as in \eqref{eq:pip2}, with weights as in (\ref{eq:bpf2}c).
The resulting algorithm is known as the bootstrap particle filter. 

\begin{remark}
\label{rem:pf}
The bootstrap particle filter\index{particle filter!bootstrap}
is provably convergent to the true filtering distribution
as $N \to \infty$, under quite general conditions, including
filters that are far from Gaussian; this should be contrasted
with ensemble methods as discussed in Remark \ref{rem:enkf}.
On the other hand the bootstrap particle filter\index{particle filter!bootstrap} can perform poorly in high dimensions,
suffering from weight collapse. Ensemble methods have been
designed to perform well in high dimensions, and methodology
for this is also discussed in Remark \ref{rem:enkf}.
\end{remark}

\section{Optimal Particle Filters}\index{particle filter!optimal}
\label{sec:opf}

The optimal particle filter\index{particle filter!optimal}  
differs from the bootstrap particle filter
by reversing the order of the Bayesian inference step and the sampling from a Markovian kernel based on the dynamics.
In particular, the optimal particle filter first incorporates the observation $y_{j+1}$ by evaluating the likelihood weights $\Prob(y_{j+1}|v_j)$ for each particle, and then samples from the probability distribution $\intp_{j+1}:=\Prob(v_{j+1}|v_j,y_{j+1})$. This has the potential advantage that the kernel in the optimal particle filter $\intp_{j+1}$ incorporates knowledge of the current observation; in contrast the
bootstrap particle filter simply predicts with the unconditioned forecast kernel $\Pred,$ drawing samples from $\Prob(v_{j+1}|v_j)$ and then reweighting them
to reflect the observation.

\begin{remark}
\label{rem:opt}
\emph{Optimality} here refers to minimizing the variance
of the weights, over one step of the filter, over a wide
class of possible particle based methods. Once
cycled through multiple steps $j$, this optimality property
is lost. However there is a clear intuitive benefit in using
the optimal rather than the bootstrap particle filter:
\index{particle filter!optimal}\index{particle filter!bootstrap}
in the optimal setting the particles that are reweighted, in one step, use information about the new data point; in
the bootstrap setting they do not.
\end{remark}

In general nonlinear settings, it may not be possible to implement the optimal particle filter exactly. This arises for two reasons. First, the likelihood weights must integrate the dependence on the latent variable $v_{j+1}$. That is, the integral
$$\Prob(y_{j+1}|v_j) = \int \Prob(y_{j+1}|v_{j+1})\Prob(v_{j+1}|v_j) \, dv_{j+1},$$
may not have a closed form. Second, sampling exactly from  $\intp_{j+1}$ may not be possible.

One setting where it is tractable to evaluate the likelihood weights and sample from $\intp_{j+1}$ is when the observation model is linear, i.e., $h(\cdot) = H\cdot$ for some $H \in \R^{k \times d}$. Let us consider the dynamic and observation models
\begin{subequations}
\label{eq:linearobs}
\begin{align}
\vd_{j+1} &= \Psi(\vd_j) + \xid_j , \\
\yd_{j+1} &= H\vd_{j+1} + \etad_{j+1}\,.
\end{align}
\end{subequations}
For this dynamics/data model we make the same Gaussian and independence 
assumptions on the initialization and noise as made in equations \eqref{eq:sdm}, 
\eqref{eq:dm} and Assumption \ref{a:fas}.
In this case, the models for propagation of the state and observation can be combined 
to yield the likelihood function 
\begin{equation}
    \label{eq:twe}
\Prob(y_{j+1}|v_j) = \mathcal{N}\bigl(H\Psi(v_j), H\Sigma H^\top + \Gamma\bigr).
\end{equation}
The Markovian kernel for the dynamics is given by
\begin{align*}
    \Prob(v_{j+1}|v_j,y_{j+1}) &\propto \Prob(y_{j+1}|v_{j+1},v_j)\Prob(v_{j+1}|v_j) \\
    &= \Prob(y_{j+1}|v_{j+1})\Prob(v_{j+1}|v_j).
\end{align*}
This density is a quadratic function of $v_{j+1}$ and so following a similar derivation to the update for 3DVar, the Markov kernel is Gaussian, i.e., $\Prob(v_{j+1}|v_j,y_{j+1}) = \mathcal{N}(m_{j+1},C),$
where the mean $m_{j+1}$ is given by
\begin{equation}
    \label{eq:meanopt}
 m_{j+1} = (I - KH)\Psi(v_j) + Ky_{j+1} \\   
\end{equation}
and the covariance $C$ satisfies
\begin{subequations}
    \label{eq:covopt} 
\begin{align}
C &= (I - KH)\Sigma, \\
K &= \Sigma H^\top S^{-1}, \\
S &= H\Sigma H^\top + \Gamma.
\end{align}
\end{subequations}
Given the dynamics and observation model and the observation $y_{j+1},$ we can sample from $\intp_{j+1}$ by sampling from the Gaussian kernel $\mathcal{N}(m_{j+1},C)$, and we can reweight using likelihood \eqref{eq:twe} to build a sample approximation for $\pi_{j+1}$. 

To define the OPF algorithm we define matrix triple $(C,K,S)$ by \eqref{eq:covopt}
and make the empirical approximation to the filtering distribution
$\pi_j \approx \pop_j$. Here $\pop_0=\pi_0=\cN(m_0,C_0)$
and, for $j \in \mathbb{N}$,
\begin{equation} 
\label{eq:pop}
\pop_j = \sum_{n=1}^N w_{j}^{(n)}\delta_{\widehat v_{j}^{(n)}}
\end{equation}
where the particles $\widehat v_{j}^{(n)}$ and weights $w_{j}^{(n)}$
evolve according to, for $\xi_{n+1}^{(n)} ~\text{i.i.d.}\thinspace \mathcal{N}(0,C)$,
\begin{subequations}
\label{eq:opf99}
\begin{align}
    \widehat{v}_{j+1}^{(n)} &= (I - KH)\Psi(v_j^{(n)}) + K\yd_{j+1} + \xi_{j+1}^{(n)},
    \qquad v_{j}^{(n)} \overset{\rm i.i.d.} {\sim} \pop_j,\\
    \ell_{j+1}^{(n)} &= \exp\left(-\frac12|\yd_{j+1} - H\Psi(v_j^{(n)})|_S^2\right), \\
    w_{j+1}^{(n)} &= \ell_{j+1}^{(n)} / \sum_{m=1}^N \ell_{j+1}^{(m)}.
\end{align}
\end{subequations}





\section{4DVar}\index{4DVar}\index{variational!4-dimensional|see{4DVar}}
\label{sec:4dvar}




We introduce the 4DVar\index{4DVar} methodology, a nomenclature which
abbreviates the specific \emph{weak constraint 4DVar}\index{4DVar!weak constraint} formulation that we focus on here. In short
this method computes a MAP estimator\index{MAP estimator} (see Definition \ref{def:map}) for the smoothing 
problem from Section \ref{sec:smoothing}. To this end we define
$$V := \{v_0, \ldots, v_J\}$$
and set
\begin{equation}
\label{eq:regS}
\reg(V) := \frac{1}{2}|v_0-m_0|^2_{C_0} + \frac{1}{2}  \sum_{j=0}^{J-1} |v_{j+1} - \Psi(v_j)|^2_{\Sigma}. 
\end{equation} 
Note that $\exp\bigl(-\reg(V)\bigr)$ is proportional to the prior density
given in \eqref{eq:sprior}.
We also define
\begin{equation}
\label{eq:lossSA}
\loss(V;\Yd) :=  \frac{1}{2} \displaystyle{\sum_{j=0}^{J-1}}|\yd_{j+1} - h(v_{j+1})|_{\Gamma}^2. 
\end{equation}
Note that $V \in \R^{\du(J+1)}$ and $\Yd \in \R^{\dy J}$ and that
$\exp\bigl(-\loss(V;\Yd)\bigr)$ is proportional to the prior density
given in \eqref{eq:likes}.
We add the expressions in \eqref{eq:regS} and \eqref{eq:lossSA} to obtain
\begin{align}
\label{eq:objS}
\J(V;\Yd)&  =\reg(V)+\loss(V;\Yd),
\end{align}
noting that $\exp\bigl(-\J(V)\bigr)$ is proportional to the posterior density
given in \eqref{eq:spost2}. The MAP estimator\index{MAP estimator} for this posterior is given by
\begin{equation} \label{eq:4DVarasMAP}
\Vs \in \argmin_{V \in \R^{\du(J+1)}} \J(V;\Yd).
\end{equation}
We then take $\Vs$ as our estimate of $\Vd.$ 


\begin{remark}
\label{eq:ws}
Minimization \eqref{eq:4DVarasMAP} is often implemented using Newton\index{Newton's method}
or Gauss--Newton\index{Gauss--Newton} methodologies (see Section \ref{sec:NGN}). Ensemble approximations of Gauss-Newton
are also used.

The problem  \eqref{eq:4DVarasMAP} is the (weak constraint) 4DVar method.\index{4DVar!weak constraint} Strong constraint 4DVar\index{4DVar!strong constraint} is found by letting $\Sigma \to 0$, resulting in a minimization problem over $v_0 \in \R^d.$ 
The name 4DVar refers to the fact that, in weather
forecasting, the optimization problem is for a field in three physical
space dimensions and one time dimension.

As with all MAP estimators, the result of applying 4DVar is simply a point
estimator. To obtain information about the posterior with density proportional
to $\exp\bigl(-\J(V)\bigr)$ requires the use of methods such as Markov chain Monte Carlo (MCMC) and sequential Monte Carlo (SMC),
or variational approximations.
\end{remark}



\section{Reanalysis}\index{reanalysis}
\label{sec:rean}



\emph{Reanalysis}\index{reanalysis}, also known as retrospective analysis, is concerned with retrospectively producing an estimate of the trajectory of a system, or the conditional probability distribution of the states given the observations.
There may be several reasons for doing this: (i) since filtering is often done in an online mode, returning to find a smoothing estimate of the past uses more
information from the observations; (ii) it may be desirable to have an estimate of
the past which is actually a trajectory of a proposed dynamics model, something not provided by filtering; (iii) new observations of the past may become available; (iv) the model, or filtering/smoothing method of choice may change over time. A reanalysis dataset uses the same model and data assimilation method throughout the entire interval, and incorporates all possible observations. Reanalyses can be produced by either filters or smoothers, although the latter is preferred since they make maximum use of the available observations.


\begin{remark}
An important feature of reanalysis is that it consolidates possibly sparse, irregular observations to give at every time step a complete state estimate of the system on the model state space. The extent to which the information from observed parts of the system can transfer to unobserved parts is formalized under the concept of \emph{observability}; see the Bibliography for references.\index{observability}
Moreover, reanalysis datasets, due to the impact of the observational nudging, are often assumed to have lower impact of model error (see Section \ref{sec:meda}) than the raw forecasts produced by the model. This is discussed in Section \ref{sec:analysis_increments}.
For these two reasons, reanalyses are often used 
to train ML forecast models.
\end{remark}




\section{Model Error}\index{model error}
\label{sec:meda}

We now consider the \index{data assimilation} data assimilation problem in the setting where parts of the model are unknown, building on discussions
in Section \ref{sec:ME} for the general inverse problem. To describe \index{forecast model error}\emph{forecast model error}, we introduce parameter
$\vartheta$ which captures unknown aspects of the systematic part of the dynamical model.
The stochastic dynamics model\index{stochastic dynamics model} becomes
\begin{subequations}
\label{eq:sdm_err}
\begin{align}
\vd_{j+1} &= \Psi_\vartheta(\vd_j) + \xid_j, \: j \in \Z^+,\\
\vd_0 &\sim \Nc\bigl(m_0, C_0\bigr), \: \xid_j \sim \Nc\bigl(0, \Sigma\bigr) \: \index{i.i.d.}\text{i.i.d.}\,, 
\end{align}
\end{subequations}
where we assume that sequence $\{ \xid_j \}$ is independent of initial condition $\vd_0;$ 
this is often written as $\{ \xid_j \} \ind \vd_0.$ 
To describe \index{observation model error} \emph{observation model error} we introduce parameter
$\varphi$ which captures unknown aspects of the observation
operator.
The \index{data model} data model becomes
\begin{subequations}
\label{eq:dm_err}
\begin{align}
\yd_{j+1} &= h_\varphi(\vd_{j+1}) + \etad_{j+1} , \: j \in \Z^+,\\
\etad_j &\sim \Nc\bigl(0, \Gamma\bigr) \: \index{i.i.d.}\text{i.i.d.}\,,
\end{align}
\end{subequations}
where we assume that $\{\etad_j\} \ind \vd_0$ for all $j$ and 
$\etad_k \ind \xid_j $ for all $j,k$.

\begin{remark}\label{rem:paramcov}
    We define unknown parameter $\theta=(\vartheta,\Sigma,\varphi,\Gamma).$ For simplicity we assume we
    learn all components of $\theta.$ However we recognize that
    it will often be of interest to learn only a subset of the
    parameters. Furthermore, the covariance matrices $\Sigma$ and
    $\Gamma$ may themselves be parameterized (for example as
    unknown parameter multiplying the identity).
\end{remark}

In the following two subsections we formulate
model error in the smoothing and filtering contexts.
Chapter \ref{ch:DAML} is devoted to detailed algorithms
concerned with learning model error.

\subsection{Model Error: Smoothing}\index{model error}
\label{ssec:medas}

To formulate learning of model error in the context of a smoothing problem we put a prior on $(\Vd,\theta)$, defined by the stochastic dynamics model for $\Vd|\theta$ and prior on $\theta$, 
and we condition on a likelihood defined by the data model.
Building on Section \ref{sec:smoothing} we define prior
\begin{equation}
\label{eq:spriorME}
\rho(\Vd,\theta) \propto \exp\Bigl(-\frac12|\vd_0-m_0|_{C_0}^2-\frac12\sum_{j=0}^{J-1}|\vd_{j+1}-\Psi_\vartheta\bigl(\vd_j\bigr)|_{\Sigma}^2\Bigr)\rho_\theta(\theta),
\end{equation}
where we have written the prior on $\Vd|\theta$ 
and then multiplied by prior
$\rho_\theta(\theta)$ on $\theta.$
As in  Section \ref{sec:smoothing} we define
$$\etad := \{\etad_1, \ldots, \etad_J\},$$
noting that $\etad \sim \Nc(0, \Gammas)$, where $\Gammas$ is block diagonal with $\Gamma$ in 
each diagonal block. If we then define
$$\hs_\varphi(\Vd):=\bigl\{h_\varphi(\vd_1), \ldots, h_\varphi(\vd_J) \bigr\}$$
then the \index{data model}data model may be written as
$$\Yd=\hs_\varphi(\Vd)+\etad.$$
We are interested in finding $\Prob(\Vd,\theta,|\Yd)=\Pi^{\Yd}(\Vd,\theta).$ We may apply Bayes Theorem \ref{t:bayes},
with prior $\rho$ noting that, under this prior, $\Vd \ind \etad,$ the standard setting for Bayesian inversion
from Chapter \ref{ch1}. We obtain
\begin{equation}
\label{eq:spost3}
\Pi^{\Yd}(\Vd,\theta) \propto \exp\Bigl(-\frac12|\Yd-\hs_\varphi(\Vd)|_{\Gammas}^2\Bigr)\rho(\Vd,\theta).
\end{equation}

\subsection{Model Error: Filtering}\index{model error}
\label{ssec:medaf}

It is also possible to use techniques based on filtering. To illustrate
this idea we consider the setting in which $\Sigma$ and $\Gamma$ are known and the unknown $\theta$ comprise only
$\vartheta$ and $\varphi$ appearing in $\Psi_\vartheta$   and $h_\varphi$, respectively. Consider the
following dynamical system, holding for all $j \in \Z^+:$
\begin{subequations}
\label{eq:sdm_err2}
\begin{align}
\vd_{j+1} &= \Psi_\vartheta(\vd_j) + \xid_j,\\
\vartheta^\dagger_{j+1} &= \vartheta^\dagger_j,\\
\varphi^\dagger_{j+1} &= \varphi_j^\dagger,\\
\yd_{j+1} &= h_\varphi(\vd_{j+1}) + \etad_{j+1}.
\end{align}
\end{subequations}
This can now be viewed as a filtering problem for 
$\{(\vd_j,\vartheta^\dagger_j,\varphi^\dagger_j)\}$ given the data
generated by $\{\yd_j\}.$ As it stands it is slightly out of the scope
of problems studied in Section \ref{sec:filtering}, because no noise
appears in the evolution of the unknown parameters. However, as mentioned in
Remark \ref{rem:gen}, filtering can be extended to this setting. Alternatively
it is possible to replace equations (\ref{eq:sdm_err2}b),(\ref{eq:sdm_err2}c)
by stochastic processes and to use an average over index $j$ of the filtering solution to provide a parameter estimate; in this context autoregressive
Gaussian processes are natural.

\subsection{Filtering with Small Model Error}

Assume that the true dynamics are given by systematic component defined
by function $\Psi$, but we only have access to an approximate model $\Psi^a$.

Ideally, data assimilation algorithms will not only filter the noise but also compensate for errors in approximating $\Psi.$  The next theorem provides the conditions under which a 3DVar\index{3DVar} filter  reduces model error as
data is acquired sequentially, on average.
In particular, we show that the error in the reconstructed solution will scale proportionally to the noise in the observations and the model error.

\begin{assumption} \label{as:true-model} Consider the dynamics and data
model \eqref{eq:sdm}, \eqref{eq:dm}, assume that the dynamics is noise-free ($\Sigma=0$)
and that the observation operator is linear ($h(\cdot)=H\cdot$). Let the sequence of observations $\yd_{j+1}$ be found from observing a true signal $v_{j}^\dagger$ given by
\begin{align*}
\vd_{j+1} &= \Psi(\vd_j),\\
\yd_{j+1} &= H\vd_{j+1} + \etad_{j+1}.
\end{align*}  
\end{assumption}

\begin{theorem}
\label{t:ques}
Let Assumption~\ref{as:true-model} hold and let $K$ be a gain matrix appearing in the mean update of the 3DVar method with an approximate forecast model $\Psi^a$:
$$m_{j+1} = (I - KH)\Psi^{a}(m_j) + K\yd_{j+1}.$$ 
Assume that $\Psi^a$ is close to $\Psi$ in the sense that, for some
$\delta \in [0,\infty)$,
\begin{align*} %
\sup_{v \in \R^{\du}} \bigl|(I - KH)\bigl(\Psi(v) - \Psi^{a}(v)\bigr)\bigr| &= \delta.
\end{align*}
Assume, further, the observability condition that there exists constant $\lambda \in (0,1)$ so that
\begin{align}\label{eq:Kalman_gain_conditions_ME}
    \sup_{v \in \R^{\du}} |(I - KH)D\Psi(v)| &\leq \lambda,
\end{align}
and denote 
$$\epsilon = \mathbb{E}|K\eta_j|.$$
Then, the 3DVar estimate based on the biased forecast model 
satisfies
$$\lim\sup_{j \rightarrow \infty} \mathbb{E}|m_j - v_j^\dagger| = \frac{\epsilon + \delta}{1 - \lambda}.$$
\end{theorem}

\begin{proof} The mean update in 3DVar with the biased forecast model is given by 
$$m_{j+1} = (I - KH)(\Psi(m_j) + b_j) + K\yd_{j+1},$$
where 
$$b_j:=\Psi^{a}(m_j)- \Psi(m_j)$$ 
represents bias in the forecast model at time $j$. Using the source of the observations, the error relative to the dynamics for the true signal $v_{j+1}^\dagger$ is given by
\begin{align*}
m_{j+1} - v_{j+1}^\dagger &= (I - KH)(\Psi(m_j) + b_j) + K(H\Psi(v_j^\dagger) + \eta_{j+1}^\dagger) - \Psi(v_j^\dagger) \\
&= (I - KH)(\Psi(m_j) - \Psi(v_j^\dagger)) + K\eta_{j+1} + (I - KH)b_j \\
&= \int_0^1 (I - KH)D\Psi(s m_j + (1 - s)v_j^\dagger)(m_j - v_j^\dagger) \, ds + K\eta_{j+1} + (I - KH)b_j,
\end{align*}
where in the last line we used the mean value theorem for $\Psi$ on the line segment $s m_j + (1-s)v_j^\dagger$ for $s \in [0,1]$. By the triangle inequality, the error is bounded by
\begin{align*}
|m_{j+1} - v_{j+1}^\dagger| &\leq \Bigl(\int_0^1 |(I - KH)D\Psi(s m_j + (1 - s)v_j^\dagger)| \, ds\Bigr)|m_j - v_j^\dagger| + |K\eta_{j+1}| + \delta\\
&\leq \Bigl(\int_0^1 \lambda \, ds\Bigr) |m_j - v_j^\dagger| + |K\eta_{j+1}| + \delta.
\end{align*}
Taking an expectation over the measurement errors, we have
$$\mathbb{E}|m_{j+1} - v_{j+1}^\dagger| \leq \lambda \mathbb{E}|m_{j} - v_{j}^\dagger| + \epsilon + \delta.$$
 Letting $e_j \coloneqq \mathbb{E}|m_{j+1} - v_{j+1}^\dagger|$ and applying the discrete Gronwall's inequality we have
$$e_{j} \leq \lambda^j e_0 + (\epsilon + \delta)\frac{1 - \lambda^j}{1 - \lambda}.$$
Noting that $\lambda < 1$, then $\lambda^j \rightarrow 0$ as $j \rightarrow \infty$ and so the result follows.
\end{proof}


\begin{remark} Theorem~\ref{t:ques} highlights that running the 3DVar algorithm for long times can correct for small model error. Moreover, this model error only needs to be controlled in the unobserved directions. That is, the overall error of the recovered state will be small if $(I-KH)b_j$ is small for all $j$, rather than the overall model error $b_j$ being small. Ideally, the gain $K$ in 3DVar is chosen such that the conditions in the assumption of Theorem~\ref{t:ques} hold; see the bibliography Section \ref{sec:dabib} for one such guarantee under an observability condition; this assumption could be checked when learning the correction.
\end{remark}


\section{Bibliography}
\label{sec:dabib}

For overviews of the subjects of data assimilation and filtering/smoothing, see the
text books \cite{jazwinski_stochastic_1970,law2015data,reich2015probabilistic,asch2016data,sarkka2013bayesian,bain2008fundamentals,crisan2011oxford,evensen2022data} and the review paper \cite{reich2019data}.  Furthermore the
books \cite{kalnay2003atmospheric,majda2012filtering} and the review paper \cite{carrassi2018data}
comprise pedagogical introductions to \index{data assimilation}data assimilation in the context of weather forecasting, turbulence modeling, and geophysical sciences, respectively. The importance of data assimilation for numerical weather forecasting was articulated in \cite{panofsky_objective_1949}, then known as \emph{objective analysis}, and connected to sequential estimation theory in \cite{ghil_applications_1981}.

The Kalman filter\index{Kalman filter} was introduced in \cite{kalman1960new}.
Discussion of the steady state covariance, and results concerning
convergence to the steady state, may be found in \cite{lancaster1995algebraic}.
The ideas of 3DVar\index{3DVar} for the solution of the analysis step was introduced in
the context of weather forecasting in \cite{lorenc1986analysis}.
For definition of the (cycled) 3DVar algorithm as employed here, see \cite{law2015data}.
For analysis of the (cycled) 3DVar algorithm see \cite{law2012analysis,moodey2013nonlinear}.

The EnKF\index{Kalman filter!ensemble} was introduced in \cite{evensen1994sequential}. See
\cite{asch2016data,evensen2022data,law2015data,reich2015probabilistic}
for more recent discussion of the methodology.
The methodology based around optimization has a probabilistic interpretation
in the Gaussian setting, and this can be used to justify the empirical
approximation \eqref{eq:empEnKF}. In the Gaussian setting see
\cite{le2009large,mandel2011convergence}; 
in the near Gaussian setting see \cite{carrillo2022ensemble}.
For an introduction to the particle filter see \cite{doucet2001introduction}.
For the optimal particle filter see \cite{doucet2000sequential}.
Particle filters typically suffer from weight collapse in high dimensional problems:
all weights become zero, except one \cite{bickel2008sharp,snyder2008obstacles}.

The impact of sampling error on EnKFs\index{Kalman filter!ensemble} in the case that the signal is a Gaussian process is addressed in \cite{sacher_sampling_2008}. Localization and inflation are reviewed in \cite{evensen2022data}. Insights into localization are given in \cite{furrer2007estimation,al-ghattas_non-asymptotic_2024,bickel2008regularized,al2023covariance,al2023optimal,al2024covariance,vishny_high-dimensional_2024}.
There are many variants of the EnKF, including ensemble square-root filters that are more computationally suited for high-dimensional problems than the formulation presented in this chapter \cite{tippett2003ensemble,hunt_efficient_2007}. Since these variants avoid the construction of the covariance matrices, localization is often implemented in these filters through \emph{domain localization}, where the spatial domain is divided into multiple areas, and analyses done locally in each. A popular EnKF variant that uses domain localization is the local ensemble transform Kalman filter (LETKF) \cite{hunt_efficient_2007}.



We note that besides the considerations about spurious correlations and forecast covariance rank discussed in the chapter, localization can also be interpreted in a dynamical systems context. For an EnKF\index{Kalman filter!ensemble}, one generally needs enough ensemble members to span the unstable--neutral subspace, corresponding to the number of non-negative Lyapunov exponents\index{Lyapunov exponents}, in order to prevent filter divergence.\index{filter divergence} This observation is supported by the fact that, in the case of linear dynamics, the forecast covariance matrix will collapse onto the unstable--neutral subspace; see the early work of \cite{trevisan_assimilation_2004} and the review of data assimilation for chaotic dynamics \cite{carrassi_data_2022} for references to these results. It has been observed, however, that dynamical systems such as the atmosphere are locally low dimensional \cite{patil_local_2001,oczkowski_mechanisms_2005}; that is, the dynamics within a spatial region may have a significantly lower dimension (as quantified by the dimension of the subspace spanned by the fastest growing modes) than that of the entire system, implying that filtering may be successful with a small ensemble when localization is applied.

For a discussion of 4DVar, in the context of weather forecasting, see
\cite{fisher2001developments}. As with all MAP estimators, 
the result of applying 4DVar is simply a point
estimator. To obtain information about the posterior with density proportional
to $\exp\bigl(-\J(V)\bigr)$ requires the use of methods such as MCMC\index{MCMC} \cite{brooks2011handbook}, SMC\index{SMC} \cite{del2006sequential} or variational
methods\index{variational Bayes} \cite{jordan1999introduction}.

The concept of reanalysis originates in atmospheric science \cite{uppala2005era}. Although operational weather forecasting has been done for decades, there have been considerable changes in forecast models and data assimilation methods, necessitating reanalysis to have a consistent trajectory estimate over decadal timescales.
One of the first reanalysis datasets for the atmosphere was produced by the National Centers for Environmental Prediction (NCEP) and the National Center for Atmospheric Research (NCAR) \cite{kalnay_ncepncar_1996}.
The subject of observability is reviewed in \cite{maybeck_stochastic_1982}.

Model error in data assimilation is often modelled by Gaussian noise, and encapsulated in the model noises $\xi^\dagger$. Deterministic formulations of model error are reviewed in \cite{carrassi_deterministic_2016}. The special case of model bias is considered in \cite{dee_data_1998}. Time-correlated model error is considered in \cite{amezcua_time-correlated_2018}. Methods for correcting model error are discussed in Chapter \ref{ch:DAML}, and a bibliography provided there.

While the effect of model bias on data assimilation is an open research topic, \cite{dee_data_1998} analyzed Kalman filtering in the presence of model bias. Under observability conditions,~\cite{maybeck_stochastic_1982} showed that the Kalman gain $K$ can be designed to satisfy the condition in~\eqref{eq:Kalman_gain_conditions_ME} for stability of a data assimilation scheme with linear dynamics; 
this is also related to the design of Luenberger observers in control theory.

\chapter{\Large{\sffamily{Learning Forecast and Observation Model}}}
\label{ch:DAML}
In Chapter~\ref{lecture7} we considered the data assimilation problem of estimating a time-evolving \index{state}state
in the setting where the models governing the state-observation system
are known. It is natural to ask how to extend this to settings where
the dynamical and observation models are  unknown. 
This chapter is devoted to the problem of estimating a time-evolving \index{state}state, together with the \index{dynamics}dynamics governing its evolution and the \index{data}data model from a window of partial and noisy \index{observation}observations of the \index{state}state. 

Jointly estimating the \index{state}state and parameters of the mathematical models governing the \index{dynamics}dynamics and \index{data}data is important in \index{data assimilation}data assimilation applications where available stochastic models are inaccurate or expensive to evaluate. The accuracy of \index{data assimilation}data assimilation can be improved, for instance, by estimating parameters in the model dynamics or by learning a \index{neural network}neural network model error correction; the efficiency of \index{data assimilation}data assimilation can be improved by leveraging machine-learned surrogate models that are cheap to evaluate. 

This chapter describes algorithmic frameworks to blend \index{data assimilation}data assimilation techniques for estimating the \index{state}state with \index{machine learning}machine learning techniques for recovering model parameters. 
After introducing the problem setting in Section \ref{sec:DAlearningmodels_setting}, Section \ref{sec:EMmodel_dynamics} describes the expectation-maximization (EM) framework for joint parameter and state estimation. In particular, we will present practical algorithmic instances of this framework to estimate parameters defining the deterministic mappings $\Psi$ and $h$ in the dynamics-data model and/or defining
the model error covariances within the dynamics-data model. Section \ref{sec:143} discusses auto-differentiable Kalman filters, an approach to maximum likelihood estimation of the parameters that relies on Kalman-type algorithms to approximate the likelihood function, and on auto-differentiation to approximate its gradient. 
Section~\ref{sec:analysis_increments} considers the specific problem of learning model error corrections for the dynamics. Section \ref{sec:144} closes with extensions and bibliographical remarks. The material in this chapter brings together many topics covered in these notes, including the \index{variational!formulation of Bayes theorem}variational formulations of \index{Bayes theorem}Bayes theorem (Chapter~\ref{ch:VI}), ensemble Kalman and particle \index{filtering}filtering algorithms (Chapter~\ref{lecture7}), parameterizations of functions for \index{machine learning}machine learning (Chapter \ref{ch:SL}), and \index{optimization}optimization (Chapter~\ref{ch:optimization}).



\section{The Setting}\label{sec:DAlearningmodels_setting}

Consider the \index{stochastic dynamics model}stochastic dynamics and \index{data model}observation models given by
\begin{subequations}
   \label{eq:SSM1}  
\begin{align}
        v_{j+1} &= \Psi_\vartheta(v_j) + \xi_j, && \xi_j \sim \Nc(0, \Sigma) \index{i.i.d.} \text{ i.i.d.}, \\
        y_{j+1} &= h_\uupsilon(v_{j+1}) + \eta_{j+1}, && \eta_j \sim \Nc(0, \Gamma) \index{i.i.d.}\text{ i.i.d.},
\end{align}
\end{subequations}
with \(v_0 \sim \Nc(m_0, C_0)\) and \(v_0 \,\bot\, \{\xi_j\} \,\bot\, \{\eta_j\}\) for $0 \leq j \leq J-1$. We assume that $v_j \in \R^\du$ and $y_j \in \R^\dy.$ We denote by $\theta \coloneqq \{\vartheta,\uupsilon,\Sigma,\Gamma\}$  the collection of unknown model parameters in the deterministic maps $\Psi_\vartheta$, $h_\uupsilon$ and the error covariances. We could extend to parameterizing
the error covariances, as discussed in Remark \ref{rem:paramcov}.

The \index{stochastic dynamics model}stochastic dynamics  in~\eqref{eq:SSM1} defines the \index{Markov kernel}Markov kernel $\Prob( \cdot \,|v_j, \theta) \coloneqq \Nc \bigl(\Psi_\vartheta(v_j),\Sigma\bigr)$  and the 
data model\index{data model} in~\eqref{eq:SSM1} defines the likelihood function for the observations
$\Prob( \cdot \,|v_{j+1},\theta) \coloneqq \Nc \bigl(h_\uupsilon(v_{j+1}),\Gamma\bigr)$. Our goal is to find $\theta$ so that the \index{Markov kernel}Markov kernel approximates that of an unknown, true, \index{stochastic dynamics model}stochastic dynamics model, and the likelihood approximates the true data-generating process, given together in the form
\begin{align}\label{eq:idealizedmodel}  
   \vd_{j+1} &= \Psi (\vd_j) + \xi_j,  &&\xi_j \sim \Nc(0, \Sigma^\dagger), \quad\quad  0 \le j \le J-1,\\
   \yd_{j+1} &= h (\vd_{j+1}) + \eta_{j+1}  &&\eta_j \sim \Nc(0, \Gamma^\dagger).
\end{align}
Once $\theta$ is found, the \index{signal}signal $\{\vd_j\}$ can be estimated leveraging the \index{filtering}filtering and \index{smoothing}smoothing algorithms in Chapter~\ref{lecture7} of these notes using the models in~\eqref{eq:SSM1}. 


For a given and fixed integer $J,$ we define, following the notation in Chapter \ref{lecture7},
\begin{equation*}
\Vd := \{\vd_0, \ldots, \vd_J\}, \quad \quad  \Yd := \{\yd_1, \ldots, \yd_J\}.
\end{equation*}
Note that $\Vd \in \R^{\du(J+1)}$ and $\Yd \in \R^{\dy J}$. 
In contrast to the \index{supervised learning}supervised learning setting in Chapter~\ref{ch:SL}, here we do not assume to have direct data $\bigl\{ v^{(n)}, \Psi(v^{(n)}) \bigr\}_{n=1}^N$ to learn the map $\Psi.$ Instead, we assume to have only access to data $\Yd$ obtained from indirect and noisy measurement of a trajectory $\Vd$ from the signal. 

\begin{dataassumption}
\label{da:8}
The data available is $\Yd := \{\yd_1, \ldots, \yd_J\}$ a single draw from the marginal $\marg$
on the observed data.
\end{dataassumption}




Before presenting algorithms to recover the parameter $\theta$, 
we consider three motivating examples for the parameter $\vartheta,$ of the parameterized map $\Psi_\vartheta,$ and of the relationship between the map $\Psi_\vartheta$ and the ground-truth deterministic map $\Psi.$ 

\begin{example}[Parameterized Dynamics]
$\Psi = \Psi_{\vartheta^\dagger}$ is parameterized, but the true parameter $\vartheta^\dagger$ is unknown and needs to be estimated. For instance, $\Psi$ may be defined by the time-discretization of a parameterized system of differential equations and we may be interested in estimating $\vartheta^\dagger$ from \index{observation}observations $\Yd.$
\end{example}

\begin{example}[Fully Unknown Dynamics]
There are settings in which $\Psi$ is fully unknown and $\vartheta$ can represent the parameters of, for example, a \index{neural network}neural network, \index{random features} random features, 
or \index{Gaussian!process}Gaussian process surrogate model $\Psi_\vartheta$ for $\Psi;$ see Chapter~\ref{ch:SL} for background on these parameterizations of functions. The goal is to find an accurate surrogate model $\Psi_\vartheta$. Even if $\Psi$ is  known, a \index{surrogate!model}surrogate model, or \index{emulator}\emph{emulator}, may be cheaper to evaluate, enabling the use of large sample sizes for particle filters or ensemble Kalman methods; see Chapter~\ref{ch:da_learned}. Similar computational considerations motivate learning the forward map for inverse problems in Chapter \ref{ch:fsm}. 
\end{example}

\begin{example}[Model Correction]
$\Psi$ is unknown, but we have access to an inaccurate model $\Psi^{a} \approx \Psi$. Here $\vartheta$ can represent, for example, the parameters of a \index{neural network}neural network, \index{random features}random features, or \index{Gaussian!process}Gaussian process $\Psi^{\text{correction}}_\vartheta$ used to correct the inaccurate model $\Psi^{a}$. The goal is to learn $\vartheta$ so that $\Psi_\vartheta \triangleq \Psi^{a} + \Psi^{\text{correction}}_\vartheta$ approximates $\Psi$ accurately. Learning model corrections is important in applications where available models have moderate predictive accuracy.  
For instance, fine scales of the \index{state}state may not be resolved accurately due to computational constraints and we may be interested in learning a surrogate model from data which accounts for the unresolved scales of the system.  
\end{example}

\section{Expectation Maximization} \label{sec:EMmodel_dynamics}
In contrast to the \index{supervised learning}supervised learning setting in Chapter~\ref{ch:SL}, here we do not assume to have direct data $\bigl\{ v^{(n)}, \Psi(v^{(n)}) \bigr\}_{n=1}^N$ to learn the map $\Psi.$ Instead, we assume to have only access to data $\Yd$ obtained from indirect and noisy measurement of a 
signal trajectory $V$: see Data Assumption \ref{da:8}.
To address the learning problem we view it as a \emph{missing data}\index{missing data} problem
in which ideally we estimate $\theta$ from $V$; but the data $V$ is missing and we must first
estimate it from $\Yd.$ To frame this idea we adopt a \index{maximum likelihood estimation}\emph{maximum likelihood} approach to estimate $\theta.$ That is, we seek to find $\theta$ that maximizes the marginal \index{likelihood}likelihood of $\theta$ given the observed data $\Yd$
\begin{equation} \label{eq:int_likelihood_filtering}
\Prob(\Yd | \theta) = \int \Prob (\Yd, V|\theta) \, dV = \int \Prob (\Yd | V, \theta) \Prob (V | \theta) \, dV.
\end{equation}
The likelihood in the last equation marginalizes over a distribution $\Prob(V |\theta)$ for the unknown states $V$; 
here and throughout 
this chapter integrals are over $\R^{\du(J+1)}$ unless otherwise noted. Evaluating the \index{likelihood}likelihood function $\Prob(\Yd | \theta)$ is challenging due to the unobserved, or  \index{latent}\emph{latent}, variable $V$, which depends on the unknown parameters $\theta$. 

\begin{remark} Likelihood functions that are computationally expensive to evaluate, such as the integral in~\eqref{eq:int_likelihood_filtering}, motivated the introduction of likelihood-free methods for Bayesian inference in Chapter~\ref{ch:data-dependence}. In this chapter, we will focus on optimization algorithms, rather than Bayesian methods, to find point estimators for the parameter $\theta$.
\end{remark}

Since the likelihood in~\eqref{eq:int_likelihood_filtering} involves an expectation over a distribution depending on the unknown parameters, it is natural to consider an iterative process for finding the \index{maximum likelihood estimation}maximum likelihood estimator of $\theta$. One widely-adopted iterative procedure is the \emph{expectation-maximization}\index{expectation!maximization} (EM) algorithm, which alternates between an expectation, (E) step, related to obtaining a lower bound for the integral
\eqref{eq:int_likelihood_filtering}, and a maximization (M) step, related to updating
the parameter estimate by maximizing the lower bound.

Theorem \ref{th:EMlikecharacterization} and the non-negativity of the KL divergence imply that, for any distribution $q(V)$ for the unknown state $V,$ it holds that 
$$\log \Prob(\Yd|\theta) \geq \mathcal{L}(q,\theta):=\int \log \left(\frac{\Prob(\Yd,V|\theta)}{q(V)}\right) q(V) \, dV.$$
Given the current iterate $\theta^\ell$ of the algorithm, in the E step we choose $q^\ell(V) \coloneqq \Prob(V|\Yd,\theta^\ell)$ to obtain a lower bound $\mathcal{L}(q^\ell,\theta)$ for $\log \Prob(\Yd|\theta).$ It follows from  Theorem \ref{th:EMlikecharacterization} that the choice $q^\ell(V) = \Prob(V|\Yd,\theta^\ell)$ solves the optimization problem 
$$q^{\ell} \in \arg \max_q \mathcal{L}(q, \theta^\ell).$$
Theorem \ref{th:EMlikecharacterization} further implies that, at $\theta = \theta^\ell,$ equality is achieved: $\log \Prob(\Yd|\theta^\ell) = \mathcal{L}(q^\ell,\theta^\ell).$ 
The lower bound $\mathcal{L}(q^\ell,\theta)$ is practical to compute because the expectation is with respect to a known  distribution for the unknown state variables, and the joint
distribution $\Prob(\Yd,V|\theta)$ is tractable from the parameterized stochastic dynamics and observation models; see~\eqref{eq:joint} below. We refer the reader to Section \ref{sec:142} for more background on the EM algorithm.

The M-step defines the updated parameters $\theta^{\ell+1}$ by maximizing the lower bound $\mathcal{L}(q^\ell,\theta)$ with respect to $\theta$. That is,
$$\theta^{\ell+1} \in \argmax_\theta \mathcal{L}(q^\ell,\theta) = \argmax_\theta \mathbb{E}^{V \sim q^\ell} \bigl[\log \Prob(\Yd,V|\theta)\bigr].$$

From the dynamics and observation models in~\eqref{eq:SSM1}, 
the joint  distribution of $V$ and $\Yd$ admits the characterization
\begin{align}\label{eq:joint}
\begin{split}
\log  \Prob(\Yd,V| \theta)  =& \log\Prob (\Yd|V,\theta)  + \log \Prob (V|\theta) \\
=& -\frac12 \log\det (\Gamma) -\frac{1}{2} \displaystyle{\sum_{j=0}^{J-1}} \bigl|y_{j+1} - h_\uupsilon( v_{j+1}) \bigr|_{\Gamma}^2\\
 &-\frac{1}{2}|v_0-m_0|^2_{C_0} - \frac{1}{2}\log\det(\Sigma) - \frac{1}{2} \sum_{j=0}^{J-1} \bigl|v_{j+1} - \Psi_\vartheta(v_j)\bigr|^2_{\Sigma} + c,
\end{split}
\end{align}
where $c$ is a constant independent of $V,$ $\Yd$ and $\theta.$ We recall that the E-step integrates the log-likelihood in~\eqref{eq:joint} with respect to $q^\ell(V)=\Prob(V|\Yd,\theta^\ell)$. The updated parameters in the M-step can then be computed by defining and maximizing the loss function 
\begin{align}\label{eq:Erisk}
\loss(\theta;q^\ell) &= -\frac12 \log \det(\Gamma)  - \frac{1}{2} \int  \sum_{j=0}^{J-1} \bigl|y_{j+1} - h_\uupsilon( v_{j+1})\bigr|^2_{\Gamma} q^\ell(V) \, dV \\
&\quad -\frac12 \log \det(\Sigma)  - \frac{1}{2} \int  \sum_{j=0}^{J-1} \bigl|v_{j+1} - \Psi_\vartheta(v_j) \bigr|^2_{\Sigma} q^\ell(V) \, dV, \nonumber \\ 
\theta^{\ell+1} &\in \argmax_\theta \loss(\theta;q^\ell). \label{eq:Mstep_risk}
\end{align}

To illustrate the application of the \index{expectation maximization}EM algorithm, the next subsections introduce practical algorithmic frameworks to define empirical loss functions and update the parameters. Subsection~\ref{sec:LearningCov} focuses on estimating the dynamics and observation model error covariances. The following two subsections focus on estimating the parameters in the \index{dynamics}dynamics model assuming the observation model is known; Subsection~\ref{sec:EM_graddescent} uses a particle approximation of $\Prob(V|\Yd,\theta^\ell)$ in~\eqref{eq:Erisk}, 
while Subsection~\ref{sec:143} uses Gaussian approximations for $\Prob(V|\Yd,\theta^\ell)$  that are derived from an extended (or ensemble) Kalman method.

\subsection{Learning Observation and Model Error Covariances} \label{sec:LearningCov}

In this subsection we consider the setting where the dynamics operator $\Psi$ and observation operator $h$ are known, but the dynamics and observation error covariances are unknown. That is, we seek the unknown parameters $\theta = \{\Gamma,\Sigma\}$. 
In this setting, we notice that the loss function~\eqref{eq:Erisk} in the M-step
is separable as the sum of two loss functions that each depend on only one parameter $\Gamma$ or $\Sigma$.
Furthermore, both of the two loss functions depending on $\Gamma$ and $\Sigma$ respectively have the same form as the objective in Proposition~\ref{prof:VI_Gaussians} for an unknown covariance in a Gaussian variational inference problem. Thus, the loss can be explicitly maximized over $\Gamma,\Sigma$. Setting $\theta^\ell = \{\Gamma_\ell,\Sigma_\ell\}$,
and using the explicit optimizer, we find the covariance matrix updates 
\begin{subequations}
\label{eq:CovUpdatesEM}
\begin{align} 
\Gamma^{\ell+1} &= \int \sum_{j=0}^{J-1} \Big( y_{j+1} - h(v_{j+1}) \Big) \otimes \Big( y_j - h(v_{j+1}) \Big) \, q^\ell(V) \, dV, \\
\Sigma^{\ell+1} &= \int \sum_{j=0}^{J-1} \Big( v_{j+1} - \Psi(v_{j}) \Big) \otimes \Big( v_{j+1} - \Psi(v_{j}) \Big) \, q^\ell(V) \, dV.
\end{align}
\end{subequations}

The following result shows that this update for the parameters $\Gamma,\Sigma$ leads to a monotonic increase of the log-likelihood for the observed variables $\Yd$.

\begin{theorem} The iterates \eqref{eq:CovUpdatesEM} of the EM algorithm for 
$\{\Gamma,\Sigma\}$ satisfy 
$$\log \Prob(\Yd|\theta^{\ell+1}) \ge \log\Prob(\Yd|\theta^\ell).$$
\end{theorem}

\begin{proof} The loss function $\loss(\theta;q^\ell)$ in the M-step is convex in $\theta$ and so $\theta^{\ell+1} = \{\Gamma^{\ell+1},\Sigma^{\ell+1}\}$ are the unique global optimum parameters, i.e., $\theta^{\ell+1} \in \argmax_\theta \loss(\theta;q^\ell)$. 
From Theorem~\ref{th:EMmonotone}, the iterates of the EM algorithm with the exact optimal parameters in the M-step satisfies the monotonic increase in the log-likelihood.
\end{proof}

\begin{remark}
The monotonic increase of the log likelihood in the population setting does not guarantee that the EM iterations converge. Additional assumptions are required to show that there is a strict improvement in the log-likelihood at each iteration and to provide a condition where the parameters reach a local critical point.
Furthermore, in practice, we will have samples from an empirical approximation of $\Prob(V|\Yd,\theta^\ell)$ and so we may update the covariances using Monte Carlo approximations of the covariance matrices in~\eqref{eq:CovUpdatesEM}. The added randomness from Monte Carlo approximation introduces a potentially
different approximation of $\Prob(V|\Yd,\theta^\ell)$ in each of the E-steps;
consequently, the monotonic increase in the log-likelihood is no longer guaranteed.
\end{remark}

\subsection{Monte Carlo EM} \label{sec:EM_graddescent}

In this subsection we consider a more general setting of learning both the dynamics model and forecast error covariance. We will focus on estimating parameters in the dynamics model assuming the observation model is known. That is, the unknown parameters correspond to $\theta = \{\vartheta, \Sigma\}$. Given (approximate) samples $\{v^{(n)}\}_{n=1}^N$ from $q^\ell(V) = \Prob(V|\Yd, \theta^\ell),$ we may use \index{Monte Carlo}Monte Carlo to approximate the expectation in the loss function as 
\begin{equation}\label{eq:Eempiricalrisk}
\loss(\theta;q^\ell) \approx c + -\frac12 \log \det(\Sigma)  -  \frac{1}{2N} \sum_{n=1}^N \sum_{j=0}^{J-1} \bigl|v_{j+1}^{(n)} - \Psi_\vartheta(v_j^{(n)}) \bigr|^2_{\Sigma},
\end{equation}
where $c$ accounts for the first two terms in~\eqref{eq:Erisk}, which are constant with respect to the unknown parameters $\theta$ as defined in this subsection. As in the last subsection, we notice that, given $\vartheta,$ the expression~\eqref{eq:Eempiricalrisk} can be explicitly maximized over $\Sigma.$ Indeed, the optimal solution is given by the covariance matrix 
$$\Sigma^{\ell+1} = \frac{1}{N} \sum_{n=1}^N \sum_{j=0}^{J-1} \Big( v_{j+1}^{(n)} - \Psi_{\vartheta} \bigl(v_{j}^{(n)}\bigr) \Big) \otimes \Big( v_{j+1}^{(n)} - \Psi_{\vartheta}\bigl(v_{j}^{(n)}\bigr) \Big).$$
We note that this covariance depends on the parameters $\vartheta$ via
the model $\Psi_{\vartheta}.$ To maximize the loss $\loss(\theta;q^\ell)$ over $\theta=\{\vartheta,\Sigma\}$, we can employ iterative \index{optimization}optimization methods: alternate optimization over $\Sigma$,
for fixed $\vartheta$, as given in the preceding block, with optimization
over $\vartheta$. Algorithm~\ref{alg:EM2} summarizes a resulting \index{expectation maximization}EM type algorithm, for learning \index{dynamics}dynamics and \index{state}states, using \index{Monte Carlo}Monte Carlo and \index{gradient ascent}gradient ascent updates. We notice that this implementation of the EM framework treats differently the parameters $\vartheta$ and $\Sigma$ in the M-step to account for the closed-form update for $\Sigma^{\ell + 1}$.

\begin{algorithm}
\caption{\label{alg:EM2} \index{expectation maximization}Expectation-Maximization with \index{Monte Carlo}Monte Carlo and \index{gradient ascent}Gradient Ascent}
\begin{algorithmic}[1]
\STATE {\bf Input}:  Initialization $\theta^0 = \{\vartheta^0, \Sigma^0\}.$ Rule for \index{gradient ascent}gradient ascent step-sizes $\{\alpha^i\}_{i = 1}^\mathcal{I}$.
\STATE For $\ell = 0, 1, \ldots, L-1$ do the following expectation and maximization steps:
\STATE {\bf E-Step}: Obtain (approximate) samples  $\{V^{(n)}\}_{n=1}^N$ from $\Prob(V|\Yd, \theta^\ell)$ and use these samples to approximate $\loss(\theta; q^\ell)$ as in \eqref{eq:Eempiricalrisk}.
\STATE{{{\bf M-Step}}}: 
\STATE Set $$\Sigma^{\ell+1}(\vartheta) = \frac{1}{2N} \sum_{n=1}^N \sum_{j=0}^{J-1} \Big( v_{j+1}^{(n)} - \Psi_{\vartheta}(v_{j}^{(n)}) \Big) \otimes \Big( v_j^{(n)} - \Psi_{\vartheta}(v_{j}^{(n)}) \Big)$$
and define
$$\J \bigl(\vartheta, \{V^{(n)}\}_{n=1}^N \bigr) \triangleq -\frac{1}{2N} \sum_{n=1}^N  \sum_{j=0}^{J-1} \Bigl|v_{j+1}^{(n)} - \Psi_\vartheta(v_j^{(n)})\Bigr|^2_{\Sigma^{\ell +1}(\vartheta)}.$$
\STATE Initialize $\vartheta^{\ell,0}=\vartheta^\ell.$
\FOR{$i=0,\dots,\mathcal{I}-1$}
\STATE $\vartheta^{\ell,i+1} = \vartheta^{\ell,i} + \alpha^i \nabla_{\vartheta} \J(\vartheta^{\ell,i}, \{V^{(n)}\}_{n=1}^N).$ 
\ENDFOR
\STATE Set $\vartheta^{\ell+1} = \vartheta^{\ell,\mathcal{I}}$.
\STATE{\bf Output}: Approximation $\theta^L$ to the \index{maximum likelihood estimation}maximum likelihood estimator.
\end{algorithmic}
\end{algorithm}

The distribution $\Prob(V|\Yd,\theta^\ell)$ for the \index{signal}signal $\{v_j\}$ can be estimated by performing \index{data assimilation}data assimilation using the \index{stochastic dynamics model}stochastic dynamics and \index{data model}data models in~\eqref{eq:SSM1} with learned parameter $\vartheta^\ell$ and covariance model $\Sigma^\ell.$ These samples may be obtained, for instance, using Markov chain Monte Carlo methods. 
Alternately, the ensemble Kalman methods described in Chapter~\ref{lecture7} may be employed, with the proviso that they can yield accurate posterior samples only in approximately \index{linear-Gaussian setting}linear-Gaussian settings.

\begin{remark}
In analogy to the supervised learning task studied in Chapter \ref{ch:SL}, equation \eqref{eq:Erisk} may be conceptually interpreted as defining a risk for the parameter $\theta,$ where the distribution $\Prob(V|\Yd,\theta^\ell)$ represents our available knowledge of the latent variable $V$ given data $\Yd$ and parameter estimate $\theta^\ell.$ 
Then, \eqref{eq:Eempiricalrisk} can be interpreted as an empirical risk, defined via approximate samples $V^{(n)} \sim \Prob(V|\Yd, \theta^\ell).$ 
\end{remark}

\begin{remark} While we present Algorithm~\ref{alg:EM2} using gradient ascent, in practice we may employ other optimization methods such as accelerated first-order methods or second-order methods, like Gauss-Newton to optimize the parameter $\vartheta$; we refer to Chapter~\ref{ch:optimization} for more details. The choice of algorithm may depend on computational constraints and properties of the loss function, such as its smoothness.
\end{remark}

\section{Auto-Differentiable Kalman Filters}
\label{sec:143}


As in the previous section we focus on estimating parameters in the dynamics model assuming that the observation model is known, so that
the unknown parameters correspond to $\theta = \{\vartheta, \Sigma\}$. 
Unlike the previous subsection, here we assume that the observation
operator is linear so that $h(v)=Hv.$ for some matrix $H \in \R^{\dy \times \du}$.
We again work under Data Assumption \ref{da:8}.

In Section \ref{sec:exkf}  we studied extended \index{Kalman filter!extended}Kalman filtering (ExKF) algorithms that make a \index{Gaussian!approximation}Gaussian approximation to the prediction\index{prediction}
and analysis\index{analysis} distributions. Specifically
\begin{equation}\label{eq:Gaussianpred}
\Prob (v_{j+1}| \Yd_j, \theta) \approx \Nc \bigl(\widehat{m}_{j+1}(\theta),\widehat{C}_{j+1}(\theta) \bigr)
\end{equation}
for the predictive distribution; and
\begin{equation}
\Prob (v_{j+1}| \Yd_{j+1}, \theta) \approx \Nc \bigl( m_{j+1}(\theta), C_{j+1}(\theta)\bigr)
\end{equation}
for the  analysis distribution. These ExKF-based \index{Gaussian!approximation}Gaussian approximations are accurate if the noise in the \index{dynamics}dynamics and the \index{observation!noise} observations are small, or the map $\Psi_\vartheta$ is approximately linear; see Remark \ref{rem:cycled2}. They may also be used to justify similar Gaussian approximations computed from the ensemble \index{Kalman filter!ensemble}Kalman filter; in particular the ensemble means and covariance provide Gaussian
ansatzs for the predictive and analysis distributions. However, we concentrate
here on the ExKF.

In this section we show how the \index{Gaussian!ansatz}Gaussian ansatz \eqref{eq:Gaussianpred} can be leveraged to produce a ExKF-based approximation of the \index{likelihood}log-likelihood function $\log \Prob(\Yd|\theta)$ and thereby an algorithm for \index{maximum likelihood estimation}maximum likelihood estimation of parameters $\theta$ in the stochastic dynamics model. It is 
intrinsic to the methodology presented that the observation operator
is linear. When combined with the Gaussian ansatz\index{Gaussian!ansatz}
this enables exact integration over the state, in order to find
the marginal distribution on $\Yd$ given $\theta.$ The derivation rests on the following characterization of the \index{likelihood}log-likelihood function under a \index{Gaussian!ansatz}Gaussian ansatz.

\begin{theorem}
Assume that the observation
operator is linear: $h(\cdot)=H \cdot.$
Suppose that, for each $0 \le j \le J-1,$ the predictive distribution $\Prob (v_{j+1}| \Yd_j, \theta)$ of the stochastic dynamics and data models \eqref{eq:SSM1} is \index{Gaussian}Gaussian with mean $\widehat{m}_{j+1}(\theta)$ and covariance $\widehat{C}_{j+1}(\theta).$ Then the \index{likelihood}log-likelihood function admits the following characterization 
\begin{equation}\label{eq:kalmanlikelihood}
\log \Prob (\Yd | \theta) = - \frac12 \sum_{j = 0 }^{J-1} \bigl|y_{j+1} - H\widehat{m}_{j+1}(\theta)\bigr|_{S_{j+1}(\theta)}^2 - \frac12 \sum_{j=0}^{J-1} \log \det \bigl(S_{j+1}(\theta)\bigr),
\end{equation}
where $S_{j+1}(\theta) = H \widehat{C}_{j+1}(\theta) H^\top + \Gamma.$
\end{theorem}
\begin{proof}
We have  
\begin{align*}
\log \Prob(\Yd|\theta) &= \sum_{j=0}^{J-1} \log  \Prob(y_{j+1}|\Yd_{j},\theta),
\end{align*}
where we use the convention that  $\Yd_0 := \emptyset$ 
so that conditioning to $\Yd_0$ does not provide any information. 
Now conditioning in the \index{data model}data model
$$y_{j+1}  = H v_{j+1} + \eta_{j+1},$$
we see that
\begin{align*}
\Expect \bigl[y_{j+1} |\Yd_j,\theta \bigr] &= \Expect \bigl[H v_{j+1} + \eta_{j+1} |\Yd_j,\theta\bigr] = H \widehat{m}_{j+1}(\theta), \\
\text{Cov}\bigl[y_{j+1} | \Yd_j,\theta \bigr] & = \text{Cov} \bigl[ H v_{j+1} + \eta_{j+1}|\Yd_j,\theta \bigr] = H \widehat{C}_{j+1}(\theta) H^\top + \Gamma.
\end{align*}
Moreover, $\Prob(y_{j+1} |\Yd_j,\theta)$ is \index{Gaussian}Gaussian. The result follows. 
\end{proof}

Thus, for any value of $\theta$, we may obtain an \emph{approximation} of the log-likelihood $\log \Prob(\Yd | \theta)$ by running a Kalman filtering algorithm, obtaining predictive means and covariances $\bigl(\widehat{m}_{j+1}(\theta),\widehat{C}_{j+1}(\theta)\bigr),$ for $0 \le j \le J-1$, and using \eqref{eq:kalmanlikelihood}. Moreover, an approximation of the log-likelihood gradient at $\theta$ can be obtained auto-differentiating through our Kalman-based likelihood estimate. Auto-differentiable Kalman filters use these estimates of the log-likelihood gradients to conduct gradient ascent. The procedure is summarized in Algorithm \ref{alg:autodiff}, for which we define
\begin{equation}
\label{eq:thisJ}
    \J(\theta) \coloneqq -\frac12 \sum_{j = 0 }^{J-1} \bigl|y_{j+1} - H\widehat{m}_{j+1}(\theta) \bigr|_{S_{j+1}(\theta)}^2 - \frac12 \sum_{j=0}^{J-1} \log \det \bigl(S_{j+1}(\theta)\bigr).
\end{equation}


\begin{algorithm}
\caption{\label{alg:autodiff} Auto-Differentiable Kalman Filter}
\begin{algorithmic}[1]
\STATE {\bf Input}:  Initialization $\theta^0,$ rule to choose step-sizes $\{\alpha^\ell\}_{\ell = 0}^{L-1}.$
\STATE For $\ell = 0, 1, \ldots, L-1$ do the following Kalman \index{filtering}filtering and \index{gradient ascent}gradient ascent steps:
\STATE {\bf Kalman Filtering}: Run an extended (or ensemble) Kalman \index{filtering}filtering algorithm to obtain predictive means and covariances $\widehat{m}_{j+1}(\theta^\ell),\widehat{C}_{j+1}(\theta^\ell),$ for $0 \le j \le J-1.$ 
\STATE {\bf \index{gradient ascent}Gradient Ascent:} \index{auto-differentiation}Auto-differentiate the map $\theta \mapsto \J(\theta)$ defined
in \eqref{eq:thisJ} to obtain a gradient estimate $\nabla \J(\theta^\ell).$  Set 
	\begin{align}
	\theta^{\ell + 1} = \theta^\ell + \alpha^\ell \nabla \J(\theta^\ell).
	\end{align}
\STATE{\bf Output}: Approximation $\theta^L$ to the \index{maximum likelihood estimation}maximum likelihood estimator. 
\end{algorithmic}
\end{algorithm}
\FloatBarrier

\begin{remark}
    If desired, the \index{signal}signal $\{v_j\}$ can be estimated by performing \index{data assimilation}data assimilation with \index{stochastic dynamics model}the stochastic dynamics and \index{data model}data models  \eqref{eq:SSM1} with learned parameter $\theta^L.$
\end{remark}

\begin{remark}
Notice that in the EM Algorithm \ref{alg:EM2} each posterior sample $\{V^{(n)} \}_{n=1}^N$ is used to perform $\mathcal{I}$ gradient descent steps in the M-Step, with the goal of maximizing the lower bound $\mathcal{L}(q^\ell, \theta).$  In contrast, in the auto-differentiable Kalman filter Algorithm \ref{alg:autodiff}, each run of a Kalman filtering algorithm is used to produce an estimate of the log-likelihood gradient, and a gradient ascent step is taken. 
This is possible because we can analytically integrate out the state variable,
given a linear observation operator and Gaussian predictive distribution.
\end{remark}

\section{Correcting Model Error Using Analysis Increments}\label{sec:analysis_increments}

We again work under Data Assumption \ref{da:8}. However we now use the learned
trajectories $\{v_j^{(n)}\}_{j=0}^{J-1}$ obtained from an ensemble method to create
surrogate supervised learning problems.

Here we consider the problem of learning parameters $\theta = \{\vartheta\}$ in a correction term to the systematic component of
the stochastic dynamics model (\ref{eq:SSM1}a). To this end we assume that
\begin{equation}
\label{eq:pcorr}    
\Psi_\vartheta = \Psi^{a} + \Psi_\vartheta^{\text{correction}}.
\end{equation}
Thus, $\Psi^{a}$ is a known approximation to the
systematic component of the stochastic dynamics model; 
we wish to use data to find a parameterized
correction $\Psi_\vartheta^{\text{correction}}.$

For simplicity we assume the covariance for the dynamical model error is known and we will work in the Monte Carlo setting of Subsection~\ref{sec:EM_graddescent}.
In this case, the loss function in~\eqref{eq:Erisk} has the form 
\begin{equation} \label{eq:lossParameterCorrection}
\loss(\theta;q^\ell) = c - \frac{1}{2N}\sum_{n=1}^N\sum_{j=0}^{J-1} \bigl|v_{j+1}^{(n)} - \Psi^{a}(v_j^{(n)}) - \Psi_{\vartheta}^{\text{correction}}(v_j^{(n)}) \bigr|_\Sigma^2,
\end{equation}
where $c$ is a constant that is independent of the parameters to be estimated. 
We recognize that minimizing~\eqref{eq:lossParameterCorrection} over $\theta$ corresponds to the supervised learning problem of estimating the mapping from $v_{j}$ to the increments $v_{j+1} - \Psi^{a}(v_j)$ given (approximate) analysis samples $V^{(n)}$. 

\begin{remark}
The Monte Carlo samples, indexed by $n$,
of the time-series $\{v_j^{(n)}\}_{j=0}^{J-1}$, may have been created without the model error correction, i.e., assuming $\Psi^{a}$ is the true dynamics model, in which case the loss in
\eqref{eq:lossParameterCorrection} is simply $\loss(\theta)$. Or they
may have been created from the corrected model for a setting  $\vartheta_\ell$ that was found in an earlier iteration of the EM algorithm. In the latter case, the maximization
of $\loss(\cdot;q^\ell)$ yields $\theta^{\ell +1}.$
\end{remark}

\section{Discussion and Bibliography}\label{sec:144}

In this chapter we have introduced two computational frameworks for joint state and parameter estimation: the EM algorithm and \index{Kalman filter!auto-differentiable}auto-differentiable filters. Both frameworks find the parameters in the \index{dynamics}dynamics by approximating the \index{maximum likelihood estimation}maximum likelihood estimator, and then use a \index{filtering}filtering or \index{smoothing}smoothing algorithm to recover the \index{state}state. This final section provides bibliographical context for the algorithms considered in this chapter, and briefly discusses other computational methods that do not stem from a \index{maximum likelihood estimation}maximum likelihood formulation.

Embedding of the \index{Kalman filter!ensemble}EnKF and the \index{Kalman smoother!ensemble}ensemble Kalman smoother (EnKS) into the \index{expectation maximization}EM algorithm was proposed in \cite{tandeo2015offline,ueno2014iterative, dreano2017estimating, pulido2018stochastic}, with a focus on estimation of error covariance matrices.  The E-step is approximated with an EnKS under the \index{Monte Carlo}Monte Carlo EM framework \cite{wei1990monte}. In addition, \cite{brajard2020combining,nguyen2019like,wikner_using_2021} incorporate machine learning techniques in the M-step to train \index{neural network}neural network surrogate models or corrections. The paper \cite{bocquet2020bayesian} proposes \index{Bayesian}Bayesian estimation of model error statistics, together with a \index{neural network}neural network emulator for the \index{dynamics}dynamics. On the other hand, \cite{ueno2016bayesian,tandeo_review_2020,cocucci2021model} consider online \index{expectation maximization}EM methods for error covariance estimation with \index{Kalman filter!ensemble}EnKF. Online methods aim to reduce computation by not reprocessing the smoothing distribution for each new observation. Although gradient information is used during the M-step to train the surrogate models in~\cite{brajard2020combining, nguyen2019like,bocquet2020bayesian}, these methods do not \index{auto-differentiation}auto-differentiate through the \index{Kalman filter!ensemble}EnKF. Other methods to learn observation and model error covariances are considered in \cite{mehra_identification_1970,berry_adaptive_2013,waller_theoretical_2016,menard_error_2016}.

Auto-differentiable Kalman filters were introduced in \cite{chen2021auto}, which proposes and analyzes an approach for joint \index{state}state and parameter estimation that leverages gradient information of an \index{Kalman filter!ensemble}EnKF estimate of the \index{likelihood}likelihood. The paper \cite{chen2023reduced} considers learning a latent low-dimensional surrogate model for the dynamics and a decoder that maps from the latent space to the state space using auto-differentiable Kalman filters. 
\index{Kalman filter!ensemble}EnKFs for derivative-free \index{maximum likelihood estimation}maximum likelihood estimation are studied in \cite{stroud2010ensemble,pulido2018stochastic}. An empirical comparison of the \index{likelihood}likelihood computed using the  \index{Kalman filter!ensemble}EnKF and other \index{filtering}filtering algorithms is made in \cite{carrassi2017estimating}; see also \cite{hannart2016dada,metref2019estimating}. The paper \cite{drovandi2021ensemble} uses \index{Kalman filter!ensemble}EnKF \index{likelihood}likelihood estimates to design a pseudo-marginal \index{MCMC}MCMC method  for \index{Bayesian!inference}Bayesian inference of model parameters. The works \cite{stroud2007sequential,stroud2018bayesian} propose online \index{Bayesian}Bayesian parameter estimation using the \index{likelihood}likelihood computed from the \index{Kalman filter!ensemble}EnKF under a certain family of conjugate distributions. 


While our discussion has focused on ensemble Kalman methods, \index{particle filter}particle filters can also be employed for joint \index{state}state and parameter estimation. \index{particle filter}Particle filters give an unbiased estimate of the data \index{likelihood}likelihood \cite{del2004feynman,andrieu2010particle}. Based upon this \index{likelihood}likelihood estimate, a particle \index{MCMC}MCMC \index{Bayesian}Bayesian parameter estimation method is designed in \cite{andrieu2010particle}. Although \index{particle filter}particle filter \index{likelihood}likelihood estimates are unbiased, they suffer from two potential drawbacks that limit their applicability to some problems. First, their variance can be large, as they inherit the weight degeneracy of \index{importance sampling}importance sampling in high dimensions \cite{snyder2008obstacles,agapiou2017importance,sanz2018importance,sanz2020bayesian}---see Chapter~\ref{lecture7} for further background on this subject. Second, while the forecast and analysis steps of \index{particle filter}particle filters can be \index{auto-differentiation}auto-differentiated, the \index{resampling}resampling steps involve discrete distributions that cannot be handled by the reparameterization trick, as discussed in \cite{chen2021auto}. For this reason, previous differentiable \index{particle filter}particle filters omit \index{auto-differentiation}auto-differentiation of the \index{resampling}resampling step \cite{naesseth2018variational,maddison2017filtering,le2017auto}, introducing a bias.

An alternative to \index{maximum likelihood estimation}maximum likelihood estimation is to optimize a lower bound of the data \index{likelihood}log-likelihood with \index{variational!Bayesian method}variational inference \cite{bishop,kingma2013auto,ranganath2014black}. The \index{posterior}posterior distribution over the \index{latent}latent \index{state}states is approximated with a parametric distribution and is jointly optimized with model parameters defining the \index{dynamics}dynamics model. In this direction, \index{variational!Bayesian method}variational sequential \index{Monte Carlo}Monte Carlo methods  \cite{naesseth2018variational,maddison2017filtering,le2017auto} construct the lower bound using a \index{particle filter}particle filter. Moreover, the proposal distribution of the \index{particle filter}particle filter is parameterized and jointly optimized with model parameters. 
Although \index{variational!Bayesian method}variational sequential \index{Monte Carlo}Monte Carlo methods provide consistent data \index{likelihood}log-likelihood estimates, they suffer from the same two potential drawbacks as \index{likelihood}likelihood-based \index{particle filter}particle filter methods. A recent work \cite{ishizone2020ensemble} proposes blending \index{variational!Bayesian method}variational sequential \index{Monte Carlo}Monte Carlo and \index{Kalman filter!ensemble}EnKF with an \index{importance sampling}importance sampling-type lower bound estimate, which is effective if the \index{state}state dimension is small. Other works that build on the \index{variational!Bayesian method}variational inference framework include \cite{krishnan2017structured,rangapuram2018deep,fraccaro2017disentangled, marino_general_2018}. An important challenge is to obtain suitable parameterizations of the \index{posterior}posterior, especially when the \index{state}state dimension is high. For this reason, a restrictive \index{Gaussian}Gaussian parameterization with a diagonal covariance matrix is often used in practice \cite{krishnan2017structured,fraccaro2017disentangled}. The topic of variational approximations to filtering and smoothing problems is discussed in Chapter~\ref{ch:LG}.

Another alternative approach to maximum likelihood estimation is to concatenate state and parameters into an augmented \index{state-space}state-space and employ the data assimilation methods, from other
chapters in this Part II, in the augmented state-space. This approach requires one to design a pseudo-dynamic for the parameters, which can be challenging when certain types of parameters (e.g., error covariance matrices) are involved \cite{stroud2007sequential,delsole2010state} or if the dimension of the parameters is high.
The use of \index{Kalman filter!ensemble}EnKF for joint learning of \index{state}state and model parameters by \index{state augmentation}\emph{state augmentation} was introduced in \cite{anderson2001ensemble}.

Beyond the problem of joint parameter and state estimation, the development of data-driven \index{machine learning} frameworks for learning \index{dynamical system}dynamical systems is a very active research area. We refer to \cite{levine_framework_2022} for a framework and to \cite{brunton2019data,gottwald2021supervised,gottwald_combining_2021,harlim2021machine,raissi2018multistep} for recent methods that do not rely on the \index{expectation maximization}EM algorithm, \index{auto-differentiation}auto-differentiation of \index{filtering}filtering methods, or \index{variational!Bayesian method}variational inference.

In addition, data-driven machine learning frameworks have gained popularity for combining physics-based models with model error corrections. These hybrid models may avoid avoid the over-smoothing or unphysical behavior of predictive models that replace the entire  forecast dynamics~\cite{bonavita2023limitations}. Two common representations for model error include  additive corrections~\cite{farchi2021using, bonavita2020machine} and data-driven subgrid scale parameterizations~\cite{rasp2018deep, bolton2019applications}; we refer to Section~\ref{sec:ME} for other forms of model error. We note that the approach discussed in this chapter learns the corrections offline, as online methods typically require the adjoint operator of the physics-based model, which may be challenging to obtain for some physics-based models, e.g., in numerical weather prediction and for climate modeling~\cite{lopez2022training}.

Model error correction using analysis increments was considered in \cite{danforth_estimating_2007,farchi2021using,chen_correcting_2022}. An alternative method for using ML to account for model error in data assimilation is to learn a mapping between the model attractor and the attractor of the true system \cite{agarwal_cross-attractor_2024}.

\chapter{\Large{\sffamily{Learning Parameterized Filters and Smoothers}}}
\label{ch:LG}

In this chapter we use learning to solve the filtering and smoothing problems introduced in Chapter \ref{lecture7}.
We consider both state estimation, finding a representative sequence of states
from the data and knowledge of the model, and  probabilistic estimation, approximating the posterior distributions for 
sequences of states given data. In Section~\ref{sec:analysis_variational} we will first introduce the variational formulation for smoothing and filtering problems, which enable variational inference approaches to solve these problems, in analogy to the procedures in Chapter~\ref{ch:VI} for inverse problems. Sections~\ref{sec:smoothers} and~\ref{sec:smootheruq} introduce practical instances of the variational formulation for recovering a smoothed point estimator of the time-varying state and an approximation to the smoothing distribution within a tractable family of distributions, respectively. We refer to the approaches in Sections ~\ref{sec:smoothers} and~\ref{sec:smootheruq} as state estimation and probabilistic estimation, respectively, to emphasize the computed uncertainty in the latter approach. Sections~\ref{sec:filters} and~\ref{sec:filteringuq} introduce analogous approaches of state estimation and probabilistic estimation for filtering, respectively. The learned approximations we consider in this chapter are built as generalizations of the classic filtering and smoothing algorithms presented in Chapter~\ref{lecture7}.

\section{Variational Formulations of Smoothing and Filtering}\label{sec:analysis_variational}

In this section we describe how to formulate the probabilistic approaches to both smoothing and filtering using the variational framework
introduced in Chapter \ref{ch:VI}. In particular, we seek the smoothing distribution as the solution 
to an optimization problem in Subsection~\ref{sec:variational_smoothing} and we show how to find the filtering distribution in Subsection~\ref{sec:variational_filtering}. In these subsections we propose variational inference approaches to 
derive tractable computational methods to solve the proposed variational smoothing and filtering problems.
We define the notation $V = \{v_0, \ldots, v_J\}$ and $V_j = \{v_0, \ldots, v_j \}$, and recall $\Yd = \{\yd_1,\dots,\yd_J \}$  and $\Yd_j := \{\yd_1, \ldots, \yd_j\}$ as in~\eqref{eq:VdYd}. 
Throughout most of this section we make the following assumption about data available for learning:

\begin{dataassumption}
\label{da:9a}
The data available is $\Yd := \{\yd_1, \ldots, \yd_J\}$ a single draw from the marginal $\marg$
on the observed data.
\end{dataassumption}

On one occasion we go beyond this setting, in this section, making Data Assumption \ref{da:9b}.
It is convenient to use the notation $\mathcal{P}^J:=\mathcal{P}(\R^{\du(J+1)}).$

\subsection{Variational Formulation of Smoothing}\index{variational!formulation of smoothing}
\label{sec:variational_smoothing}

The density for the smoothing distribution $\mathbb{P}(V | \Yd)$, following Section~\ref{sec:smoothing}, is then
\begin{align*}
    \Pi^{\Yd}(V) &\propto \like(\Yd|V)\rho(V),
\end{align*}
where the likelihood and the prior are given by
\begin{subequations}
\label{eq:sdef}
\begin{align}
    \like(\Yd|V) &= \prod_{j=1}^{J}\like_j(v_j),\\
    \like_j(v_j) &= Z_\Gamma^{-1}\exp\bigl(-\frac{1}{2} |\yd_{j} - h(v_{j})|^2_\Gamma\bigr),\quad Z_\Gamma = (2\pi)^{k/2} \det(\Gamma)^{1/2},\\
    \rho(V) &= \prod_{j=0}^J \rho_j(v_j),\\
    \rho_j(v_j) &= \begin{cases}
    Z_\Sigma^{-1}\exp\bigl(-\frac{1}{2}|v_{j} - \Psi(v_{j-1})|^2_\Sigma\bigr) & j\geq 1, \quad Z_\Sigma  = (2\pi)^{d/2} \det(\Sigma)^{1/2},\\
    Z_{C_0}^{-1}\exp\bigl(-\frac{1}{2}|v_0 - m_0|_{C_0}^2\bigr) & j=0, \quad Z_{C_0}  = (2\pi)^{d/2} \det(C_0)^{1/2}.
    \end{cases}
\end{align}
\end{subequations}

The following theorem shows that the smoothing density arises as the solution of a variational problem. This result is analogous to the variational formulation for the posterior in an inverse problem, that was presented in Theorem~\ref{t:VariationalForm_Bayes}.

\begin{theorem}
    Consider the likelihood $\like(\Yd|V)$ and prior $\rho(V)$ given in~\eqref{eq:sdef}, and let  
\begin{subequations}
\label{eq:var_smoothing}
\begin{align} 
\J(q) &= \dkl(q\|\rho) - \mathbb{E}^q \bigl[\log \like(\Yd|V) \bigr],\\
\qopt &\in \argmin_{q \in \cP^J} \J(q).
\end{align}
\end{subequations}
Then, the minimizer of $\J$ over $\mathcal{P}^J$ is the smoothing density, i.e., $\qopt=\Pi^{\Yd}.$
\end{theorem}
\begin{proof}
This follows directly from the variational formulation of Bayes Theorem \ref{t:VariationalForm_Bayes}. 
\end{proof}

This formulation of the smoothing problem can be used as the basis for algorithms to learn approximations for the smoothing distribution from data.

\subsection{Variational Formulation of Filtering}\index{variational!formulation of filtering}
\label{sec:variational_filtering}

The goal in this subsection is to find variational formulations of the filtering problem that are useful 
as the basis of algorithms to learn from data. We present two different variational formulations of filtering: one that involves a variational inference problem at every analysis time, and one that begins from the above variational formulation of the smoothing problem and imposes the temporal structure of filtering on it.

\subsubsection{Variational Inference at Each Assimilation Step}

Recall the prediction ($\Pred$) and analysis ($\An(\cdot;\yd_{j+1})$) maps
that define filtering \eqref{eq:pna}. The analysis step \eqref{eq:filter_bayes_inference} is an application of Bayes Theorem \ref{t:bayes} with likelihood $\mathbb{P}(y^\dagger_{j+1} | v_{j+1})$ and prior $\widehat{\post}_{j+1} = \mathbb{P}(v_{j+1}|\Yd_j)$ found by application of $\Pred$ given by \eqref{eq:pred_operator} to $\post_j.$ Thus, the analysis density $\post_{j+1}$ can be written as the solution to an optimization problem using the variational formulation of Bayes Theorem \ref{t:VariationalForm_Bayes}:
\begin{subequations}
\label{eq:var_filtering}
\begin{align}
\J_{j+1}(q) &= \dkl(q\|\widehat{\post}_{j+1}) - \mathbb{E}^{v_{j+1}\sim q} \bigl[\log \mathbb{P}(y^\dagger_{j+1} | v_{j+1}) \bigr],\\
\post_{j+1} &\in \argmin_{q \in \mathcal{P}} \J(q),
\end{align}
\end{subequations}
where $\mathcal{P}:= \mathcal{P} (\R^d).$
The above assumes that we have access to the true prior $\widehat{\post}_{j+1}$. We now consider densities $q'_j$ recursively defined by the prediction--analysis cycle
\begin{subequations}\label{eq:online}
    \begin{align}
    q'_0 &= \post_0,\\
    \J_{j+1}(q) &= \dkl(q\|\Pred q'_j) - \mathbb{E}^{v_{j+1}\sim q} \bigl[\log \mathbb{P}(\yd_{j+1} | v_{j+1}) \bigr],\label{eq:online_cost}\\
    q'_{j+1} &\in \argmin_{q\in\mathcal{P}} \J_{j+1}(q).\label{eq:theta_star2}
\end{align}
\end{subequations}
Then, $q'_{j+1}$ equals the filtering distribution $\mathbb{P}(v_{j+1}|\Yd_{j+1})$. Performing the minimization \eqref{eq:theta_star2} over a restricted class of probability densities, potentially defined
differently at each step $j$, leads to a sequence of approximate filtering densities $\{q'_{j}\}_{j \ge 0}.$

\subsubsection{Imposing Filtering Structure on Smoothing}

Alternatively, one can start from smoothing and then impose a temporal structure on the resulting density. In filtering, the probability distribution for state $v_j$ at time $j$ only depends on past observations $\Yd_j$, as defined in \eqref{eq:VdYd}, and not future observations.
In order to approximate a filtering distribution it is natural to seek minimizers of $\J(\cdot)$
defined by (\ref{eq:var_smoothing}a) which factorize in the form
\begin{equation}\label{eq:filter_density_factorized}
    q(V) = \prod_{j=1}^J \qf_j(v_j|V_{j-1};\Yd_j)\mathfrak{q}_0(v_0).
\end{equation}
For later use we also define 
\begin{equation}\label{eq:factb}
    q_j(V_j) = \prod_{i=1}^j \qf_i(v_i|V_{i-1};\Yd_i)\mathfrak{q}_0(v_0).
\end{equation}

We let $\cC^J \subset \cP^J$ denote probability density functions of the form \eqref{eq:filter_density_factorized}.
(The use of $\cC$ is to invoke the conditional, auto-regressive
structure.) Ideally we  would like to minimize the loss function
$\J(\cdot)$ defined in (\ref{eq:var_smoothing}a) over $\cC^J.$
However there is no mechanism in loss function (\ref{eq:var_smoothing}a) to impose the
specific data dependence inherent in $\cC^J$, namely that $q_j$ depends only on $\Yd_j$, within
the context of minimizing $\J(\cdot);$
this is because only one instance of the data $\Yd$ is available. We now describe two possible
ways of circumventing this issue. The first involves minimization of a sequence of objective functions $\J_j(\cdot)$ each of which only sees $\Yd_j.$ The second involves use of an objective function $\J(\cdot)$ defined over multiple realizations of $\Yd.$

\paragraph{Multiple Objective Functions}

The methodology suggested here is based on the following theorem, which employs the notation
\eqref{eq:filter_density_factorized} \eqref{eq:factb} and in which
it is important to note the distinction between $\qf_j$ and $q_j$:

\begin{theorem}\label{theorem:filter_factorized}
For $q \in \cC^J$ satisfying the factorized structure \eqref{eq:filter_density_factorized}, the objective  function \eqref{eq:var_smoothing} can be written as
    \begin{subequations}
    \label{eq:seqf}                                                                                                                                                                                               \begin{align}
           \J_j(\qf_j) &= \dkl\Bigl(\qf_j(v_j|V_{j-1}; \Yd_j)\|\rho_j(v_j)\Bigr) - \mathbb{E}^{v_j\sim \qf_j} \bigl[\log \like_j(v_j) \bigr],\\
        \J(q) &= \sum_{j=1}^J\mathbb{E}^{V_{j-1}\sim q_{j-1}} \bigl[ \J_j(\qf_j)\bigr].
    \end{align}
    \end{subequations}
   \end{theorem}
\begin{proof}
We will use the $\ELBO$ introduced in Definition \ref{d:elbo} and the relationship between $\ELBO,$ KL divergence, and likelihood established in Theorem \ref{th:EMlikecharacterization}. 
    We start by noting that 
    \begin{equation*}
        \dkl(q \| \Pi^{\Yd}) = \log \mathbb{P}(\Yd) - \ELBO(\mathbb{P}(V, \Yd), q).
    \end{equation*}
    Since the first term does not depend on $q$, we focus on the second term, given by
    \begin{equation*}
        \ELBO(\mathbb{P}(V, \Yd), q) = \mathbb{E}^{V\sim q}\left[\log\frac{\mathbb{P}(V, \Yd)}{q(V)}\right].
    \end{equation*}
    The joint density $\mathbb{P}(V, \Yd)$ can be factorized autoregressively as
    \begin{equation*}
        \mathbb{P}(V, \Yd) = \prod_{j=1}^J \mathbb{P}(\yd_j | \Yd_{j-1}, V_j) \mathbb{P}(v_j | \Yd_{j-1}, V_{j-1}).
    \end{equation*}
    Using this, as well as the factorized structure \eqref{eq:filter_density_factorized} of $q$, we obtain
    \begin{align*}
        \ELBO(\mathbb{P}(V, \Yd), q) &= \mathbb{E}^q\left[\log\left(\prod_{j=1}^J\frac{\mathbb{P}(\yd_j | \Yd_{j-1}, V_j) \mathbb{P}(v_j | \Yd_{j-1}, V_{j-1})}{\qf_j(v_j|V_{j-1};\Yd_j)}\right)\right]\\
        &= \sum_{j=1}^J\mathbb{E}^q\left[\log\left(\frac{\mathbb{P}(\yd_j | \Yd_{j-1}, V_j) \mathbb{P}(v_j | \Yd_{j-1}, V_{j-1})}{\qf_j(v_j|V_{j-1};\Yd_j)}\right)\right].
    \end{align*}
    Since each term is only conditioned on variables up to time $j$, we can simplify to
    \begin{align*}
        \ELBO(\mathbb{P}(V, \Yd), q) &= \sum_{j=1}^J\mathbb{E}^{q_j}\left[\log\left(\frac{\mathbb{P}(\yd_j | \Yd_{j-1}, V_j) \mathbb{P}(v_j | \Yd_{j-1}, V_{j-1})}{\qf_j(v_j|V_{j-1};\Yd_j)}\right)\right]\\
        & \hspace{-1cm}= \sum_{j=1}^J\mathbb{E}^{q_{j-1}}\mathbb{E}^{\qf_j}\left[\log\left(\frac{\mathbb{P}(\yd_j | \Yd_{j-1}, V_j) \mathbb{P}(v_j | \Yd_{j-1}, V_{j-1})}{\qf_j(v_j|V_{j-1};\Yd_j)}\right)\right]\\
        &  \hspace{-1cm} = -\sum_{j=1}^J\mathbb{E}^{V_{j-1}\sim q_{j-1}} \left[\dkl\Bigl(\qf_j(v_j|V_{j-1}; \Yd_j)\|\rho_j(v_j)\Bigr) - \mathbb{E}^{v_j\sim \qf_j} \bigl[\log \like_j(v_j) \bigr]\right],
    \end{align*}
    where the last line follows from noticing that $\mathbb{P}(\yd_j | \Yd_{j-1}, V_j) = \mathbb{P}(\yd_j | v_j) = \I_j$ is the observation likelihood at time $j$, and $\mathbb{P}(v_j | \Yd_{j-1}, V_{j-1}) = \mathbb{P}(v_j | v_{j-1}) = \rho_j(v_j)$ is the prior for time $j$. Then, minimizing $\dkl(q\|\Pi^{\Yd})$ is equivalent to minimizing $\J(q)$ given in \eqref{eq:seqf}.
\end{proof}

This is an interesting result, but direct minimization of $\J(\cdot)$ as in (\ref{eq:seqf}b) will not
lead to a minimizer in class $\cC^J.$ This is because minimization will lead to dependence on the entire
$\Yd$ in each of the conditionals $\qf_j(v_j|V_{j-1}; \Yd)$; there is no mechanism to ensure
dependence in the form $\qf_j(v_j|V_{j-1}; \Yd_j).$ However, given a single realization
of the data $\Yd$ it is reasonable to proceed as follows to enforce this dependence: instead of minimizing  $\J(\cdot)$ from (\ref{eq:seqf}b),  we may instead sequentially minimize $\J_j(\cdot)$ 
from (\ref{eq:seqf}a), over index $j=1, \dots, J.$ Thus
\begin{subequations}
    \begin{align}
        \qfs_j &\in \argmin_{\qf \in \cP(\R^d)} \J_j(\qf),\\
        \qfs(V) &= \prod_{j=1}^J \qfs_j(v_j|V_{j-1};\Yd_j)\qfs_0(v_0).
    \end{align}
\end{subequations}
Note that each $\J_j$ depends only on $\Yd_j$ hence enforcing the desired dependence on each conditional
$\qfs_j(v_j|V_{j-1}; \Yd_j).$

\paragraph{Multiple Data Sequences}
\begin{dataassumption}
\label{da:9b}
The data available is $\{(\Yd)^{(n)}\}_{n=1}^N$ which are multiple independent
realizations from the marginal $\marg$
on the observed data $\Yd := \{\yd_1, \ldots, \yd_J\}$. 
\end{dataassumption}

Assuming that we have access to the distribution $\marg$ on $\Yd$ implied by the stochastic dynamics 
model \eqref{eq:sdm}, \eqref{eq:dm}, we may consider the following optimization problem: 
\label{eq:var_filteringa}
\begin{align*} 
\J(q) &= \mathbb{E}^{\Yd}\Bigl[\dkl(q\|\rho) - \mathbb{E}^q \bigl[\log \like(\Yd|V) \bigr]\Bigr],\\
\qopt &\in \argmin_{q \in \cC^J} \J(q).
\end{align*}
In practice, expectation over $\Yd$ is approximated empirically using Data Assumption \ref{da:9b}.
Recall that the idea of averaging over
multiple data instances was also used in Section \ref{sec:carGB}.

\section{Smoothing: State Estimation}\label{sec:smoothers}
Recall the 4DVar approach to the smoothing problem defined in Section \ref{sec:4dvar}. 
It finds an estimate of the state $\Vs := \{\vs_0, \ldots, \vs_J\}$
from the observed data $\Yd := \{\yd_1, \ldots, \yd_J\}.$
Emphasizing the dependence of $\Vs$ on the available data $\Yd$ we have
\begin{align}
\label{eq:NobjS}
\Vs(\Yd) & \in \argmin_{V \in \R^{\du(J+1)}} \J(V;\Yd),\\
\J(V;\Yd)&  =\reg(V)+\loss(V;\Yd),
\end{align}
where $\reg(V)$ and $\loss(V;\Yd)$ are defined in \eqref{eq:regS} and \eqref{eq:lossSA}. Of course $\Vs(\Yd)$ is simply the MAP estimator
\index{MAP estimator} defined by the Bayesian smoothing problem 
from Section \ref{sec:smoothing}.

In the following we assume that we have multiple solutions of the 4DVar MAP estimator
for multiple realizations of the data $\Yd.$ We use the same notational conventions as in
the preceding section.

\begin{dataassumption}
    \label{d:9c}
The data available is $\{(\Yd)^{(n)}\}_{n=1}^N$ which are multiple independent
realizations from the marginal $\marg$
on the observed data $\Yd := \{\yd_1, \ldots, \yd_J\}$ .
And, for each $n$, we have $(\Vs)^{(n)}=\Vs\bigl((\Yd)^{(n)}\bigr).$
\end{dataassumption}


We employ distance-like deterministic scoring rules $\D$\index{scoring rule!distance-like deterministic}; see Definition \ref{def:det_score} from Subsection \ref{ssec:dldsc}.
Given the data $\bigl\{(\Yd)^{(n)},(\Vs)^{(n)}\bigr\}_{n=1}^N$ from Data Assumption \ref{d:9c} 
we may apply the methodology of Section \ref{sec:MAPd} to
learn the mapping from $\Yd$ to $\Vs.$ Indeed we find $\Vs(\Yd) \approx
\V(\Yd;\thetas)$ where $\thetas$ solves an empirical approximation of the minimization problem
\begin{subequations}
\label{eq:MAPL2}
\begin{align} 
\J(\theta) &= \bbE^{\Yd \sim \marg}  \Bigl[ \D\bigl(\V(\Yd;\theta),\Vs(\Yd)\bigr) \Bigr],\\
\thetas &\in \argmin_{\theta \in \Theta} \J(\theta).
\end{align}
\end{subequations}


\begin{remark}
\label{rem:edopaper} It is also possible to circumvent the use of 4DVar and directly generate
data pairs $\bigl\{(\Yd)^{(n)},(\Vd)^{(n)}\bigr\}_{n=1}^N \sim \gamma$, where $\gamma$ denotes
the joint distribution on signal and data defined by \eqref{eq:sdm}, \eqref{eq:dm}, \eqref{eq:VdYd}. 
It is then possible to solve an empirical approximation of
\begin{subequations}
\label{eq:MAPL22}
\begin{align} 
\J(\theta) &= \bbE^{(\Yd, \Vd) \sim \gamma} \Bigl[ \D\bigl(\V(\Yd;\theta),\Vd\bigr) \Bigr],\\
\thetas &\in \argmin_{\theta \in \Theta} \J(\theta).
\end{align}
\end{subequations}
\end{remark}




\section{Smoothing: Probabilistic Estimation}\label{sec:smootheruq}

 In this section we discuss how the smoothing distribution
may be learned.

\subsection{Smoothing: Gaussian Approximate Probabilistic Estimation}
\label{ssec:4DVARgoesGaussian}


We may apply the ideas of Chapter \ref{ch:VI} to the smoothing problem, working under
Data Assumption \ref{da:9a}. We introduce a
parametric family of probability density functions $\cQ \subset \cP^J$ and minimize the
objective function from (\ref{eq:var_smoothing}a) over $\cQ$ instead of $\cP^J:$
\begin{subequations}
\label{eq:var_smoothinga}
\begin{align} 
\J(q) &= \dkl(q\|\rho) - \mathbb{E}^q \bigl[\log \like(\Yd|V) \bigr],\\
\qs &\in \argmin_{q \in \cQ} \J(q).
\end{align}
\end{subequations}


    Recall the 4DVar\index{4DVar} solution \eqref{eq:4DVarasMAP} which is the MAP estimator for the smoothing problem,
    as introduced in Section \ref{sec:4dvar}. Precompute this solution of an optimization problem, and call it $\Vs$. Now let
    $$\cQ=\Bigl\{q \in \cP^J: q=\cN(\Vs,\Sigmas),\, \Sigmas \in \R^{d(J+1) \times d(J+1)}_{\textrm{sym},>}\Bigr\}.$$
    We thus seek to optimize over parameter $\Sigmas.$ In practice we may wish to (Cholesky) 
    square-root factorize $\Sigmas$, as in Example \ref{ex:cholGVI}, to impose symmetry.

\subsection{Smoothing: Amortized Gaussian Approximate Probabilistic Estimation}
    \label{ssec:4DVARgoesGaussian2}
We may also be interested in learning a parametric model to capture dependence of an approximate smoothing distribution on the data $\Yd$. To this end, in this subsection we work under 
 working under Data Assumption \ref{da:9b}. We generalize the previous subsection and  choose
to minimize over $\mathcal{S}_\theta: \R^{Jk} \to \cQ \subset \cP^J,$ parameterized by $\theta \in \Theta \subseteq \R^p:$
\begin{subequations}
\label{eq:var_smoothingb}
\begin{align} 
\J(q) &= \mathbb{E}^{\Yd} \Bigl[\dkl(q\|\rho) - \mathbb{E}^q \bigl[\log \like(\Yd|V) \bigr] \Bigr],\\
\thetas &\in \argmin_{\theta \in \Theta} \J\bigl(\mathcal{S}_\theta(\Yd)\bigr).
\end{align}
\end{subequations}
Then, for given unseen data $\Yd$, we choose our approximate smoothing distribution 
$\qs=\mathcal{S}_{\thetas}(\Yd).$
    Consider Subsection \ref{ssec:4DVARgoesGaussian} but now assume that
    the mean of the Gaussian is computed (approximately) as  function $\Vs(\Yd)$ mapping observations to the 4DVar solution, as in Section \ref{sec:smoothers};
    and in the context of uncertainty quantification now allow the covariance $\Sigmas$ to be a function of $\Yd$ parameterized by $\theta \in \Theta.$ Thus $\Sigmas=\Sigmas(\Yd;\theta).$ See Example \ref{rem:VIy}.

\section{Filtering: State Estimation}\label{sec:filters}

Recall the dynamics/data model \eqref{eq:sdm} and \eqref{eq:dm}, repeated here for convenience:
\begin{subequations}
    \label{eq:ddm99}
\begin{align}
\vd_{j+1} &= \Psi(\vd_j) + \xid_j, \: j \in \Z^+,\\
\yd_{j+1} &= h(\vd_{j+1}) + \etad_{j+1} , \: j \in \Z^+.
\end{align}
\end{subequations}
Our interest in this section is in learning filtering algorithms for this
problem; we make the following data assumption:

\begin{dataassumption}
\label{da:9d}
We have access to data set $\{\vd_{j+1}, \yd_{j+1}\}_{j \in \{0, \ldots,J-1\}}$ 
generated as a realization of \eqref{eq:ddm99}.   
\end{dataassumption}

 We will study learning problems found
as generalization of three specific algorithms from Chapter \ref{lecture7},
namely 3DVar, the EnKF and the optimal particle filter. 
We use the class of 
distance-like deterministic scoring 
rules\index{scoring rule!distance-like deterministic} 
from Definition \ref{def:det_score}. Using a choice of such a rule $\D(\cdot,\cdot)$
we define an objective function from which to find parameters $\theta$ specifying a filtering algorithm. 

\begin{example}
The canonical example of a distance-like deterministic scoring 
rule\index{scoring rule!distance-like deterministic}  
is $\D(v,w)=|v-w|^2$, the squared Euclidean distance.
\end{example}

\subsection{3DVar}

\subsubsection{General $\Psi$ and $h$}
Now recall the 3DVar algorithm \eqref{eq:pred3DVAR}, also repeated here for convenience:
\begin{subequations}
 \label{eq:pred3DVAR2}   
\begin{align}
\hat{v}_{j+1} &= \Psi(v_j),\\
v_{j+1} &= \hat{v}_{j+1} + K \bigl(\yd_{j+1}-h(\hat{v}_{j+1})\bigr).	
\end{align}
\end{subequations}
For the dynamics/data model and for 3DVar, we make the same Gaussian and independence 
assumptions on the initialization and noise as made in equations \eqref{eq:sdm}, 
\eqref{eq:dm} and Assumption \ref{a:fas}. In particular we assume that $\vd_0$ and $v_0$
are drawn from the same distribution $\cN(m_0,C_0)$, but independently. 
To fully specify the 3DVar algorithm we need to choose matrix $K$. We investigate learning $\theta := K$ on the basis of data. (We note that, alternatively, $K$ could be parameterized as $K = K(\theta)$, and parameter $\theta$ could be learned.) We emphasize the dependence of the output of 3DVar on unknown parameter $\theta$
by writing $v_j(\theta).$ 
We apply a scoring rule $\D(\cdot, \cdot)$ satisfying Definition~\ref{def:det_score} to measure the distance between $\vd_j$ and $v_j$, and estimate a $\theta^\star$ that minimizes the score averaged over the time series:
\begin{subequations}\label{eq:state_estimation_obj}
    \begin{align}
        \J^J(\theta) &= \frac{1}{J}\sum_{j=1}^{J} \D(v_j(\theta), \vd_j),\\
        \theta^\star&\in \argmin_\theta \J^J(\theta).
    \end{align}
\end{subequations}
Note that $v_j(\theta)$ depends on the observed data $\{\yd_{i}\}_{i \in \{1,\ldots,j\}}$ and
so we are indeed using the entirety of the data specified in Data Assumption \ref{da:9d}.
The minimization \eqref{eq:state_estimation_obj} may be performed using auto-differentiation with respect to $\theta$\index{auto-differentiation}; see Section \ref{sec:auto-differentiation} for details on this methodology.

\begin{remark}
In defining the previous learning frameworks we have started from the population loss, defined as expectation
over a measure with Lebesgue density, and then noted that in practice we approximate this empirically.
Here, because the population loss is more complicated to write down, we work the other way around: we
have started with empirical loss \eqref{eq:state_estimation_obj} and now proceed to derive a population
loss. To this end let us view \eqref{eq:ddm99}, \eqref{eq:pred3DVAR2} as a coupled stochastic dynamical system for
    $(\vd_j,\yd_j,v_j)$ and assume it is ergodic with invariant measure $\gamma(d\vd,d\yd,dv;\theta);$ note, in particular that this measure depends on $\theta$. Furthermore, note that the measure factorizes naturally as $\gamma(d\vd,d\yd,dv;\theta)=\pi(dv|\yd;\theta)\like(d\yd|\vd)\mu(d\vd).$ 
    We may then view $\J^J(\cdot)$ as approximation of the population-level loss $\J(\cdot)$
    found, by ergodicity, in the limit $J \to \infty:$
    \begin{equation*}
        \J(\theta)=\int \D(v, \vd) \pi(dv|\yd;\theta)\like(d\yd|\vd) \, \mu(d\vd).
    \end{equation*}
\end{remark}

\subsubsection{Linear $\Psi$ and $h$}

We show that for linear dynamics and observations, taking $\D$ to be the trace of the covariance matrix leads to a gain which converges to the steady-state Kalman gain as $J\to\infty$.
Consider the 3DVar algorithm \eqref{eq:pred3DVAR2} with $\Psi(\cdot) = A\cdot$ and $h(\cdot) = H\cdot$. Then $v_j$ obeys the recursion
\begin{subequations}\label{eq:kalman_fixed_mean}
    \begin{align}
        v_{j+1} &= (I - KH)\hat{v}_{j+1} + K \yd_{j+1},\\
        \hat{v}_{j+1} &= A v_j.
    \end{align}
\end{subequations}
Define the error covariances $C_j = \mathbb{E}\bigl[(\vd_j - v_j)\otimes(\vd_j - v_j)\bigr]$ and $\hat{C}_j = \mathbb{E}\bigl[(\vd_j - \hat{v}_j)\otimes(\vd_j - \hat{v}_j) \bigr]$ which, note, are not the covariances of the filtering distribution. These covariances obey the recursions
    \begin{subequations}\label{eq:kalman_fixed_cov}
        \begin{align}
            C_{j+1} &= (I - KH)\hat{C}_j(I-KH)^\top + K\Gamma K^\top,\\
            \hat{C}_{j + 1} &= A C_{j} A^\top + \Sigma.
        \end{align}
    \end{subequations}
    The recursion for $\hat{C}_j$ holds because
    \begin{align*}
        \hat{C}_{j + 1} &= \mathbb{E}   \Bigl[\bigl(\vd_{j+1} - \hat{v}_{j+1}\bigr)\otimes \bigl(\vd_{j+1} - \hat{v}_{j+1}\bigr)\Bigr]\\
        &= \mathbb{E}\Bigl[\bigl(A\vd_{j} + \xi_j - A{v}_{j} \bigr)\otimes \bigl(A\vd_{j} + \xi_j - A{v}_{j}\bigr) \Bigr]\\
        &= \mathbb{E}\Bigl[\bigl(A(\vd_{j} - {v}_{j})\bigr)\otimes \bigl(A(\vd_{j} - {v}_{j})\bigr)\Bigr] + \Sigma\\
        &= AC_jA^\top + \Sigma.
    \end{align*}
    The recursion for ${C}_j$ holds because
    \begin{align*}
        C_{j+1} &= \mathbb{E} \Bigl[\bigl(\vd_{j+1} - v_{j+1}\bigr)\otimes \bigl(\vd_{j+1} - v_{j+1}\bigr)\Bigr]\\
        &= \mathbb{E}\Bigl[\bigl(\vd_{j+1} - (I - KH)\hat{v}_{j+1} - KH\vd_{j+1} - K\eta_{j+1}\bigr)\\
        &\qquad\otimes \bigl(\vd_{j+1} - (I - KH)\hat{v}_{j+1} - KH\vd_{j+1} - K\eta_{j+1}\bigr)\Bigr]\\
        &= \mathbb{E}\Bigl[(I - KH)(\vd_{j+1} - \hat{v}_{j+1})\otimes(I - KH)(\vd_{j+1} - \hat{v}_{j+1})\Bigr] + K\Gamma K^\top\\
        &= (I - KH)\hat{C}_j(I-KH)^\top + K\Gamma K^\top.
    \end{align*}

    We consider learning $K$ by minimizing 
    \begin{equation}\label{eq:cost_function_trace}
        \J^J(K) = \lim_{J\to\infty}\frac{1}{J+1}\sum_{j=0}^{J}\Tr(C_j).
    \end{equation}
    
    In the following theorem, we show that the minimizer of $\J^J(K)$ converges to the steady-state Kalman gain as $J\to\infty$. 
\begin{theorem}
    Take the 3DVar algorithm \eqref{eq:pred3DVAR2} with $\Psi(\cdot) = A\cdot$ and $h(\cdot) = H\cdot$. Suppose that the analysis covariance $C_j$ of the Kalman filter converge as $j \to \infty$ to the steady state in \eqref{eq:ss_kalman2}. Then, $K^\star \in \argmin_K \J^J(K)$, where $\J^J(K)$ is given by \eqref{eq:cost_function_trace}, converges to the steady-state Kalman gain $K_\infty$\index{Kalman filter!steady state} \eqref{eq:ss_kalman_gain} as $J\to\infty$.
\end{theorem}
\begin{proof}
    We begin by noting that \eqref{eq:kalman_fixed_mean} and \eqref{eq:kalman_fixed_cov} also hold for a time-varying gain $K_j$:
    \begin{subequations}\label{eq:kalman_rec}
        \begin{align}
            v_{j+1} &= (I - K_{j}H)A v_j + K_{j} \yd_{j+1},\\
            C_{j+1} &= (I - K_j H)\hat{C}_j(I-K_jH)^\top + K_j\Gamma K_j^\top,\label{eq:analysis_cov}\\
            \hat{C}_{j + 1} &= A C_{j} A^\top + \Sigma.
        \end{align}
    \end{subequations}
    It is readily shown that the $K_j$ that minimizes $C_{j+1}$ given $\hat{C}_j$ (with respect to the order of positive definite matrices) is the Kalman gain $K_j^\star = \hat{C}_{j} H^\top \bigl(H \hat{C}_{j} H^\top + \Gamma\bigr)^{-1}$. This can be seen by setting $K'_j = K_j^\star + \Delta K$, where $\Delta K$ is an arbitrary matrix, and showing that $(I - K_j' H)\hat{C}_j(I-K_j'H)^\top + K_j'\Gamma K_j'^\top \geq (I - K_j^\star H)\hat{C}_j(I-K_j^\star H)^\top + K_j^\star \Gamma {K_j^\star}^\top$.

    We now introduce the notation $C_j^\star$ to indicate the matrix given by the recursion \eqref{eq:kalman_rec} when the Kalman gain is used. We write $C_j(K)$ for the solution to the recursion when the gain is fixed at some $K_j = K$ for all $j$.

    It can be seen by induction that $C_j(K) - C_j^\star \geq 0$ for all $j$. Since $\Tr(\cdot)$ is monotonically increasing with respect to the order of positive definite matrices, we have that
    \begin{align*}
        \Tr(C_j^\star) \leq \Tr \bigl(C_j(K)\bigr)
    \end{align*}
    for any fixed $K$ and all $j$.
    
    Taking the limit $j\to\infty$, we have that for all $K$
    \begin{align*}
        \lim_{j\to\infty}\Tr(C_j^\star) = \Tr\bigl(C_\infty(K_\infty)\bigr) &\leq \lim_{j\to\infty} \Tr\bigl(C_j(K)\bigr),
    \end{align*}
    where we have used the convergence of the Kalman filter to its steady state. Thus, $\Tr\bigl(C_j(K)\bigr)$ is minimized at $K = K_\infty$, the steady-state Kalman gain.

    By the Stolz--Ces\`aro theorem (see bibliography), we have that
    \begin{equation*}
        \lim_{J\to\infty}\frac{1}{J+1}\sum_{j=0}^{J}\Tr(C_j^\star) =  \lim_{J\to\infty}\frac{1}{J+1}\sum_{j=0}^{J}\Tr\bigl(C_\infty(K_\infty)\bigr) \leq \lim_{J\to\infty}\frac{1}{J+1}\sum_{j=0}^{J}\Tr\bigl(C_j(K)\bigr)
    \end{equation*}
    for all $K$.
\end{proof}

\subsection{EnKF Gain}\label{sec:enkf_gain_learning}
Although the ensemble Kalman method was designed as
a Monte Carlo method, it is often used as a state estimator
and the ensemble is used to estimate uncertainty in the
state estimates. This is the perspective we adopt here. We continue to work under
Data Assumption \ref{da:9d}
and recall the EnKF algorithm \eqref{eq:predEnKF}\index{Kalman filter!ensemble}. Rather than calculating $K_{j+1}$ from empirical covariances as in \eqref{eq:gainEnKF}, we instead try and learn dependence on the ensemble. To this end we modify \eqref{eq:predEnKF} to read
\begin{subequations}
\label{eq:predEnKF2}
\begin{align}
\widehat{v}_{j+1}^{(\sam)} &= \Psi(v_{j}^{(\sam)})+\xi^{(\sam)}_{j}, \quad \sam=1,\ldots,\Sam, \\
v_{j+1}^{(\sam)} &= \widehat{v}_{j+1}^{(\sam)}+K_{j+1}\bigl(\yd_{j+1}-\eta_{j+1}^{(\sam)}-h(\widehat{v}_{j+1}^{(\sam)})\bigr),\quad \sam=1,\ldots,\Sam,\\
K_{j+1}&=\Ks\bigl(\widehat{v}_{j+1}^{(1)},\ldots,\widehat{v}_{j+1}^{(N)};\theta\bigr),
\end{align}
\end{subequations}
where $\xi_{j}^{(\sam)} \sim \Nc(0,\Sigma), \quad \eta_{j+1}^{(\sam)} \sim \Nc(0,\Gamma)$
are independent sequences of i.i.d. random vectors with respect to both $j$ and $n$, and
the two sequences themselves are independent of one another.
Here, in this setting, it may be desirable that $\Ks(\cdot;\theta)$ be invariant with respect to permutation of the ensemble.

The assumptions on the noise are as detailed after \eqref{eq:predEnKF}.
It is useful to define a state estimator by taking the mean of the ensemble at time $j$:
\begin{equation}
\label{eq:SE}   
\bar{v}_j=\frac{1}{N}\sum_{n=1}^N v_j^{(n)}.
\end{equation}


\begin{remark}
\label{rem:thetaform}
It may be of interest to replace (\ref{eq:predEnKF2}c)  by
$K_{j+1}=\Ks\bigl(\widehat{C}_{j+1}^{vh},\widehat{C}_{j+1}^{yy};\theta\bigr),$
where the covariance matrices are as defined in \eqref{eq:gainEnKF} and
$\Ks(\cdot;\theta)$ is a parameterized family of gain functions 
to be learned by optimizing over $\theta.$ For example
$\Ks(\cdot;\theta)$ may be parameterized as a neural network.
Recall from Remark \ref{rem:lh} that if $h$ is linear then the two covariances
$\widehat{C}_{j+1}^{vh},\widehat{C}_{j+1}^{yy}$ can be expressed in terms of 
$\widehat{C}_{j+1}^{vv}$ and $H$; thus in this case we might seek to learn the
gain in the form $\Ks\bigl(\widehat{C}_{j+1}^{vv}, H;\theta\bigr).$
Furthermore it may also be of interest to replace
(\ref{eq:predEnKF2}b,\ref{eq:predEnKF2}c) by an update of the form
\begin{align*}
v_{j+1}^{(\sam)} &=\ks\bigl(\widehat{v}_{j+1}^{(\sam)},\bar{w}_{j+1},i_{j+1}^{(\sam)},\widehat{C}_{j+1}^{vh},\widehat{C}_{j+1}^{yy},\widehat{C}_{j+1}^{vv};\theta\bigr), \quad \sam=1,\ldots,\Sam,\\
i_{j+1}^{(\sam)} & =\yd_{j+1}-\eta_{j+1}^{(\sam)}-h(\widehat{v}_{j+1}^{(\sam)}),
\end{align*}
where
$$\bar{w}_{j+1}=\frac{1}{N}\sum_{n=1}^N \widehat{v}_{j+1}^{(n)}$$
is the mean of the predicted ensemble. 
The reader will be able to suggest many variants on the preceding formulations of a learning problem for an EnKF-like data assimilation algorithm.
\end{remark}

Again, to emphasize dependence of the algorithm on parameters $\theta$ to be learned,
we write $v_j^{(n)}(\theta)$ and the state estimator
$\bar{v}_j(\theta).$ We then define $\theta$ by
\begin{subequations}\label{eq:state_estimation_obj2}
    \begin{align}
        \J^J(\theta) &= \frac{1}{J}\sum_{j=1}^{J} \D(\bar{v}_j(\theta), \vd_j).\\
        \theta^\star&\in \argmin_\theta \J^J(\theta).
    \end{align}
\end{subequations}
Here $\D(\cdot,\cdot)$ is again a
deterministic scoring  rule\index{scoring rule!distance-like deterministic} 
from Definition \ref{def:det_score}.

\begin{remark}
    Instead of minimizing the error of the ensemble mean $\overline{v}_j$ with respect to the true state $\vd_j$ using a deterministic scoring rule, one can also desire that the distribution of the ensemble be informative of the error with respect to the truth. For example, it is possible to ask that the ensemble spread match the expected error with respect to the truth (see Subsection \ref{ssec:ESR} for more discussion of this point). Considering the ensemble as an empirical measure, $\pi_{j+1} = \frac{1}{N}\sum_{n=1}^N \delta_{v_{j+1}^{(n)}}$, instead of the cost function \eqref{eq:state_estimation_obj2} one based on a probabilistic scoring rule (see Section \ref{sec:psr}) can be applied:
    \begin{equation*}
        \J^J(\theta) = \frac{1}{J}\sum_{j=1}^{J} \D(\pi_j(\theta), \vd_j).
    \end{equation*}
\end{remark}

\subsection{EnKF Localization and Inflation}

Inflation and localization, discussed in Subsections \ref{sec:inflation}\index{inflation} and \ref{sec:localization}\index{localization}, are essential for the performance of the EnKF, as discussed in Remark \ref{rem:enkf}. Learning can be used to determine appropriate parameters for these features of the EnKF.
Again we  continue to work under Data Assumption \ref{da:9d}.

Recall multiplicative inflation given by \eqref{eq:inflation},
\begin{equation*}
    \widehat{v}_{j+1}^{(\sam)} \to \widehat{m}_{j+1} + \alpha (\widehat{v}_{j+1}^{(\sam)} - \widehat{m}_{j+1}),
\end{equation*}
and covariance localization given by \eqref{eq:loc_cov}, \eqref{eq:loc},
\begin{align*}
    \widehat{C}_{j+1}&\to L \circ \widehat{C}_{j+1},\\
    (L)_{ik} &= e^{-D_{ik}^2/\ell}.
\end{align*}
The inflation parameter $\alpha$ and localization radius $\ell$ can be considered parameters $\theta = (\alpha, \ell)$, and then optimized as in Subsection \ref{sec:enkf_gain_learning}.

\begin{remark}
    Other ways of parameterizing localization could also be considered, such as taking $\theta = L$ and learning the entire matrix, or parameterizing $L(\theta)$ with a given structure different from the one given above. Alternatives to Schur product localization can also be considered, such as ones that learn a nonlinear map that localizes the gain,
\begin{equation*}
    K_j\to\mathsf{L}(K_j; \theta).
\end{equation*}
\end{remark}

\subsection{Optimal Particle Filter}
\label{ssec:opflf}
Here we work in the setting of linear observation operator, \eqref{eq:linearobs}, repeated
here for convenience:
\begin{align*}
\vd_{j=1} &= \Psi(\vd_j) + \xid_j , \\
\yd_{j+1} &= H\vd_{j+1} + \etad_{j+1}\,.
\end{align*}
We again make the same Gaussian and independence 
assumptions on the initialization and noise as 
are made in equations \eqref{eq:sdm}, 
\eqref{eq:dm} and Assumption \ref{a:fas}. 
Recall that the optimal particle filter, from Section \ref{sec:opf}, works by proposing
particles through an ensemble of equally weighted noisy 3DVars and then reweighting them:
see equation \eqref{eq:opf99}. Here, recognizing that reweighting often leads to particle
collapse (see Section \ref{sec:dabib}), we instead seek to learn a desirable combination 
of the ensemble of 3DVars:
\begin{subequations}
\label{eq:opf999}
\begin{align}
    \widehat{v}_{j+1}^{(n)} &= (I - KH)\Psi(v_j^{(n)}) + K\yd_{j+1} + \xi_{n+1}^{(n)}, \\
    v_{j+1}^{(\sam)} &= \widehat{v}_{j+1}^{(\sam)}+\ks\Bigl(\{\widehat{v}_{j+1}^{(n)}\}_{n=1}^N,\widehat{v}_{j+1}^{(\sam)},\yd_{j+1},i_{j+1}^{(\sam)};\theta\Bigr), \quad \sam=1,\ldots,\Sam,\\
i_{j+1}^{(\sam)} & =\yd_{j+1}-H\widehat{v}_{j+1}^{(\sam)}.
\end{align}
\end{subequations}
with $\xi_{j+1}^{(n)}$ i.i.d. in $j$ and $n$ and distributed according to $\mathcal{N}(0,C)$ and matrix $K$ as defined in \eqref{eq:covopt}.
Again it may be desirable that $\ks(\cdot,\widehat{v}_{j+1}^{(\sam)},\yd_{j+1},i_{j+1}^{(\sam)};\theta)$ 
is invariant with respect to permutation of the ensemble.

We continue to work under Data Assumption \ref{da:9d}. 
To emphasize dependence of the algorithm on parameters $\theta$ to be learned,
we again write $v_j^{(n)}(\theta)$ and the state estimator from \eqref{eq:SE} as
$\bar{v}_j(\theta).$ We then determine $\theta$ by \eqref{eq:state_estimation_obj2}.
As in the context of the EnKF, other forms of learning problem may be
postulated; see Remark \ref{rem:thetaform}.

\subsection{Spread--Error Relationship\index{spread--error ratio}}
\label{ssec:ESR}

In this subsection we discuss the connection between scoring rules and the \emph{spread--error ratio}, another distance-like function used to evaluate forecasts. Note that we have, in this section, trained methods as state
estimators, not to give probabilistic forecasts. Nonetheless it is possible
to ask, for the particle-based methods, what properties one might desire from the
whole ensemble as well as from its mean. One answer to this question 
is to consider the spread--error ratio. To this end we view ensemble members
$\{{v}_{j}^{(n)}\}_{n=1}^N$ as providing an approximate filtering distribution
$$\pi_{j}(\theta)=\frac{1}{N}\sum_{n=1}^N \delta_{{v}_{j}^{(n)}}.$$
To motivate the following definition,
read the statement of Theorem \ref{t:ser} which explains a key property of
filtering distributions which is a straightforward consequence of conditional
expectation. 

\begin{definition}
Consider a sequence of probabilistic forecasts $\{\pi_j\}_{j=1}^J.$
    The \emph{spread--error ratio}\index{spread--error ratio} of this
    sequence with respect to the true trajectory $\{\vd_j\}_{j=1}^J$ is the ratio
    \begin{equation*}
        r = \frac{\frac{1}{J}\sum_{j=1}^J\mathbb{E}^{v_j\sim \pi_j}\bigl[|v_j - \mathbb{E}^{v_j\sim \pi_j}[v_j]|^2 \bigr]}{\frac{1}{J}\sum_{j=1}^J \bigl|\vd_j-\mathbb{E}^{v_j\sim \pi_j}[v_j] \bigr|^2}.
    \end{equation*}
    If $r = 1$, we say that the forecasts $\{\pi_j\}_{j=1}^J$ have a \emph{perfect spread--error relationship}. If $r < 1$, we say that they are \emph{underdispersed}. If $r > 1$, we say that they are \emph{overdispersed}.\footnote{Note that a different ratio other than 1 can be used. The important point is that the spread should vary in proportion to the error.}
\end{definition}

For a given trajectory error, does minimizing a probabilistic scoring rule with respect to covariance recover a spread--error ratio of $1$?
We show that it does with the Dawid--Sebastiani score\index{Dawid--Sebastiani score} and the logarithmic scoring rule with a Gaussian forecast, but not in the case of the continuous ranked probability score (CRPS).\index{continuous ranked probability score}

\begin{theorem}\label{theorem:spread_error_dss}
For $1 \le j \le J,$ let $m_j = \Expect^{v_j \sim \pi_j} [v_j]$ and let 
    \begin{align*}
        e &= \frac{1}{J}\sum_{j=1}^J(m_j - \vd_j)^2.
    \end{align*}
    Then, in the scalar case, the variances $C_j = \Expect^{v_j \sim \pi_j} \bigl[ (v_j - m_j)^2  \bigr] $ that minimize the sum of the Dawid--Sebastiani scores, $\{C^\star_j\}_{j=1}^J$, are such that $\frac{1}{J}\sum_{j=1}^JC^\star_j = e$, thus having a spread--error ratio of 1.
\end{theorem}

\begin{proof}
    The sum of the Dawid--Sebastiani scores \eqref{eq:ds_score}\index{Dawid--Sebastiani score} over the trajectory is given in the scalar case by
    \begin{equation*}
        \sum_{j=1}^J\left[\frac{(\vd_j - m_j)^2}{C_j} + \log(C_j)\right].
    \end{equation*}
     Minimizing each term with respect to $C_j$, we find that $C^\star_j = (\vd_j - m_j)^2$. Thus, $\frac{1}{J}\sum_{j=1}^JC^\star_j = e$.
\end{proof}

\begin{remark}
    From the above proof, it is straightforward to see that this theorem is also true when the Dawid--Sebastiani score is replaced by the logarithmic scoring rule \eqref{eq:log_score}\index{logarithmic score}, but restricted to Gaussian $\pi_j$.
\end{remark}

\begin{proposition}
    Theorem \ref{theorem:spread_error_dss} is not true when the Dawid--Sebastiani rule is replaced with the CRPS \eqref{eq:CRPS}\index{continuous ranked probability score}, and thus, also the energy score\index{energy score}. Furthermore, the spread--error ratio of the optimal forecast is not constant when $|\mathbb{E}[v] - \vd|^2$ is varied.
\end{proposition}
\begin{proof}
    Proof by example. Set $J=1$, $\vd = 1$, and $m = 0$, so that $e = 1$. Then it can be found numerically that $\CRPS(\pi, \vd)$ is minimized when $C\approx 1.44$, so that $r\approx 1.44$. When $\vd = 2$ and $m = 0$, $e = 4$, and the CRPS is minimized at $C\approx 1.50$, so that $r\approx 0.38$.
\end{proof}

\subsection{Learning State Estimators in the Presence of Model Error}
\label{ssec:lme}

We consider the setting in which the model \eqref{eq:ddm99} is imperfect
and hence we seek to learn state estimation data assimilation algorithms only from data;
no access to the true state is assumed.  We thus employ:

\begin{dataassumption}
\label{da:9e}
We have access to data set $\{\yd_{j+1}\}_{j \in \{0,\ldots,J-1\}}$ generated from
a realization of \eqref{eq:ddm99}.   
\end{dataassumption}

We then use deterministic scoring rules\index{scoring rule!deterministic} 
from Definition \ref{def:det_score}, but applied in the observation space rather than in the state space.
Learning data assimilation algorithms,
as in the previous section, but based on an imperfect model trajectory, may not be optimal.
Instead we assume that the observation model \eqref{eq:dm} is perfect, but for a true data signal
which does not come from \eqref{eq:sdm}; thus we have access only to $\{\yd_{j+1}\}_{j \in \bbZ^+}.$ 
We do assume, however, that we know the function $h(\cdot)$ mapping from the unknown true state
to the data space. In this setting, focusing on 3DVar, we can consider the loss
\begin{equation}\label{eq:lossnewref}
    \J^J(\theta) = \frac{1}{J}\sum_{j=1}^{J} \D \Bigl(h(v_j(\theta), \yd_j\Bigr)
\end{equation}
instead of \eqref{eq:state_estimation_obj}.
Note that $\J^J(\theta)$ is then a proxy for the loss with respect to the true trajectory in the observation space:
\begin{equation}\label{eq:dist_true_traj_obs_space}
    \frac{1}{J}\sum_{j=1}^{J} \D\Bigl(h\bigl(v_j(\theta)\bigr), h(\vd_j)\Bigr).
\end{equation}
These ideas also enable us generalize to the loss function \eqref{eq:state_estimation_obj2}
to the setting of EnKF and the optimal particle filter.


\begin{example}\label{ex:optimism_euc}
The cost function $\J^J(\theta)$ in \eqref{eq:lossnewref} may be problematic; since $v_j$ is a function of $\yd_j$, it can be overfit to observations. For example, if $h$ is surjective, one can achieve a perfect score by simply setting $v_j = h^{-1}(\yd_j)$, where $h^{-1}$ is the right inverse of $h$.
We describe a method to avoid overfitting when using the squared Euclidean distance as the scoring rule. Similar analyses could be done for other scoring rules.

Take $\D(\cdot, \cdot)$ to be the squared Euclidean norm: $\D(v, w) = |v - w|^2$. We analyze a single time $j$.
Taking the expectation over the observation noise realization, $\eta^\dagger_j\sim\cN(0, \Gamma)$, we obtain:
\begin{align*}
    \mathbb{E}\Bigl[|\yd_j-h\bigl(v_j(\theta)\bigr)|^2\Bigr] = \mathbb{E}\Bigl[|h(\vd_j) - h(v_j)|^2\Bigr] + \Tr(\Gamma) - 2\mathbb{E}\Bigl[h\bigl(v_j(\theta)\bigr)^\top \eta^\dagger_j\Bigr].
\end{align*}
Note that $\mathbb{E}\Bigl[h(v_j)^\top \eta^\dagger_j\Bigr]$ will generally be positive, since the observation $\yd_j$ was used to produce the analysis $v_j$. The first term on the RHS is \eqref{eq:dist_true_traj_obs_space}, which is what we would like to estimate. Thus, $\mathbb{E}\Bigl[|\yd_j-h\bigl(v_j(\theta)\bigr)|^2\Bigr]$ will systematically underestimate $\mathbb{E}\Bigl[|h(\vd_j) - h(v_j)|^2\Bigr] + \Tr(\Gamma)$. The term $2\mathbb{E}\Bigl[h\bigl(v_j(\theta)\bigr)^\top \eta^\dagger_j\Bigr]$ is called the \emph{optimism}.\index{optimism}

$\mathbb{E}\Bigl[|\yd_j-h\bigl(v_j(\theta)\bigr)|^2\Bigr] + 2\mathbb{E}[h\bigl(v_j(\theta)\bigr)^\top \eta^\dagger_j]$ is thus a better proxy for out-of-sample performance, and should be minimized instead of only $\mathbb{E}\Bigl[|\yd_j-h\bigl(v_j(\theta)\bigr)|^2\Bigr]$.
\end{example}

\section{Filtering: Probabilistic Estimation}
\label{sec:filteringuq}

In this section we discuss how classes of algorithms
may be optimized to approximate probabilistic estimation
defined by the filtering distribution. We concentrate on particle-based methods.

Recall that the  time evolution of the filtering distribution can be defined
by interweaving prediction by the underling stochastic dynamics with Bayes
Theorem to incorporate the observations via the analysis step -- see 
Section~\ref{sec:filtering}. In particular \eqref{eq:pna} defines
the evolution via the (i) prediction\index{prediction} $\post_j \mapsto \hat{\post}_{j+1}$ and the (ii) analysis\index{analysis} $\hat{\post}_{j+1}
\mapsto \post_{j+1}$ steps; it is in step (ii) that the
data $\yd_{j+1}$ is incorporated. The bootstrap particle filter\index{particle filter!bootstrap} of Section \ref{sec:pf} 
uses this factorization of the filter evolution. 
The optimal  particle filter\index{particle filter!optimal} of Section
\ref{sec:opf} uses a different factorization into 
(i)  $\post_j \mapsto \intp_{j+1}$ 
and (ii) $\intp_{j+1} \mapsto \post_{j+1}$, 
in which both steps depends on the data $\yd_{j+1}$.

For both particle filters an issue arising in application to high dimensional problems is weight collapse. We provide a methodology to learn new
ensemble methods that lead to equal weight ensemble filters, trained
to be close to the bootstrap or optimal particle filters in step (ii).
Our available data is as follows:

\begin{dataassumption}
\label{da:9f}
    We are given i.i.d.\thinspace samples $\{\hv_{j+1}^{(n)}\}_{n=1}^N$ from the forecast distribution $\widehat\pi_{j+1}$ at time $j+1$.
\end{dataassumption}

In what follows we use distance measures, such as those derived
from the scoring rules from Section \ref{sec:psr}. (We exclude the deterministic scoring rules\index{scoring rule!deterministic} from Subsection \ref{ssec:dldsc}, given in Definition \ref{def:det_score}, that are employed
solely in the context of state estimation.)  The key attribute we seek for the
distance is that it is implementable given only samples. Indeed it is instructive to think
of scoring rules as being introduced for this purpose: metrics and divergences  may not
be amenable to measuring distance between two probability distributions when both are given
only through samples. In Subsection \ref{ssec:learning_filters_vi} we discuss how variational inference may be used to learn probabilistic filters, and then in Subsection \ref{ssec:LF} we discuss how scoring rules may be used instead. Subsection \ref{ssec:BPF99} then deploys these ideas in the
context of learning using the bootstrap particle filter; Subsection \ref{ssec:OPF99} generalizes
to the optimal particle filter.

\subsection{Learning Filters Using Variational Inference}\label{ssec:learning_filters_vi}\index{variational!formulation of filtering}

Recall the dynamical system \eqref{eq:sdm}
\begin{align*}
\vd_{j+1} &= \Psi(\vd_j) + \xi^\dagger_j,\\
\vd_0 &\sim \mathcal{N}(m_0, C_0), \quad \xi^\dagger_j \sim \mathcal{N}(0, \Sigma) \: \text{i.i.d.}, 
\end{align*}
with observations given by \eqref{eq:dm}
\begin{align*}
\yd_{j+1} &= h(\vd_{j+1}) + \eta^\dagger_{j+1},\\
\eta^\dagger_j &\sim \mathcal{N}(0, \Gamma) \quad \text{i.i.d.}
\end{align*}

Also recall the notation
\begin{align*}
\Yd_j = \{\yd_1, \ldots, \yd_j\}.
\end{align*}

We now parameterize the set of candidate approximate filters $q$ to develop the basis of actionable algorithms. Recall the prediction
and analysis operators defined in \eqref{eq:pna}. Consider a family
of algorithms in which the analysis step is parameterized by
$\theta$, yielding the following recursion:
\begin{equation}
\label{eq:pran}
    q_{j+1}(\theta) = \An_\theta(\Pred q_j(\theta); \yd_{j+1}),\quad q_0 = \pi_0.
\end{equation}

Then, using the variational formulation of filtering in \eqref{eq:var_filtering} and substituting in \eqref{eq:pran}, we define the cost function
\begin{align}
    \J_{j+1}(\theta) = \dkl(q_{j+1}(\theta)\|\Pred q_j(\theta)) - \mathbb{E}^{v_{j+1}\sim q_{j+1}(\theta)}[\log \mathbb{P}(\yd_{j+1} | v_{j+1})],
\end{align}
and also define
\begin{equation}
    \J(\theta) = \sum_{j=1}^{J} \J_j(\theta).
\end{equation}

Assuming that there is some $\theta$ such that $\An_{\theta} = \An$, then for $\topt\in\argmin_\theta \J(\theta)$ we have that
\begin{equation*}
    \J_{j+1}(\topt) = \dkl(\pi_{j+1}\|\hat{\pi}_{j+1}) - \mathbb{E}^{v_{j+1}\sim \pi_{j+1}}[\log \mathbb{P}(\yd_{j+1} | v_{j+1})],
\end{equation*}
i.e., $\J$ is minimized by those parameters which return the true filtering distribution $\pi_j=\mathbb{P}(\vd_j|\Yd_j)$ at every $j$.

\subsection{Learning Filters Using Strictly Proper Scoring Rules}
\label{ssec:LF}

The following theorem provides the basis for learning filters using strictly proper scoring rules.

\begin{theorem}\label{theorem:strict_proper_filter}
 Consider a strictly proper scoring rule\index{scoring rules!proper}  $S(\cdot, \cdot)$; see Definition \ref{def:proper_score}. Then, for any distribution $q(\Yd_j)$, a function of $\Yd_j$, we have that
\begin{equation}\label{eq:scoreOBJ}
\mathbb{E}^{(\vd_j, \Yd_j)} \Bigl[S(q(\Yd_j), \vd_j)\Bigr]\geq \mathbb{E}^{(\vd_j, \Yd_j)} \Bigl[S(\mathbb{P}(\vd_j|\Yd_j), \vd_j)\Bigr].
\end{equation}
\end{theorem}

\begin{proof}
From the definition of a strictly proper scoring rule, we have that
\begin{equation*}
    \mathbb{E}^{v_j\sim\mathbb{P}(\vd_j|\Yd_j)} \Bigl[S(q(\Yd_j), v_j)\Bigr]\geq \mathbb{E}^{v_j\sim\mathbb{P}(\vd_j|\Yd_j)} \Bigl[S(\mathbb{P}(\vd_j|\Yd_j), v_j)\Bigr].
\end{equation*}
Taking the expectation with respect to $\Yd_j$ of both sides, we obtain the desired result.
\end{proof}

Thus, having only the information $Y^\dagger_j$, the filtering distribution minimizes the expected score. Hence this expected score may be used as the basis for learning algorithms designed to match
the true filter, using only samples from the joint distribution of $\vd_j$ and $\Yd_j$. 
Certain scoring rules are amenable to sample-based implementation, which will be convenient in what follows.

As in \eqref{eq:pran}, we now parameterize the set of approximate filters $q$:
\begin{equation*}
    q_{j+1}(\theta) = \An_\theta(\Pred q_j(\theta); \yd_{j+1}),\quad q_0 = \pi_0.
\end{equation*}

\begin{corollary}
    Consider $q_j$ evolving under the $\theta$-parameterized algorithm
    \eqref{eq:pran} and define
\begin{align*}
    \J(\theta) &= \mathbb{E}^{(\vd_j,\Yd_j)} \Bigl[S(\An_\theta(\Pred q_{j-1}(\theta); y^\dagger_{j}), \vd_j)\Bigr],\\
    \topt &\in \argmin_\theta \J(\theta).
\end{align*}
Then, if there is some $\theta$ for which $\An_\theta = \An$ and $j>0$, we have that
\begin{equation*}
    \J(\topt) = \mathbb{E}^{(\vd_j,\Yd_j)} \Bigl[S(\mathbb{P}(\vd_j|\Yd_j), \vd_j)\Bigr].
\end{equation*}
\end{corollary}
\begin{proof}
    This follows from Theorem~\ref{theorem:strict_proper_filter} by substituting \eqref{eq:pran} for $q(\Yd_j)$.
\end{proof}

\begin{remark}
    Empirical minimization algorithms based on $\J(\theta)$ are straightforward in practice. For example it is possible to approximate the expectation $\mathbb{E}^{(\vd_j,\Yd_j)}$ by obtaining pairs $\{(\Vd_j)^{(n)}, (\Yd_j)^{(n)}\}_{n=1}^N$ from the dynamical system \eqref{eq:sdm}, \eqref{eq:dm}.
\end{remark}



\subsection{Bootstrap Particle Filter}
\label{ssec:BPF99}

Recall, from \eqref{eq:pip2}, \eqref{eq:bpf2},
the particle filter approximation of the filtering distribution
$\post_{j+1}$:
\begin{equation*}
   \pip_{j+1} = \sum_{m=1}^M w_{j+1}^{(m)}\delta_{\widehat v_{j+1}^{(m)}}.
\end{equation*}
Here the particles $\widehat v_{j}^{(m)}$ and weights $w_{j}^{(m)}$
evolve according to
\begin{align*}
    \widehat v_{j+1}^{(m)} &= \Psi \bigl(v_j^{(m)}\bigr) + \xi_j^{(m)},\\
     \ell_{j+1}^{(m)} &= \exp \left( - \frac{1}{2} \bigl\lvert \yd_{j+1} - h\bigl(\widehat v_{j+1}^{(m)}\bigr) \bigr\rvert_{\Gamma}^2 \right),\\
w_{j+1}^{(m)}&= \ell_{j+1}^{(m)}\Big/\Bigl(\sum_{i=1}^M \ell_{j+1}^{(i)}\Bigr).
\end{align*}
We have chosen integer $M$ here for the number of particles to emphasize that
it may be different from integer $N$ used in the ensuing ensemble 
Kalman-like method. From $\pip_{j+1}$ we may construct an equally weighted approximation by resampling to obtain
\begin{equation*}
   \pir_{j+1} = \sum_{m=1}^M \frac{1}{M}\delta_{v_{j+1}^{(m)}}.
\end{equation*}
Here the $v_{j+1}^{(m)}$ are drawn i.i.d. from $\pip_{j+1}$. In this
process some of the $\{\widehat v_{j+1}^{(r)}\}_{r=1}^M$ may be 
dropped and others repeated.


We want to learn parameters $\theta$ in a modified ensemble
Kalman filter, defined by equation \eqref{eq:predEnKF2}, so that
the following equally weighted approximation of the filtering
distribution is close to the true filtering distribution:
\begin{equation*}
   \pie_{j+1}(\theta) = \sum_{n=1}^N \frac{1}{N}\delta_{v_{j+1}^{(n)}(\theta)}.
\end{equation*}
Here, recalling \eqref{eq:predEnKF2},
\begin{align*}
\widehat{v}_{j+1}^{(\sam)} &= \Psi(v_{j}^{(\sam)})+\xi^{(\sam)}_{j}, \quad \sam=1,\ldots,\Sam, \\
v_{j+1}^{(\sam)}(\theta) &= \widehat{v}_{j+1}^{(\sam)}+K_{j+1}\bigl(\yd_{j+1}-\eta_{j+1}^{(\sam)}-h(\widehat{v}_{j+1}^{(\sam)})\bigr),\quad \sam=1,\ldots,\Sam,\\
K_{j+1}&=\Ks\bigl(\widehat{v}_{j+1}^{(1)},\ldots,\widehat{v}_{j+1}^{(N)};\theta\bigr).
\end{align*}
Recall the integral probability metric MMD \index{maximum mean discrepancy} 
from Definition \ref{def:dmmd},
noting that it may be implemented for empirical (equally weighted ensemble)
measures as in \eqref{eq:MMD_ens}.
We then define $\theta^\star$ by
\begin{subequations} %
    \begin{align}
        \J^{M,N}(\theta) &= \dmmd(\pir_{j+1},\pie_{j+1}),\\
        \theta^\star&\in \argmin_\theta \J^{M,N}(\theta).
    \end{align}
\end{subequations}

\begin{remark}
    \label{rem:lpf}
    Note that we have been silent about how the particles
    $\{v_{j}^{(m)}\}_{m=1}^M$ for the bootstrap particle
    filter, and the particles $\{v_{j}^{(n)}\}_{n=1}^N$
    for the equally weighted ensemble filter, are chosen.
    They should be chosen from the same distribution $\post_j$, 
    but they do not need to be identical as points. It is possible
    to choose $\post_j=\pie_{j}$ and to average $\J(\cdot)$ over
    $j.$ The preceding methodology could then be implemented
    under Data Assumption \ref{da:9e}.
    
    Recall also that $M$ may not equal $N$;
    indeed it may be advantageous to choose $M \gg N$ to ensure
    that the resampling process provides good representation
    of the true filter $\post_{j+1}.$
\end{remark}






\subsection{Optimal Particle Filter}
\label{ssec:OPF99}

We now describe a similar methodology to that in the preceding subsection, but based on the
optimal particle filter rather than the bootstrap particle 
filter. Recall, from \eqref{eq:pop}, \eqref{eq:opf99},
the optimal particle filter approximation of the filtering distribution
$\post_{j+1}$:
\begin{equation*} 
\pop_j = \sum_{m=1}^M w_{j}^{(m)}\delta_{\widehat v_{j}^{(m)}},
\end{equation*}
where the particles $\widehat v_{j}^{(m)}$ and weights $w_{j}^{(m)}$
evolve according to, for $\xi_{n+1}^{(m)} ~\text{i.i.d.}\thinspace \mathcal{N}(0,C)$,
\begin{align*}
    \widehat{v}_{j+1}^{(m)} &= (I - KH)\Psi(v_j^{(m)}) + K\yd_{j+1} + \xi_{j+1}^{(m)},
    \qquad v_{j}^{(m)} \overset{\rm i.i.d.} {\sim} \pop_j,\\
    \ell_{j+1}^{(m)} &= \exp\left(-\frac12|\yd_{j+1} - H\Psi(v_j^{(m)})|_S^2\right) , \\
    w_{j+1}^{(m)} &= \ell_{j+1}^{(m)} / \sum_{r=1}^N \ell_{j+1}^{(r)} .
\end{align*}
From $\pop_{j+1}$ we may construct an equally weighted approximation by resampling to obtain
\begin{equation*}
   \por_{j+1} = \sum_{m=1}^M \frac{1}{M}\delta_{v_{j+1}^{(m)}}.
\end{equation*}
Here the $v_{j+1}^{(m)}$ are drawn i.i.d. from $\pop_{j+1}$.





Recall Subsection \ref{ssec:opflf}.
We want to learn parameters $\theta$ in a modified ensemble
3DVar, defined by equation \eqref{eq:predEnKF2}, so that
the following equally weighted approximation of the filtering
distribution is close to the true filtering distribution:
\begin{equation*}
   \pio_{j+1}(\theta) = \sum_{n=1}^N \frac{1}{N}\delta_{v_{j+1}^{(n)}(\theta)}.
\end{equation*}
Here, recalling \eqref{eq:opf999},
\begin{align*}
    \widehat{v}_{j+1}^{(n)} &= (I - KH)\Psi(v_j^{(n)}) + K\yd_{j+1} + \xi_{n+1}^{(n)}, \\
    v_{j+1}^{(\sam)} &= \widehat{v}_{j+1}^{(\sam)}+\ks\Bigl(\{\widehat{v}_{j+1}^{(n)}\}_{n=1}^N,\widehat{v}_{j+1}^{(\sam)},\yd_{j+1},i_{j+1}^{(\sam)};\theta\Bigr), \quad \sam=1,\ldots,\Sam,\\
i_{j+1}^{(\sam)} & =\yd_{j+1}-H\widehat{v}_{j+1}^{(\sam)}.
\end{align*}
We then define $\theta^\star$ by
\begin{subequations} %
    \begin{align}
        \J^{M,N}(\theta) &= \dmmd(\pio_{j+1},\por_{j+1}),\\
        \theta^\star&\in \argmin_\theta \J^{M,N}(\theta).
    \end{align}
\end{subequations}
The same comments as in Remark \ref{rem:lpf}
apply here too.













\section{Bibliography}

Several works have studied variational formulations of smoothing and filtering problems. Learning parameterized filters using the variational objective introduced in Subsection \ref{ssec:learning_filters_vi} was considered in  \cite{luk_learning_2024}. An alternative variational objective for jointly learning a parameterized filter and the system dynamics is given in \cite{boudier2023data}. A variational formulation of the filtering and smoothing problems in continuous time, where the posterior is restricted to be in the exponential family\index{exponential family}, is provided in \cite{sutter_variational_2016}. The variational formulation of the optimal continuous-time filter (the Kushner--Stratonovich equation\index{Kushner--Stratonovich equation}) with no dynamics is derived in \cite{laugesen_poissons_2015}. The latter is formally combined with a variational formulation of the Fokker--Planck equation\index{Fokker--Planck equation} for gradient systems in \cite{lambert_variational_2023}, and it is shown that the solution coincides with the Kalman--Bucy filter\index{Kalman filter!Kalman--Bucy} in the linear case. Variational filtering is discussed in \cite{marino_general_2018}, and the proof of Theorem~\ref{theorem:filter_factorized} is given there.

We add some remarks on implementation issues arising in
Sections \ref{sec:smoothers} and \ref{sec:filteringuq}. In order to evaluate $\J(\theta)$, the expectations can be replaced by empirical means. Additionally, the KL divergence must be computed. In some cases, such as with Gaussian densities, a closed form of the divergence is available: see Example \ref{ex:klg}, and
identity \eqref{eq:kl_gaussians} in particular. Indeed Gaussian approximation
is, in general, popular both because the interpretability of the mean
and covariance, and because of the closed form for the divergence. In case only samples of $q_\theta^{\Yd}$ are available (such as in an ensemble smoother), the divergence may be approximated by first applying density estimation to these samples. Since the derivative of $\J(\theta)$ will generally be hard to obtain analytically, auto-differentiation\index{auto-differentiation} can be applied, and then gradient-based methods used to minimize it. An example of using auto-differentiation in a similar context is provided in \cite{levine_framework_2022}. %

3DVar gain learning was considered in \cite{hoang_simple_1994,mallia-parfitt_assessing_2016}, and a lower-dimensional parameterization was considered in \cite{hoang_adaptive_1998}. It was also considered in \cite{levine_framework_2022} in the case of nonlinear dynamics. It was proven in \cite{hoang_simple_1994,mallia-parfitt_assessing_2016} that the fixed gain which minimizes the expected error with respect to observations, in the asymptotic limit, is the steady-state Kalman gain. However, the cost functions considered were different, and \cite{hoang_simple_1994} required assumptions on the rank of $H$.

The learning of a neural network analysis step by minimizing a state estimation loss in an EnKF was considered in \cite{mccabe_learning_2021}. The analysis step there is EnKF-like in the sense that the ensemble members interact during the analysis step only through the ensemble mean and covariance. The learning of an analysis step was also considered in \cite{bocquet_accurate_2024}. Permutation-invariant neural networks were used for postprocessing of an ensemble in \cite{hohlein_postprocessing_2024}.
The issue of estimating optimism and out-of-sample performance of DA algorithms is discussed in \cite{brocker_sensitivity_2012,mallia-parfitt_assessing_2016}.
Various approaches to learning inflation are discussed in \cite{anderson_spatially_2009,miyoshi_gaussian_2011}. Learning localization by minimizing the squared Euclidean distance between the analysis and the true trajectory is considered in \cite{wang_convolutional_2023}, while a similar approach with a different scoring rule is considered in \cite{moosavi_tuning_2019}. Other approaches to learning localization are discussed in \cite{popov_bayesian_2019,cheng_graph_2021,kalnay_review_2023,le_provost_adaptive_2023,vishny_high-dimensional_2024}.
Emulating the analysis step of a Kalman filter using recurrent neural networks is considered in \cite{harter_data_2012}.
An ensemble estimator for the energy score was introduced in \cite{gneiting_assessing_2008}.
For the statement and proof of the Stolz--Ces\`aro theorem, see Theorem~1.23 in \cite{muresan_concrete_2009}.

The use of Gaussian approximations in filtering, including via variational Bayes, is studied in the papers \cite{csato2002data,vrettas2011estimating,archambeau2007variational}. Combinations with ensemble methods are discussed in
\cite{vrettas2015variational}. The paper
\cite{galy2021flexible} employs mean-field\index{mean-field} models.

Learning 4DVar was considered in~\cite{filoche2023learning}. A data assimilation approach via reinforcement learning\index{reinforcement learning} can be found in \cite{hammoud_data_2024}.

For work on learning controllers, a subject closely related
to learning data assimilation algorithms in the presence
of model error, see \cite{fiechter1997pac,dean2020sample}.
The use of reinforcement learning within data assimilation is an area likely to
see considerable growth; see \cite{mowlavi2024reinforcement,hammoud_data_2024}.

There have been several works on trying to learn the filtering distribution directly without using knowledge of the model dynamics \cite{brocker_probabilistic_2009,boudier2023data,rozet_score-based_2023,bao_score-based_2024}. This is sometimes referred to as ``end-to-end'' learning. This has also been considered for state estimation \cite{tsiamis_online_2023,du_can_2023,vaughan_aardvark_2024}.

\chapter{\Large{\sffamily{Learning the Filter or Smoother Using Transport}}}

The focus of this chapter is the development of measure transport approaches for the probabilistic solution of filtering and smoothing problems. These approaches extend the parameterized maps considered in Chapter~\ref{ch:LG} for probabilistic estimation, which maintained the structure of classic ensemble filtering and smoothing algorithms. In this chapter, we will find transformations that are not constrained to specific functional forms and can be used to solve general filtering and smoothing problems. Sections~\ref{sec:filtering_map} and~\ref{sec:amortized_filtering} are analogous to Chapters~\ref{ch:transport} and~\ref{ch:data-dependence}, respectively, for the transport approach to solving inverse problems. Here, we apply these ideas in the context of the
analysis\index{analysis} component of filtering.
In Section~\ref{sec:filtering_map}, we discuss how to build maps from the forecast to an analysis distribution using deterministic transports, while Section~\ref{sec:amortized_filtering} seeks transports by learning their dependence on the observation. 
Section~\ref{sec:transport_smoothing} extends the transport framework to the solution of smoothing problems. The bibliography in Section~\ref{sec:Bib_learning_filters} concludes with other instances of transport-based ensemble filtering and smoothing algorithms.

\section{Learning the Forecast to Analysis Map} \label{sec:filtering_map}

In this section we seek a transport map that pushes forward the prediction to the analysis distribution in each step of a filtering problem. Following the notation in Chapter~\ref{ch:LG}, we let $\widehat{v}_{j+1} \in \R^\du$ denote the state at time $j+1$ following the forecast distribution $\widehat{\pi}_{j+1}$. We would like to find samples from the analysis distribution
$\pi_{j+1}.$ Our goal is to find a transport $T(\cdot; \yd_{j+1},\theta) \colon \R^\du  \rightarrow \R^\du$, that depends on the 
observation $\yd_{j+1}\in \R^\dy$ and parameters $\theta \in \Theta \subseteq \R^p$, and has the property that
$$T(\widehat{v}_{j+1};\yd_{j+1},\theta) \sim \pi_{j+1}, \qquad \widehat{v}_{j+1} \sim \widehat{\pi}_{j+1}.$$ 
After finding $T$, we can evaluate the map at forecast samples to generate analysis samples. Our goal is to find this map given only a forecast ensemble and the observation model. 
Because it is notationally convenient to do so, we will sometimes drop the dependence of $T$ on $\yd_{j+1}$ in what follows within this section.


\begin{dataassumption}
\label{da:10a}
We are given i.i.d.\thinspace samples $\{\hv_{j+1}^{(n)}\}_{n=1}^N$ from the forecast distribution $\widehat\pi_{j+1}$ at time $j+1$
and we are able to evaluate $\like(\yd_{j+1}|\hv_{j+1}^{(n)}).$
\end{dataassumption}

\begin{remark}
    In practice, when using methods based on $T$ within multiple
    iterations of the predict--analysis cycle, we will not have
    access to \emph{exact} samples from the forecast distribution $\widehat\pi_{j+1}$ at time $j+1$, but rather to \emph{approximate} samples. This, however, does not affect
    the proposed methodology; it is blind to whether the
    given data forms exact or approximate samples.
\end{remark}

A major challenge in ensemble filtering and smoothing problems is that both the reference (forecast) and target (analysis) distributions for the map do not have analytical density functions;
everything is defined through approximate ensembles, and hence
combinations of Dirac measures. For this reason the transport approaches derived in Chapter~\ref{ch:transport}, which rely on the explicit form of the reference density to define the loss function (for example, the KL divergence in~\eqref{eq:waya}) do not apply.
 
In this section we will seek the map so that the push-forward distribution $T_\sharp \widehat\pi_{j+1}$ is close to the true filtering distribution $\pi_{j+1}$. We do this by minimizing the squared energy distance, noting that this distance measure
is well-defined between two empirical measures. Recall
from Definition \ref{def:energy} that this distance is
\begin{subequations}
 \label{eq:energy_dist_filtering0}
\begin{align} 
\den^2(T_\sharp \widehat{\pi}_{j+1},\pi_{j+1}) &= 2\mathbb{E}^{(v,v') \sim T_\sharp \widehat\pi_{j+1} \otimes \pi_{j+1}}|v - v'| - \mathbb{E}^{(v,v') \sim T_\sharp \widehat\pi_{j+1} \otimes T_\sharp \widehat\pi_{j+1}}|v - v'| \\
&\quad - \mathbb{E}^{(v,v') \sim \pi_{j+1} \otimes \pi_{j+1}}|v - v'|, \nonumber
\end{align}
\end{subequations}
where we have suppressed the dependence of the map on the parameters $\theta$ and the observation $\yd_{j+1}$ for conciseness. 
We note also that
\begin{equation*} 
\den^2(T_\sharp \widehat{\pi}_{j+1},\pi_{j+1})  
= 2\mathbb{E}^{(v,v') \sim \widehat\pi_{j+1} \otimes \pi_{j+1}}|T(v) - v'| - \mathbb{E}^{(v,v') \sim \widehat\pi_{j+1} \otimes \widehat\pi_{j+1}}|T(v) - T(v')| + c,
\end{equation*}
where $c$ is a constant that is independent of the transport $T$.
Noting that we will optimize over (parameterized) transport $T$
we emphasize that this constant is hence irrelevant for our purposes
here.

To evaluate the distance given only a forecast ensemble, we use importance sampling to write the expectation in the distance with respect to $\pi_{j+1}$ in terms of $\widehat\pi_{j+1}$ with the likelihood weights $w_{j,n} = \like(\yd_{j+1}|\widehat{v}_{j+1}^{(n)})$. Given a forecast ensemble $\{\widehat{v}_{j+1}^{(n)}\}_{n=1}^N$, we then define the loss function for the transport parameters as
\begin{equation} \label{eq:LossEnergyDist_Filtering}
    \loss(\theta) = \frac{2}{N^2}\sum_{n,m = 1}^N|T(\widehat{v}_{j+1}^{(n)};\theta) - \widehat{v}_{j+1}^{(m)}|w_{j,m} - \frac{1}{N^2}\sum_{n,m = 1}^N|T(\widehat{v}_{j+1}^{(n)};\theta) - T(\widehat{v}_{j+1}^{(m)};\theta)|.
\end{equation}
The following result shows that the optimal parameters 
\begin{equation} \label{eq:OptParam_Filtering}
    \theta^\star \in \argmin_{\theta \in \Theta} \loss(\theta)
\end{equation}
minimize the energy distance with certain arguments.

\begin{theorem} \label{thm:MinimizingEnergyDistance_Filtering}
Given a forecast ensemble $\{\widehat{v}_{j+1}^{(n)}\}_{n=1}^N$, let   $$\widehat\pi_{j+1} \coloneqq \sum_{n=1}^N \delta_{\widehat{v}_{j+1}^{(n)}}$$ represent the forecast distribution at time $j+1$ and let 
$$\pi_{j+1}(v) \propto \like(\yd_{j+1}|v)\widehat\pi_{j+1}(v)$$ be the filtering distributions at time $j+1$, respectively. Then the optimal parameters for the transport map in~\eqref{eq:OptParam_Filtering} solve the problem
$$\theta^\star \in \argmin_{\theta \in \Theta} \den \Bigl(T(\cdot;\yd_{j+1},\theta)_\sharp \widehat\pi_{j+1},\pi_{j+1} \Bigr).$$
\end{theorem}

\begin{proof} For the empirical measure $\widehat\pi_{j+1}$, the filtering distribution is also an empirical measure and the energy distance $\den^2(T(\cdot;\yd_{j+1},\theta)_\sharp \widehat\pi_{j+1},\pi_{j+1})$ is given by the loss function $\loss(\theta)$ up to an additive constant. Given that the energy distance is minimized when the measures are equal and the constant does not affect the minimizer, the optimal parameters coincide.
\end{proof}

\begin{remark} While evaluating the loss function, and hence the learned transport map, relies on importance sampling, the forecast ensemble will be updated using the transport alone. The transport will push-forward an equally weighted ensemble of forecast to analysis samples. This may partially alleviate the degeneracy faced by particle filters where the ensemble  eventually has an effective sample size of 1. Particle degeneracy arises from keeping the position of each particle fixed during the analysis step. This constraint forces particles to possibly remain in low probability under the filtering distribution after conditioning on an observation. Instead, the approach outlined in this section uses transport to move the particle positions in each analysis step.
\end{remark}

\section{Learning Dependence of the Map on Data} \label{sec:amortized_filtering}

In this section we again seek transports that map to the filtering distribution $\pi_{j+1}$. In this case, we let the map $T$ \emph{explicitly} depend on both the predicted state $\widehat{v}_{j+1} \in \R^\du$ and the true observation $\yd_{j+1} \in \R^\dy$; in particular we try to learn the dependence of
$T$ on not only the forecast $\widehat{v}_{j+1}$ but also
the data $\yd_{j+1}.$ 
Our goal is to find the parameters $\theta \in \Theta \subseteq \R^p$ of the map $T$ so that, at least approximately,
$$\widehat{v}_{j+1} \sim \widehat{\pi}_{j+1} \Rightarrow T(\widehat{v}_{j+1},\yd_{j+1};\theta) \sim \pi_{j+1}.$$
Here the filtering distribution $\pi_{j+1}$ is found from
Bayes Theorem \ref{t:bayes} with the prior coming from
the forecast $\widehat\pi_{j+1}$ and the likelihood model $\like(\yd_{j+1}|\cdot)$.
Using the push-forward notation, or goal is to choose $\theta$
to get as close as possible to achieving
\begin{equation}
 \label{eq:www}   
T(\cdot,\yd_{j+1};\theta)_\sharp \widehat\pi_{j+1} = \pi_{j+1}.
\end{equation}
In this section we will aim to identify appropriate $\theta$ without likelihood evaluations, i.e., given only an ensemble from the joint distribution. 

\begin{dataassumption} \label{da:10b} We are given pairs of i.i.d.\thinspace samples $\{(\hv_{j+1}^{(n)},{y}_{j+1}^{(n)})\}_{n=1}^N$ from the joint distribution $\joint_{j+1}(v,y) \coloneqq \widehat\pi_{j+1}(v)\like(y|v)$.
\end{dataassumption}
In the following two subsections we will present two formulations to find these maps. In  Subsection~\ref{sec:ED_datadependence_opt} we will minimize an objective based on the energy distance, while Subsection~\ref{sec:MLE_datadependence_opt} will leverage the transports learned via maximum likelihood in Chapter~\ref{ch:transport}.

\subsection{Minimizing the Energy Distance} \label{sec:ED_datadependence_opt}

Following the approach in Section~\ref{sec:filtering_map}, we will consider the objective to be the energy distance between the true and approximate filtering distributions in expectation over the observation $\yd_{j+1}$ drawn from its marginal distribution $\marg_{j+1}$. That is,
\begin{align*} 
\mathbb{E}^{\yd_{j+1} \sim \marg_{j+1}}\left[\den^2 \bigl(T(\cdot,\yd_{j+1})_\sharp \widehat{\pi}_{j+1},\pi_{j+1} \bigr)\right] &= 2\mathbb{E}^{\yd_{j+1} \sim \marg_{j+1}}\mathbb{E}^{(v,v') \sim \widehat\pi_{j+1} \otimes \pi_{j+1}}|T(v,\yd_{j+1}) - v'| - \\ 
\mathbb{E}^{\yd_{j+1} \sim \marg_{j+1}} &\mathbb{E}^{(v,v') \sim \widehat\pi_{j+1} \otimes \widehat\pi_{j+1}}|T(v,\yd_{j+1}) - T(v',\yd_{j+1})| + c,
\end{align*}
where $c$ is again a constant that is independent of $T$. By using the factorization of the joint distribution
$\joint_{j+1}(v,y) =
\pi_{j+1}(v)\marg_{j+1}(y),$
we can write the expected energy distance as 
\begin{align*} \label{eq:energy_dist_filtering}
\mathbb{E}^{\yd_{j+1} \sim \marg_{j+1}}\left[\den^2 \bigl(T(\cdot,\yd_{j+1})_\sharp \widehat{\pi}_{j+1},\pi_{j+1} \bigr)\right] &= 2\mathbb{E}^{(v,v',\yd_{j+1}) \sim \widehat\pi_{j+1} \otimes \joint_{j+1}}|T(v,\yd_{j+1}) - v'| \\
- &\mathbb{E}^{(v,v',\yd_{j+1}) \sim \widehat\pi_{j+1} \otimes \widehat\pi_{j+1} \otimes \marg_{j+1}}|T(v,\yd_{j+1}) - T(v',\yd_{j+1})|.
\end{align*}
 This allows us to use the joint ensemble to define the following empirical loss function for the map parameters:
$$\loss(\theta) = \frac{2}{N^2}\sum_{m,n=1}^N |T(\widehat{v}_{j+1}^{(n)},y_{j+1}^{(m)};\theta) - \widehat{v}_{j+1}^{(m)}| - \frac{1}{N^2}\sum_{l,m,n=1}^N |T(\widehat{v}_{j+1}^{(n)},y_{j+1}^{(l)};\theta) - T(\widehat{v}_{j+1}^{(m)},y_{j+1}^{(l)};\theta)|.$$
We then define the optimal parameters for the map as  $\theta^\star \in \argmin_{\theta \in \Theta} \loss(\theta)$.

\begin{remark} The two terms in the loss function $\loss$ have opposing behavior. While minimizing the first term encourages the map $T(\cdot,y_{j+1}^{(m)})$ to push-forward the forecast ensemble to the state $v_{j+1}^{(m)}$ matching the observation $y_{j+1}^{(m)},$ the second term encourages diversity in the map evaluations. That is, the second term is maximized by increasing the difference between all pairwise map evaluations for each observation.
\end{remark}

\begin{remark} The expectation in the second term of the loss function involves a tensor product of two measures for the state and observation. This expectation can be estimated from an ensemble of paired states and observations by permuting the pairings. That is, $(\widehat{v}_{j+1}^{(n)}, y_{j+1}^{(l)}) \sim \widehat\pi_{j+1} \otimes \marg_{j+1}$ for $n \neq l$.
\end{remark}

\subsection{Composed Maps Learned with Maximum Likelihood} \label{sec:MLE_datadependence_opt}

In this subsection we consider an alternative approach to construct an observation-dependent transport. To do so, we first identify an invertible block-triangular map (see Assumption~\ref{a:blockt}) that pushes forward 
the joint distribution $\joint_{j+1}$ to a known reference density $\refT$ using, for example, the maximum-likelihood approach introduced in Chapter~\ref{ch:transport}. The following theorem shows how to use this map to construct a  transport that pushes forward $\joint_{j+1}$ to the filtering distribution $\pi_{j+1}$.

\begin{theorem} \label{thm:FilteringMapComposition}
Let $S \colon \R^d \times \R^k \rightarrow \R^d$ be a triangular map of the form 
\begin{equation} \label{eq:TriangularMapFiltering}
  S(y,v) = \begin{bmatrix*}[l] y \\ S_2(y,v) \end{bmatrix*},  
\end{equation}
where $S_2(y,\cdot) \colon \R^{\du} \rightarrow \R^{\du}$ is invertible for each $y \in \R^{\dy}$.  We denote this inverse as $S_2(y,\cdot)^{-1}$. If $S$ pushes forward $\joint_{j+1}(y,v)$ to a product reference $\refT_1(y)\refT_2(v)$, then
\begin{equation} \label{eq:ComposedMapFiltering}
    T(y,v,\yd_{j+1}) \coloneqq  S_2(\yd_{j+1},\cdot)^{-1} \circ S_2(y,v)
\end{equation}
pushes forward $\joint_{j+1}(y,v)$ to $\pi_{j+1}(v)$ for any $\yd_{j+1} \in \R^\dy$.
\end{theorem}

\begin{proof} 
By Theorem~\ref{t:data}, the second component $S_2(y,\cdot)$ of a triangular map of the form  in~\eqref{eq:TriangularMapFiltering} pushes forward the conditional $\mathbb{P}(v|y)$ of $\joint_{j+1}(y,v)$ to $\refT_2(v)$ for any $y \in \R^k$. Thus, the inverse map $S_2(\yd_{j+1},\cdot)^{-1}\vert_{v}$ pushes forward the conditional $\mathbb{P}(v|\yd_{j+1})$ given by the filtering density $\pi_{j+1}$ to $\refT_2$. Composing these maps gives us a transport pushing forward $\joint$ to $\pi_{j+1}$.
\end{proof}

Given the joint ensemble of states and observations, we can define our analysis ensemble by building an estimator for the map $\widehat{S}_2$ using the procedure in Subsection~\ref{ssec:learning_maps} and evaluating the composed map at our joint ensemble:
$$v_{j+1}^{(n)} = \widehat{T}(y_{j+1}^{(n)},\widehat{v}_{j+1}^{(n)},\yd_{j+1}) \coloneqq \widehat{S}_2(\yd_{j+1},\widehat{S}_2(\widehat{v}_{j+1}^{(n)},\cdot)^{-1}|_{\widehat{v}_{j+1}^{(n)}}), \qquad n = 1,\dots,N.$$

\begin{remark} The joint-to-posterior map depends on both the true observation $\yd_{j+1}$ and synthetic observations $y_{j+1}$ at time $j+1$. For a fixed $\yd_{j+1}$, the transformation from the forecast to analysis state can be seen as a stochastic transport due to the randomness in the synthetic observations $y_{j+1}$. In contrast, the transports in Sections~\ref{sec:filtering_map} and~\eqref{sec:ED_datadependence_opt} for a fixed observation are deterministic maps that push forward $\widehat\pi_{j+1}$ to $\pi_{j+1}.$
\end{remark}

While the framework above is quite general, in practice we may want to seek transports within a parameterized family of functions with a particular structure. The following result shows that these filters based on composed maps are related to classic ensemble Kalman filters.

\begin{theorem} Let $S$ be an invertible triangle map of the form in~\eqref{eq:TriangularMapFiltering} where $S_2$ is the optimal map with respect to the loss function in~\eqref{eq:tsd} over the affine space
$$\mathcal{S} = \{S_2(y,u) = A(u + By + c), A \in \R^{\du \times \du}, A \succ 0, B \in \R^{\du \times \dy}, c \in \R^\du \}.$$  Then, the composed map in~\eqref{eq:ComposedMapFiltering} has the form of the ensemble Kalman update
$$T(y,v,\yd_{j+1}) = v + \Sigma_{\widehat{v}_{j+1},y_{j+1}}\Sigma_{y_{j+1},y_{j+1}}^{-1}(\yd_{j+1} - y),$$
where $\Sigma_{\widehat{v}_{j+1},y_{j+1}}$ and $\Sigma_{y_{j+1},y_{j+1}}$ denote the cross-covariance of $(\widehat{v}_{j+1},y_{j+1})$ and the covariance of $y_{j+1}$ under $\joint_{j+1},$ respectively.
\end{theorem}

\begin{proof} From Theorem~\ref{thm:ClosedFormAffineTransportMaps}, minimizing the loss in~\eqref{eq:tsd} over the space of affine maps $\mathcal{S}$ yields the transformation
$$S_2(y,v) = \Sigma_{v|y}^{-1/2} \left(v - \mathbb{E}[v] - \Sigma_{vy}\Sigma_{yy}^{-1}(y - \mathbb{E}[y]) \right),$$
where we have suppressed the dependence of the states in the covariance on time for conciseness. The inverse of the map evaluated at $\yd_{j+1}$ is given by 
$$S_2(\yd_{j+1},\cdot)^{-1}\vert_v = \Sigma_{v|y}^{1/2} v + \mathbb{E}[v] + \Sigma_{vy}\Sigma_{yy}^{-1}(\yd_{j+1} - \mathbb{E}[y]).$$
Composing these maps cancels out $\Sigma_{v|y}^{-1/2}$ and the constant terms, yielding the desired result.
\end{proof}

\section{Optimal Particle Filter Transport} \label{sec:transport_smoothing}
In  Section \ref{sec:filtering}, we define sequential filtering by alternating two steps: prediction using the dynamics model
$\mathsf{P}$, and analysis $\mathsf{A}$ by accounting for the realized observation. For notational convenience
we define $\mathsf{A}_j(\cdot)=\mathsf{A}(\cdot;\yd_{j+1})$ where
$\mathsf{A}$ is defined in \eqref{eq:An}. This can be summarized, similarly to Section \ref{sec:filtering}, as
$$\pi_{j+1} = \mathsf{A}_j \circ \mathsf{P} \pi_j.$$
In this section we follow the strategy of the optimal particle filter (OPF) introduced in Section~\ref{sec:opf}, which reverses these two steps. At each time step $j$, the OPF first applies an analysis step to sample the conditional distribution $\mathbb{P}(v_j|Y_j,\yd_{j+1})$ starting from $\mathbb{P}(v_j|Y_{j})$; and second it applies a prediction step to sample from $\mathbb{P}(v_{j+1}|Y_{j},\yd_{j+1})$. These two steps may be summarized using the relationship
$$\pi_{j+1} = \mathsf{P}_j^{\textrm{OPF}} \circ \mathsf{A}_j^{\textrm{OPF}} \pi_j.$$
While the OPF performs the analysis step using importance sampling, we will show in this section how to achieve the first step using transports. In particular, our goal is to find a map $T$ depending on some parameters $\theta$ so that 
\begin{equation} \label{eq:TransportSmoothing}
    T(v_j,\yd_{j+1};\theta) \sim \mathsf{A}_j^{\textrm{OPF}} \pi_j, \quad v_j \sim \pi_j.  
\end{equation}

In the previous two Sections~\ref{sec:filtering_map} and  \ref{sec:amortized_filtering} we showed how to build transports for conditioning given samples from the joint distribution of the forecast, under two data assumptions. In the first, Section~\ref{sec:filtering_map}, we assume that we can evaluate the likelihood of the observation $\yd_{j+1}$, while in the second, Section~\ref{sec:amortized_filtering} we require only samples drawn from the joint distribution of state and observation. We will now demonstrate how to apply both methods to define the transport in~\eqref{eq:TransportSmoothing} in the following two subsections.

\subsection{Learning with Likelihood Weights} \label{sec:TransportSmoothingImportanceSampling}

Following the approach in Section~\ref{sec:filtering_map}, we first seek the transport in~\eqref{eq:TransportSmoothing} that implicitly depends on the observation $\yd_{j+1}$ by minimizing the energy distance
\begin{equation}
\label{eq:paste}
    \theta^\star \in \argmin_{\theta \in \Theta} \den \Bigl(T(\cdot;\yd_{j+1},\theta)_\sharp \pi_{j}, \mathsf{A}_j^{\textrm{OPF}} \pi_j \Bigr).
\end{equation}

We make the following data assumption: 
\begin{dataassumption}
\label{da:10c}
We are given i.i.d.\thinspace samples $\{v_{j}^{(n)}\}_{n=1}^N$ from the filtering distribution $\pi_{j}$ at time $j$ and we are able to evaluate $\mathbb{P}(\yd_{j+1}|v_j^{(n)}).$
\end{dataassumption}

To compute expectations with respect to $\mathsf{A}_j^{\textrm{OPF}} \pi_j$ in the objective, we similarly rely on an importance sampling step by sampling $v_j^{(n)}$ from $\pi_j$ and computing the  likelihood weights for the observations $\mathbb{P}(y_{j+1}|v_j^{(n)}).$ As shown in Section~\ref{sec:opf}, in the setting
\eqref{eq:linearobs} when the observation model is linear,  the likelihood function for $\yd_{j+1}$ given the state $v_{j}$ is a Gaussian with the closed-form 
$$\mathcal{N}\Bigl(H\Psi(v_j),H\Sigma H^\top + \Gamma \Bigr).$$
We denote the evaluation at $\yd_{j+1}$, given sample $v_j^{(n)}$,
by $w_{j,n}.$
Then, we can define a loss function for the map parameters, which is analogous to~\eqref{eq:LossEnergyDist_Filtering}. Given an ensemble approximation $\{v_j^{(n)}\}_{n=1}^N \sim \pi_{j}$ to the analysis distribution at time $j$, we have the loss function
$$\loss(\theta) = 2 \frac{1}{N^2}\sum_{n,m = 1}^N|T(v_{j}^{(n)};\theta) - v_{j}^{(m)}|w_{j,m} - \frac{1}{N^2}\sum_{n,m = 1}^N|T(v_{j}^{(n)};\theta) - T(v_{j}^{(m)};\theta)|.$$
This is obtained from the energy distance formulation \eqref{eq:paste} after dropping $\theta-$independent terms.
The optimal map parameters can then be computed by finding 
$$\theta^\star \in \argmin_{\theta \in \Theta} \loss(\theta).$$ 
The equivalence between minimizing $\loss$ and the energy distance follows the same proof of Theorem~\ref{thm:MinimizingEnergyDistance_Filtering}. 

After learning the map, we can approximately sample from  $\mathbb{P}(v_j|Y_j,\yd_{j+1})$ by evaluating the map $T(v_j^{(n)};\yd_{j+1},\theta^\star)$ at each sample $v_{j}^{(n)} \sim \pi_j$. This process generates an ensemble from what is known as the \emph{lag-1 smoothing distribution}\index{lag1-smoother}, for the state given one future observation. Applying the Markov kernel given in~\eqref{eq:meanopt} and~\eqref{eq:covopt}, which defines the operator $\mathsf{P}_j^{\textrm{OPF}}$, then generates samples from the analysis distribution $\pi_{j+1}$ starting from the smoothing ensemble.

\subsection{Learning the Data Dependence}

Following the approach in Section~\ref{sec:amortized_filtering}, 
working under Data Assumption \ref{da:10b}, we now seek the transport in~\eqref{eq:TransportSmoothing} that explicitly depends on the observation by minimizing the expected energy distance
$$\theta^\star \in \argmin_{\theta \in \Theta} \mathbb{E}^{\yd_{j+1} \sim \marg_{j+1}} \left[\den(T(\cdot;\yd_{j+1},\theta)_\sharp \pi_{j}, \mathsf{A}_j^{\textrm{OPF}} \pi_j) \right].$$

As compared to the previous subsection, we can implement this loss as long as we can sample from the joint distribution of $(v_{j},y_{j+1})$ for the state and the observation at the next time. Given a collection of analysis samples $\{v_j^{(n)}\}_{n=1}^N \sim \pi_{j}$, we can sample synthetic observations by evaluating the dynamics model followed by the observation model for each sample. That is,
\begin{align*}
    \widehat{v}_{j+1}^{(n)} &= \Psi(v_j^{(n)}) + \xi_j, \quad \xi_j \sim \mathcal{N}(0,\Sigma) \\
    y_{j+1}^{(n)} &= h(\widehat{v}_{j+1}^{(n)}) + \eta_{j+1}^{(n)}, \quad \eta_{j+1}^{(n)} \sim \mathcal{N}(0,\Gamma).
\end{align*}
We then define the loss function for the map parameters as
$$\loss(\theta) = \frac{2}{N^2}\sum_{m,n=1}^N |T(v_{j}^{(n)},y_{j+1}^{(m)};\theta) - v_{j}^{(m)}| - \frac{1}{N^2}\sum_{l,m,n=1}^N |T(v_{j}^{(n)},y_{j+1}^{(l)};\theta) - T(v_{j}^{(m)},y_{j+1}^{(l)};\theta)|,$$
where the optimal parameters are given by $\theta^\star \in \argmin_{\theta \in \Theta} \loss(\theta)$. After identifying the map parameters, we generate the ensemble from the lag-1 smoothing distribution $\mathsf{A}_j^{\textrm{OPF}} \pi_j$ by evaluating the map $T(v_j^{(n)},\yd_{j+1};\theta^\star)$ with the true observation at time $j+1$ at each sample $v_{j}^{(n)} \sim \pi_j$.

\begin{remark} The procedure in Subsection~\ref{sec:TransportSmoothingImportanceSampling} requires a closed-form expression for the likelihood weights. Thus it is only implementable for linear observation models and one step of filtering, as for the optimal particle filter, as explained in Section~\ref{sec:opf}. On the other hand, the  approach in this subsection can be implemented for general non-linear observation operators, as long as we can sample from the forecast dynamics and likelihood model.
\end{remark}

\section{Bibliography} \label{sec:Bib_learning_filters}

Learning approaches for ensemble filtering and smoothing based on transportation of measure have shown recent promise in generalizing classic Kalman approaches and reducing the error. The paper \cite{spantini2022coupling} introduces the approach of composing triangular transports as in Theorem~\ref{thm:FilteringMapComposition} to build prior-to-posterior maps, while~\cite{al2023optimal} seeks optimal transport maps by solving adversarial learning problems. A related framework known as Gaussian anamorphosis seeks invertible transformations of the state and observations where Kalman algorithms apply. See~\cite{grooms2022comparison} for an approach based on nonlinear diagonal transformations and a generalization that uses invertible neural networks in~\cite{chipilski2023exact}. Other nonlinear generalizations of ensemble Kalman filtering methods include~\cite{hoang2021machine, anderson2010non, lei2011moment}. A nonlinear filter that is derived using variational inference using transports that lie in reproducing kernel Hilbert spaces (see Example~\ref{ex:kernel_trick}) is~\cite{pulido2019sequential}.

\chapter{\Large{\sffamily{Data Assimilation Using Learned Forecasting Models}}}\label{ch:da_learned}

In this chapter we consider having an ML forecast dynamics model $\Psi^a$  that approximates the true model $\Psi$; see Chapter \ref{ch:DAML} and Chapter \ref{ch:ts_forecasting} for ways to learn this model. The motivation for using $\Psi^a$ may be that $\Psi$ is unknown, or that the $\Psi^a$ is less computationally expensive to use for forecasting. Such a model (or multiple models) $\Psi^a$ can then be used for smoothing and filtering, or used in conjunction with $\Psi$ in ensemble-based algorithms to augment the ensemble size. Note that this is closely related to the use of surrogate models in inverse problems, discussed in Chapter \ref{ch:fsm}. No explicit data
assumptions are made in this chapter, as the surrogate models can potentially be learned from a
variety of different data scenarios.

This chapter is laid out as follows. In Section \ref{sec:ml_approx_da} we state approximation properties of the smoothing and filtering distributions with a learned forecast model. In Section \ref{sec:mf} we discuss multifidelity methods for making use of a learned forecast model, in addition to the original computational model, to improve data assimilation. In Section \ref{sec:mf_cov} we discuss multifidelity methods for estimating covariance matrices. Section \ref{sec:bibliographylearnedforecastDA} closes with bibliographical remarks.

\section{Smoothing and Filtering Using Surrogate Models}\label{sec:ml_approx_da}




\subsection{Smoothing Problem}

Recall definitions of $\Vd, \Yd$ and $\Yd_j$ from \eqref{eq:VdYd}.
From \eqref{eq:sprior} we obtain the prior on $\Vd$ from the dynamics model, 
a probability density function in $\mathcal{P}(\R^{\du(J+1)})$ given by
\begin{equation}
\label{eq:sprior2}
\rho(\Vd) \propto \exp\Bigl(-\frac12|\vd_0-m_0|_{C_0}^2-\frac12\sum_{j=0}^{J-1}|\vd_{j+1}-\Psi\bigl(\vd_j\bigr)|_{\Sigma}^2\Bigr).
\end{equation}
Immediately after \eqref{eq:sprior} we define
\begin{align*}
\etad &= \{\etad_1, \ldots, \etad_J\} \in \R^{\dy J},\\
\hs(\Vd) &=\bigl\{h(\vd_1), \ldots, h(\vd_J) \bigr\},
\end{align*}
where $\etad \sim \Nc(0, \Gammas)$, and $\Gammas$ is block diagonal with $\Gamma$ in 
each diagonal block. We then obtain the posterior
\begin{equation}
\label{eq:spost22}
\Pi(V) \propto \like(\Yd|V)\rho(V),
\end{equation}
also a probability density function in $\mathcal{P}(\R^{\du(J+1)})$, where
\begin{equation}
    \label{eq:like22}
    \like(\Yd|V) \propto \exp\Bigl(-\frac12|\Yd-\hs(V)|_{\Gammas}^2\Bigr).
\end{equation}
(We drop the superscript $\Yd$ on the posterior as it is not central to
the following discussion.)
If we use a surrogate model $\Psi^a$ to accelerate computations we will change the
prior dynamics model to have the form
\begin{equation}
\label{eq:sprior222}
\rho'(\Vd) \propto \exp\Bigl(-\frac12|\vd_0-m_0|_{C_0}^2-\frac12\sum_{j=0}^{J-1}|\vd_{j+1}-\Psi^a\bigl(\vd_j\bigr)|_{\Sigma}^2\Bigr).
\end{equation}
The resulting posterior is
\begin{equation}
\label{eq:spost222}
\Pi'(V) \propto \like(\Yd|V)\rho'(V),
\end{equation}




We are interested in what effect the use of a surrogate model has on the posterior.
As a first step we simply assume that $\rho'$ is close to $\rho$ and ask what can be said about the closeness of $\Pi'$ and $\Pi.$ In the following theorem and proof, all integrals are over $\R^{\du(J+1)}$.

\begin{theorem}
Assume that $Z:=\int \like(\Yd|V)\rho(V) \, dV>0.$ Then, there is a constant $C>0$ such that, for all
$\dtv(\rho,\rho')$ sufficiently small,
$$\dtv(\Pi,\Pi') \le C \dtv(\rho,\rho').$$
\end{theorem}

\begin{proof} In this proof $Z':=\int \like(\Yd|V)\rho'(V) \, dV>0$ and $\like(V)=\like(\Yd|V).$
We have
\begin{align*}
2\dtv(\Pi,\Pi')&=\int \Bigl| \frac{1}{Z}\like(V)\rho(V)-\frac{1}{Z'}\like(V)\rho'(V)\Bigr| \, dV\\
& \le I_1+I_2,\\
I_1 & := \int \Bigl| \frac{1}{Z}\like(V)\rho(V)-\frac{1}{Z}\like(V)\rho'(V)\Bigr| \, dV,\\
I_2 & := \int \Bigl| \frac{1}{Z}\like(V)\rho'(V)-\frac{1}{Z'}\like(V)\rho'(V)\Bigr| \, dV.
\end{align*}
Since $Z>0$ and $\like(V)$ is uniformly bounded with respect to $V$ we deduce that, for some $C_1>0,$
$$I_1 \le C_1 \dtv(\rho,\rho').$$
It also follows that, for some $C_2>0,$
$$|Z-Z'| \le \int \like(V)|\rho(V)-\rho'(V)| \, dV \le C_2 \dtv(\rho,\rho').$$
Hence, for all $\dtv(\rho,\rho')$ sufficiently small, $Z'>\frac12 Z>0.$ Finally
we deduce that, for some $C_1>0,$ for some $C_3>0$,
$$I_2 = \left|\frac{1}{Z} - \frac{1}{Z'}\right|Z \le C_3 |Z-Z'|.$$
The result follows.
\end{proof}

\begin{remark}
    The sense in which $\rho'$ is close to $\rho$ depends on details of surrogate models, out
    of distribution, that we do not get into in these notes. In particular the approximation
    theorems we allude to in Section \ref{sec:AP} are valid, in their simplest form, over compact sets $D$;
    in contrast, the prior distribution here is supported on the whole Euclidean space. However, by making 
    assumptions about the behaviour of $\Psi$ and $\Psi^a$ at infinity, which controls errors
    outside $D$, and by choosing $D$ large enough, it is possible to deduce that
    $\rho'$ is close to $\rho$.
\end{remark}


\subsection{3DVar}


Consider the filtering problem of estimating  signal 
$\{v_j\}_{j\geq 0}$ given observations $\{y_j\}_{j\geq 1}$ in the setting where the dynamics-observation models \eqref{eq:sdm}, \eqref{eq:dm} reduce to
\begin{align*}
    \vd_{j+1} &= \Psi(\vd_j),\\
    \yd_{j+1} &= H \vd_{j+1} + \etad_{j+1}.
\end{align*}
We make the same assumptions on the noise and initial conditions as detailed
at the start of Chapter \ref{lecture7}.
We are interested in applications where evaluating $\Psi$ is computationally expensive, but where we have a surrogate, i.e., an approximate model $\Psi^a$ that can be cheaply evaluated. The theorem below proves long-time accuracy for a filtering algorithm that uses the surrogate dynamics $\Psi^a$ rather than the true dynamics $\Psi$.




The following theorem proves long-time accuracy for a 3DVar filtering algorithm that uses the surrogate dynamics $\Psi^a$ rather than the true dynamics $\Psi$. The result relies on standard observability conditions on the true dynamics and observation model $(\Psi, H)$ and on accuracy of the surrogate model $\Psi^a$ in the unobserved part of the state-space. Such a result may have some interest because we do not assume long-time accuracy or stability of the surrogate dynamics, but we can nevertheless obtain long-time accuracy of filtering estimates by leveraging the observations $\{\yd_j\}_{j\geq 1}$.

\begin{theorem}
Let Assumption~\ref{as:true-model} hold and let $K$ be a gain matrix appearing in the mean update of the 3DVar method with a surrogate forecast model $\Psi^a$. That is, 
$$m_{j+1} = (I - KH)\Psi^{a}(m_j) + K\yd_{j+1}.$$ 
Assume there exists constants $\lambda \in (0,1)$ and $\delta < \infty$ so that 
\begin{align*}
    \sup_{v \in \R^{\du}} |(I - KH)D\Psi(v)| &\leq \lambda,\\
    \sup_{v \in \R^{\du}} \bigl|(I - KH)\bigl(\Psi(v) - \Psi^{a}(v)\bigr)\bigr| &= \delta,
\end{align*}
and denote 
$$\epsilon = \mathbb{E}|K\eta_j|.$$
Then, the 3DVar estimate based on the biased forecast model 
satisfies
$$\lim\sup_{j \rightarrow \infty} \mathbb{E}|m_j - v_j^\dagger| = \frac{\epsilon + \delta}{1 - \lambda}.$$
\end{theorem}
\begin{proof}
This is simply Theorem~\ref{t:ques}.
\end{proof}


\section{Multifidelity Ensemble State Estimation}\label{sec:mf}\index{multifidelity}

In this section we assume that we have an ensemble of traditional numerical solvers, but want to reduce the error variance in state estimation given an ensemble of ML forecasts. In particular, learned forecast models often have lower computational cost than numerical ones, but may be less accurate. Even if they are less accurate, the forecasts from the learned forecast models can often be used to improve ensemble-based DA by increasing the ensemble size of the numerical model.

However, when the models have different accuracy, they must be treated differently in the DA process. We consider the numerical model to be the computationally expensive, high-fidelity model, and the (possibly multiple) learned forecast models to be the computationally cheap, low-fidelity models. Multi-model and multifidelity\index{multifidelity} methods can be applied in this context; we discuss two such methods below. The first is the multi-model EnKF, which makes the statistical assumption that all the models are unbiased. The second is an EnKF based on multifidelity Monte Carlo, which does not assume unbiasedness, but maintains unbiasedness with respect to the high-fidelity model.
Our discussion includes analysis of how to pick the ensemble sizes optimally, balancing cost and accuracy within a given computational budget.

\subsection{Multi-Model (Ensemble) Kalman Filters}\index{Kalman filter!multi-model}\index{Kalman filter!multi-model ensemble}
\label{ssec:mmenkf}


\subsubsection{Linear Gaussian Setting}

We work in the setting where the dynamics-observations models
\eqref{eq:sdm} and \eqref{eq:dm} are linear and Gaussian and
take the form
\begin{subequations}
\label{eq:mmod}    
\begin{align}
    \vd_{j+1} &= A\vd_j+\xid_j,\\
\yd_{j+1} &= H \vd_{j+1} + \etad_{j+1}.
\end{align}
\end{subequations}
We again make the same assumptions on the noise and initial conditions as detailed
at the start of Chapter \ref{lecture7}.
We introduce projection matrices $G_l:\R^{\du} \mapsto \R^{d_l}.$
If we assume there is $A_l$ such that $G_l A=A_l G_l$, and define $\Sigma_l=G_l \Sigma G_l^\top$, 
then we obtain
\begin{equation}
    G_l \vd_{j+1} = A_l G_l \vd_j + \varepsilon_{l,j},
\end{equation}
where $\varepsilon_{l,j} \sim \cN(0,\Sigma_l).$
If we define $\vd_{l,j}=G_l \vd_{j}$ then we have
\begin{equation}
\label{eq:mmod2} 
    \vd_{l,j+1} = A_l \vd_{l,j} + \varepsilon_{l,j}.
\end{equation}

We may now ask how we can use the multiple models \eqref{eq:mmod2} to develop a Kalman filter
for \eqref{eq:mmod}. An answer is given by the \emph{multi-model Kalman filter}\index{Kalman filter!multi-model} which is defined as follows:
\begin{subequations}\label{eq:mmkf}
\begin{align}
\hat{v}_{l,j+1} &= A_l v_{l,j},\\
\hat{C}_{l,j+1} &= A_l C_{l,j} A_l^\top + \Sigma_l,\\
C_{j+1} &= \left(\sum_{l=1}^L G_l^\top \hat{C}_{l,j+1}^{-1}G_l + H^\top \Gamma^{-1} H\right)^{-1},\label{eq:mmkf_cov}\\
v_{j+1} &= C_{j+1}\left(\sum_{l=1}^L G_l^\top \hat{C}_{l,j+1}^{-1}\hat{v}_{l,j+1} + H^\top\Gamma^{-1}\yd_{j+1}\right),\\
v_{l,j+1} &= G_l v_{j+1},\\
C_{l,j+1} &= G_l C_{j+1}G_l^\top.
\end{align}
\end{subequations}

It can be readily seen from \eqref{eq:mmkf_cov} that if $G_l$ is injective and $\hat{C}_{l,j+1}$ is positive definite, then model $l$ decreases the covariance of the multi-model analysis $v_{j+1}$.
The multi-model Kalman filter can be derived in a Bayesian way, or as the best linear unbiased estimator (BLUE)\index{best linear unbiased estimator} for multiple models.
Indeed, following the latter route, the analysis step of the MM-KF follows from the following theorem.

\begin{theorem}
Assume that $\{{\hat{v}}_l\}_{l=1}^L$ are defined from $\vd\in\Ru$ by the identities
\begin{equation*}
{\hat{v}}_l = {G}_l {\vd} + e_l,
\end{equation*}
where $\mathbb{E}[{e}_l] = {0}$, $\mathbb{E}[{e}_l{e}_l^\top] = C_l$, and $\mathbb{E}[{e}_l{e}_{l'}^\top] = {0}$ when $l\neq l'$.

These estimates may be combined to obtain the minimum variance linear unbiased estimator of $\vd$, which is given by
\begin{equation*}
\hat{v} = \sum_{l=1}^{L} {B}_l \hat{v}_l,
\end{equation*}
where
\begin{equation*}
{B}_l = \left(\sum_{l'=1}^L {G}_{l'}^\top {C}_{l'}^{-1} {G}_{l'}\right)^{-1} {G}_l^\top {C}_l^{-1}.
\end{equation*}
\end{theorem}
\begin{proof}
Note that we are seeking the BLUE estimator for a linear inverse problem 
$$ y = \bar{G} {v}^\dagger + e,$$
where $y = (\hat{v}_1, \ldots, \hat{v}_L) \in \R^{dL},$ $e = (e_1, \ldots, e_L)$, the covariance of $e$ is $\bar{C}$, and
\begin{equation*}
\overline{C} = \begin{pmatrix}
{C}_1 & & \\
& \ddots & \\
& & {C}_L
\end{pmatrix}, \qquad {\overline{G}} = \begin{pmatrix}
{G}_1\\
\vdots\\
{G}_L
\end{pmatrix}.
\end{equation*}
By the Gauss--Markov theorem\index{Gauss--Markov theorem}, the solution is given by the OLS estimator $$(\bar{G}^\top \bar{C}^{-1} \bar{G})^{-1} \bar{G}^\top \bar{C}^{-1} y,$$
which agrees with the desired expression.



\end{proof}

\subsubsection{Nonlinear Non-Gaussian Setting}

We now generalize \eqref{eq:mmod}, \eqref{eq:mmod2} to the nonlinear and non-Gaussian setting,
assuming that
\begin{subequations}
\label{eq:mmod3}    
\begin{align}
    \vd_{j+1} &= \Psi(\vd_j)+\xid_j,\\
\yd_{j+1} &= H \vd_{j+1} + \etad_{j+1},
\end{align}
\end{subequations}
and that we have multiple nonlinear forward
models $\{\Psi_l\}_{l=1}^L$ so that
\begin{equation}
\label{eq:mmod4} 
    \vd_{l,j+1} = \Psi_l(\vd_{l,j}) + \varepsilon_{l,j},
\end{equation}
where $\vd_{l,j}=G_l \vd_{j}$.
We  make the same assumptions on the noise and initial conditions as in the linear Gaussian case.



Similar to the single-model EnKF, if instead of linear models $A_l$ we have nonlinear models $\Psi_l$, we can formally replace the forecast step involving linear models with the nonlinear ones:
\begin{align}
\widehat{v}_{l,j+1}^{(\sam)} &= \Psi_l(v_{l,j}^{(\sam)})+\xi^{(\sam)}_{l,j}, \quad \sam=1,\ldots,\Sam_l,
\end{align}
and replace the means and covariance matrices in \eqref{eq:mmkf} with their empirical versions estimated from the ensembles.

The equations \eqref{eq:mmkf} can also be written in an iterative form, in which the analysis step of the single-model Kalman filter\index{Kalman filter} is repeatedly applied to each new model forecast. Other multi-model Kalman filters can then be obtained by replacing the Kalman filter analysis step with one of its variants, such as the EnKF\index{Kalman filter!ensemble}. The multi-model EnKF (MM-EnKF) can also make use of nonlinear $G_l$ and $H$. We will not state the details, but point the reader to the Bibliography for further information.


\subsection{Multifidelity Monte Carlo}\index{Monte Carlo!multifidelity}

Here we work in the setting of the preceding Subsection \ref{ssec:mmenkf}, in the
nonlinear non-Gaussian context. An alternative approach to what is presented in the
previous subsection is one based on control variates. This does not make the assumption 
of unbiasedness, but does require a known hierarchy of fidelities.

The idea of multifidelity Monte Carlo methods comes from the concept of \emph{control variates}, a way of reducing the variance in Monte Carlo estimates. The basic idea is to use a correlated random variable, which may have a different expectation, to reduce the variance in the primary.

Suppose again that we have $L$ low-fidelity models $\{\Psi_l\}_{l=1}^L$.\footnote{For notational simplicity, we do not write a $\Sigma_l$ for each model. However, the results in this subsection apply equally well if $\Psi_l$ is considered to be the stochastic function $\Psi'_l(v) = \Psi_l(v) + \xi$, where $\xi\sim\mathcal{N}(0, \Sigma_l)$.} Assume that $\Psi_\text{hi}$ is the high-fidelity model (corresponding to $l=0$), with respect to which we would like to be unbiased. Assume furthermore that the ensemble sizes for each model are arranged such that $0 < N_\text{hi}\leq N_1\leq \ldots\leq N_L$. We deal with the scalar case for simplicity, and also recall that we are working in the linear observation setting where $h(\cdot) = H\cdot$.

Let $\{v^{(n)}\}_{n=1}^{N_L}$ be i.i.d. samples from density $\Upsilon$. Then compute the following ensemble means:
\begin{align*}
    &\hat{m}_\text{hi} = \frac{1}{N_\text{hi}} \sum_{n=1}^{N_\text{hi}} \Psi_\text{hi}(v^{(n)}),&&\hat{m}_l = \frac{1}{N_l} \sum_{n=1}^{N_l} \Psi_l(v^{(n)}),\\
    &\hat{m}_l' = \frac{1}{N_{l-1}} \sum_{n=1}^{N_{l-1}} \Psi_l(v^{(n)}).
\end{align*}

Then we consider a multifidelity estimator given by
\begin{align}\label{eq:mfmc}
    \hat{m} &= \hat{m}_\text{hi} + \sum_{l=1}^L \alpha_l (\hat{m}_l - \hat{m}'_l),\\
    \alpha_l &= \frac{\rho_l \sigma_\mathrm{hi}}{\sigma_l},
\end{align}
where $\rho_l$ is the correlation coefficient between $\Psi_\mathrm{hi}$ and $\Psi_l$, and $\sigma_l^2$, $\sigma_\mathrm{hi}^2$ are the variances of $\Psi_l$ and $\Psi_\mathrm{hi}$, respectively.

\begin{theorem}
    The estimator $\hat{m}$ is unbiased for $\mathbb{E}^{v \sim \Upsilon}\bigl[\Psi_\mathrm{hi}(v)\bigr]$  and has variance
    \begin{equation}\label{eq:mfmc_var}
        \mathrm{Var}[\hat{m}] = \frac{\sigma^2_\mathrm{hi}}{N_\mathrm{hi}} + \sum_{l=1}^L \left(N_{l-1}^{-1} - N_l^{-1}\right)(\alpha_l^2\sigma_l^2 - 2\alpha_l\rho_l\sigma_\mathrm{hi}\sigma_l).
    \end{equation}
    The variance $\mathrm{Var}[\hat{m}]$ is minimized when
    \begin{equation*}
        \alpha_l = \frac{\rho_l \sigma_\mathrm{hi}}{\sigma_l}.
    \end{equation*}
\end{theorem}
\begin{proof}
    Note that expectation here is with respect to $\Upsilon,$ the distribution of the samples $\{v^{(n)}\}_{n=1}^{N_L}$. The fact that $\mathbb{E}[\hat{m}] = \mathbb{E}[\hat{m}_\text{hi}] = \mathbb{E}[\Psi_\text{hi}]$ is immediate from the linearity of expectation.

    Then,
    \begin{align*}
        \mathrm{Var}[\hat{m}] &= \mathrm{Var}[\hat{m}_\text{hi}] + \sum_{l=1}^L \alpha_l^2 (\mathrm{Var}[\hat{m}_l] + \mathrm{Var}[\hat{m}'_l])\\
        &\qquad+ 2\sum_{l=1}^L \alpha_l (\mathrm{Cov}[\hat{m}_\text{hi}, \hat{m}_l] - \mathrm{Cov}[\hat{m}_\text{hi}, \hat{m}'_l])\\
        &\qquad + 2\sum_{l=1}^L \alpha_l \sum_{j=l+1}^L \alpha_j (\mathrm{Cov}[\hat{m}_l, \hat{m}_j] - \mathrm{Cov}[\hat{m}_l, \hat{m}'_j])\\
        &\qquad - 2\sum_{l=1}^L \alpha_l \sum_{j=l+1}^L \alpha_j (\mathrm{Cov}[\hat{m}'_l, \hat{m}_j] - \mathrm{Cov}[\hat{m}'_l, \hat{m}'_j])\\
        &\qquad - 2\sum_{l=1}^L\alpha_l^2\mathrm{Cov}[\hat{m}_l,\hat{m}'_l].
    \end{align*}
    Lines 3 and 4 cancel. Using the definitions of the correlation coefficients and variances, and the fact that the variance of a mean of $N$ independent random variables decreases as $1/N$, we obtain
    \begin{equation*}
        \mathrm{Var}[\hat{m}] = \frac{\sigma^2_\mathrm{hi}}{N_\mathrm{hi}} + \sum_{l=1}^L \left(N_{l-1}^{-1} - N_l^{-1}\right)(\alpha_l^2\sigma_l^2 - 2\alpha_l\rho_l\sigma_\mathrm{hi}\sigma_l).
    \end{equation*} 
    Taking the derivative of $\mathrm{Var}[\hat{m}]$ with respect to $\alpha_l$ and setting it to 0 gives the stated expression for $\alpha_l$.
\end{proof}

If  $\{\sigma_l\}_{l=1}^L$, $\sigma_\text{hi}$, and $\{\rho_l\}_{l=1}^L$ are not known, they can be estimated from the ensembles. This suggests the procedure outlined in Algorithm~\ref{alg:mf_enkf}.
\begin{algorithm}[!h]
\caption{\label{alg:mf_enkf}Ensemble Kalman filter\index{Kalman filter!ensemble} using multifidelity \index{Monte Carlo}Monte Carlo}
\begin{algorithmic}[1]
\STATE {\bf Input}:  Initialization $(v_0, C_0).$
\FOR{$j=1,\dots,J$}
\STATE Sample $\{v^{(n)}_j\}_{n=1}^{N_M}\sim\mathcal{N}(m_{j-1}, C_{j-1})$.
\STATE Evaluate the models at the $v^{(n)}_j$ and compute the means $m_{\mathrm{hi},j}$, $m_{l, j}$ and $m'_{l, j}$ for $l=1,\ldots,L$.
\STATE Estimate $\sigma_{\text{hi},j}$, $\{\sigma_{l,j}\}_{l=1}^L$, and $\{\rho_{l,j}\}_{l=1}^L$ from the ensembles.
\STATE Compute the multifidelity Monte Carlo estimate of the mean $\hat{m}_j$ \eqref{eq:mfmc} and its associated variance $\mathrm{Var}[\hat{m}_j]$ \eqref{eq:mfmc_var}. Then, estimate the forecast covariance $\hat{C}_j'$ from the ensembles, and set
\begin{equation*}
    \hat{C}_j = \hat{C}_j' + \mathrm{Var}[\hat{m}_j].
\end{equation*}\label{mf_enkf_cov}
See the remark below on the computation of $\hat{C}_j'$.
\STATE Assimilate observations, updating the mean and covariance: 
\begin{subequations}
\begin{align*}
m_j &= \hat{m}_j + K_j(\yd_j - H\hat{m}_{j}),\\
C_j &= (I - K_jH)\hat{C}_j,\\
K_j &= \hat{C}_j H^\top(H\hat{C}_j H^\top + \Gamma)^{-1}.
\end{align*}
\end{subequations}
\ENDFOR
\STATE{\bf Output}: $(v_J, C_J).$
\end{algorithmic}
\end{algorithm}
\begin{remark}
    We have thus far discussed multifidelity estimation of the mean of a distribution. In step \ref{mf_enkf_cov} of Algorithm \ref{alg:mf_enkf}, the forecast covariance $\hat{C}_j'$ can itself be estimated using a multifidelity method, as discussed further in Section \ref{sec:mf_cov} and in the bibliography. Alternatively, this covariance can be estimated from the ensemble of one of the fidelity levels.
\end{remark}

\subsection{Model Selection and Sample Allocation}

For a fixed computational budget, we would like to find the allocation of ensemble sizes $\{N_l\}_{l=1}^L$ that minimizes the variance while staying within the budget. This is called the \emph{model selection and sampling allocation problem} (MOSAP).

We apply this idea to the multifidelity Monte Carlo estimator \eqref{eq:mfmc}. Assume the cost of a single run of model $l$ is $c_l$, and we have a fixed computational budget $b$. We would like to minimize the variance \eqref{eq:mfmc_var} under this constraint, leading to
\begin{align*}
    &\min_{\{N_l\}_{l=0}^L} \frac{\sigma^2_\mathrm{hi}}{N_\mathrm{hi}} + \sum_{l=1}^L \left(N_{l-1}^{-1} - N_l^{-1}\right)(\alpha_l^2\sigma_l^2 - 2\alpha_l\rho_l\sigma_\mathrm{hi}\sigma_l)\\
    &\text{subject to }\sum_{l=1}^L c_l N_l = b, \,\,N_{l-1} \leq N_l.
\end{align*}
This is an integer programming problem. Similar analyses can be carried out for other multifidelity methods.


\section{Multifidelity Covariance Estimation}\label{sec:mf_cov}

Thus far, we have discussed multifidelity methods for improving state estimates. Within ensemble DA, due to the effect of sampling error, it is also of interest to improve estimates of forecast covariance matrices, and to possibly mitigate the need for localization and inflation as discussed in Subsections \ref{sec:localization} and \ref{sec:inflation}. This can be done by using a large ML ensemble to improve the estimated covariance produced by a small numerical ensemble. Alternatively, an ML model can be trained to predict the covariance directly.

Consider having access to multiple unbiased estimators $\{\hat{C}_l\}_{l=1}^L$ of a covariance matrix $\hat{C}$, and taking a scalar linear combination of these estimators:
\begin{equation}\label{eq:comb_cov}
     \sum_{l=1}^L c_l \hat{C}_l,
\end{equation}
If each of the $\hat{C}_l$ is symmetric positive definite, then the linear combination will be too. Under Gaussian assumptions on these estimators, the following theorem gives the improvement in the covariance estimate.
\begin{theorem}\label{th:multifidelity}
    Suppose that we have $L$ independent estimators of the true covariance $\hat{C}$, $\{\hat{C}_l\}_{l=1}^L$. Assume furthermore that they are all unbiased, and are distributed according to $\hat{C}_l\sim\mathcal{N}(\hat{C}, U_l, V_l)$, the matrix normal distribution (note that we do not make use of the fact that $\hat{C}_l$ will generally be positive semidefinite).

    Consider a linear combination of $\hat{C}_l$ with scalar weights,
    \begin{equation*}
        \sum_{l=1}^L c_l \hat{C}_l,
    \end{equation*}
    such that $\sum_{l=1}^L c_l = 1$ (this is necessary for the combination to be unbiased).

    Then, the $\{c_l\}_{l=1}^L$ that minimize the total variance of $\sum_{l=1}^L c_l \hat{C}_l$ are
    \begin{equation}
        c_l = \frac{e_l^{-1}}{\sum_{j=1}^L e_j^{-1}},
    \end{equation}
    where $e_l = \mathbb{E} \Bigl[|\hat{C}_l - \hat{C}|_F^2 \Bigr]$ and $|\cdot|_F$ is the Frobenius norm. The total variance is then
    \begin{equation}
        \left(\sum_{l=1}^L e_l^{-1}\right)^{-1}.
    \end{equation}
\end{theorem}
\begin{proof}
In squared Frobenius norm, $\hat{C}_l$ has an expected error of 
\begin{align*}
    e_l &= \mathbb{E} \Bigl[|\hat{C}_l - \hat{C}|_F^2 \Bigr]\\
    &= \mathbb{E} \Bigl[\Tr \Bigl((\hat{C}_l - \hat{C})^\top(\hat{C}_l - \hat{C}) \Bigr) \Bigr]\\
    &= \Tr \Bigl(\mathbb{E} \Bigl[(\hat{C}_l - \hat{C})^\top(\hat{C}_l - \hat{C}) \Bigr] \Bigr)\\
    &= \Tr(U_l)\Tr(V_l),
\end{align*}
where the last line follows from a property of the matrix normal distribution. 

Then, for the linear combination \eqref{eq:comb_cov},
\begin{align*}
    \text{vec}\left(\sum_{l=1}^L c_l \hat{C}_l \right) \sim \cN\left(\text{vec}\left(\sum_{l=1}^L c_l \hat{C}\right), \sum_{l=1}^L c_l^2(V_l \otimes U_l)\right) = \cN\left(\text{vec}(\hat{C}), \sum_{l=1}^L c_l^2(V_l \otimes U_l)\right),
\end{align*}
where $\otimes$ is the Kronecker product. Now, the total variance is
\begin{align}
     \Tr\left(\sum_{l=1}^L c_l^2(V_l \otimes U_l)\right) &= \sum_{l=1}^L c_l^2\Tr(V_l \otimes U_l) = \sum_{l=1}^L c_l^2\Tr(U_l)\Tr(V_l) = \sum_{l=1}^L c_l^2 e_l.\label{eq:total_var}
\end{align}
Minimizing \eqref{eq:total_var} with respect to the $c_l$ and using Lagrange multipliers to enforce $\sum_{l=1}^L c_l = 1$, we obtain
\begin{equation*}
    c_l = \frac{e_l^{-1}}{\sum_{j=1}^L e_j^{-1}}.
\end{equation*}
Note that the $c_l$ are positive. The total variance becomes
\begin{equation*}
    \left(\sum_{l=1}^L e_l^{-1}\right)^{-1}.
\end{equation*}
\end{proof}

\begin{remark}
    Note that if the $\hat{C}_l$ are sample covariance matrices from an ensemble, and the ensemble members are normally distributed, the $\hat{C}_l$ will have a Wishart distribution. In the large-ensemble limit the Wishart sampling distribution tends towards a matrix normal distribution.
\end{remark}

The bibliography points to some multifidelity covariance estimators that do not require the assumption of unbiasedness.

\section{Bibliography}\label{sec:bibliographylearnedforecastDA}
Machine learning models for numerical weather forecasting have recently received significant attention, see e.g. \cite{pathak2022fourcastnet,Bi2023,keisler2022forecasting,chen2023fuxi,chen2023fengwu,lam2022graphcast}. 
Data assimilation using learned forecast models has been considered in \cite{hamilton_ensemble_2016,lguensat_analog_2017,chen_bamcafe_2021,chattopadhyay2022towards,penny_integrating_2022,xiao_fengwu-4dvar_2023,adrian2024data,kotsuki_integrating_2024}. The importance of these forecast models correctly reproducing the Lyapunov spectrum and forecast error covariance was explored in \cite{penny_integrating_2022}. Including the Lyapunov spectrum and attractor dimension into the training process was explored in \cite{platt_constraining_2023}. Instead of learning a full forward model, learning an adjoint model for use in 4DVar\index{4DVar} was considered in \cite{hatfield_building_2021}.

Hybrid methods combining a numerical and learned forecast model in data assimilation and ensemble forecasting have been considered in \cite{bach_ensemble_2021,bach_improved_2024,chattopadhyay_deep_2023}. The latter used a large ensemble of a learned forecast model, along with a smaller ensemble of a more expensive numerical model solving the equations of motion, in an EnKF\index{Kalman filter!ensemble}, mitigating the need for localization.
Combining a small high-fidelity ensemble with a large ensemble of reduced-order models in an EnKF using control variates was considered in \cite{popov_multifidelity_2021}. A multilevel EnKF was introduced in \cite{hoel_multilevel_2016}.

The multi-model Kalman filter\index{Kalman filter!multi-model} was introduced in \cite{narayan_sequential_2012}, with a Bayesian derivation in the latter, and a best linear unbiased estimator (BLUE)\index{best linear unbiased estimator} derivation provided in \cite{bach_multi-model_2023}. The multi-model EnKF\index{Kalman filter!multi-model ensemble} was introduced in \cite{bach_multi-model_2023}.
Additionally, there have been ML methods for learning to combine multiple model forecasts \cite{thorey_online_2017,harris_multimodel_2023}. These have not been used with data assimilation to our knowledge.

Performing data assimilation in the latent space of an autoencoder\index{autoencoder} (Section \ref{sec:auto}) or variational autoencoder\index{autoencoder!variational} (Section \ref{sec:vauto}) has been considered in \cite{peyron_latent_2021,melinc_3d-var_2024,glyn-davies_phi-dvae_2022}.

The generation of ensembles from an ML forecast model was considered in \cite{scher_ensemble_2021,li_seeds_2023,price_gencast_2023}. 

A survey of multifidelity methods is presented in \cite{peherstorfer_survey_2018}. The multifidelity Monte Carlo estimator discussed in this chapter was introduced in \cite{peherstorfer_optimal_2016}, including the optimal ensemble sizes for each model balancing computational cost and accuracy. We refer to \cite{gupta2018matrix} for background on the matrix normal distribution and its properties. A framework for analyzing different multifidelity estimators and finding the multi-level best linear unbiased estimator (MLBLUE) is presented in \cite{schaden_multilevel_2020}, and later generalized to a multivariate setting in \cite{croci_multi-output_2023}. Multifidelity estimation of covariance matrices was considered in \cite{destouches_multivariate_2023,maurais_multi-fidelity_2023,maurais_multifidelity_2023}.

The relation between the matrix normal distribution and the Wishart distribution is discussed in \cite{nel_symmetric_1978}.

\chapter{\Large{\sffamily{Metrics, Divergences and Scoring Rules}}}
\label{ch:distances}

In this chapter we define various ``distance-like'' ways to quantify closeness between probability measures.
We work with probability measures on $\Ru$, denoted $\cP(\Ru).$ We also discuss scoring rules which quantify
closeness of a probability measure to a point, and deterministic scoring rules, between two points.
To be consistent with the rest of the notes, the presentation focuses on probability density functions; but the definitions all work for general probability distributions. Indeed we will, in several instances, employ Dirac masses. Generically we compare two probability density functions $\postr$ and $\postv$; we denote the cumulative density functions associated with these two
probability density functions by $\Fr$ and $\Fv$. We start with metrics in Section \ref{sec:metric}; we continue by discussing divergences in Section \ref{sec:div}; and finally we discuss scoring rules in Section \ref{sec:psr}. Throughout the chapter we will make connections between metrics, divergences and scoring rules, as summarized in Figure~\ref{fig:nesting_distances}.

Our motivation for studying this topic is twofold. 
Some metrics and divergences are useful to present theoretical results about inverse problems and data assimilation. Others are useful for defining loss functions for probabilistic machine learning models based on data, which is important for designing machine learning algorithms and assessing their performance. For example, the Hellinger metric\index{metric!Hellinger} 
is useful for stating stability results for measures; see, for
example, Theorems \ref{t:wpz} and \ref{thm1L}. On the
other hand, the energy distance\index{distance!energy} is a metric that is used as a loss function for tasks such as learning probabilistic filters; see, for example, Section \ref{sec:filtering_map}. 
As well as being useful for stating theoretical results, 
the Kullback--Leibler\index{divergence!Kullback--Leibler} divergence is
useful for defining loss functions in machine learning;
see Chapter \ref{ch:transport}. Scoring rules have been used traditionally for evaluating probabilistic forecasts against samples and hold potential to define objectives for machine learning tasks. 

\begin{figure}
\centering
\begin{tikzpicture}
    \draw [thick, fill=gray!50] (0,-0.5) arc (-90:270:3cm and 2cm);
    \draw [thick, fill=gray!80] (0,0) arc (-90:270:2cm and 1cm);
    \draw [thick, fill=gray!10, opacity=0.4] (4,-0.5) arc (-90:270:3cm and 2cm);
    \node [yshift=1cm] (0,0) {Metrics};
    \node [yshift=2.5cm] (0,0) {Divergences};
    \node [xshift=5cm, yshift=1.5cm, text width=2.4cm] (0,0) {Expected scoring rules};
\end{tikzpicture}
\caption{Diagram representing the constraints of three groups of distance-like ways to quantify closeness between probability measures. Metrics impose more restrictive conditions than divergences: only some divergences are metrics. Furthermore a subset of expected scoring rules, those based on strictly proper rules lead to divergences,
and in some cases to metrics. We provide concrete examples of such scoring rules in the following sections. \label{fig:nesting_distances}} 
\end{figure}

\section{Metrics}\index{metric}
\label{sec:metric}

\subsection{Metrics on the Space of Probability Measures}\label{ssec:metrics_measures}

A metric between probability distributions is a function $\D\colon \cP(\Ru) \times \cP(\Ru) \rightarrow \mathbb{R}$ that satisfies the following four properties for all $\postr,\postv \in \cP(\Ru)$: 
\begin{enumerate} \itemsep0pt
    \item Non-negative: $\D(\postr,\postv) \geq 0.$
    \item Positive: $\D(\postr,\postv) = 0$ if and only if $\postr = \postv.$
    \item Symmetric: $\D(\postr,\postv) = \D(\postv, \postr).$
    \item Sub-additive or triangle inequality: $\D(\postr,\postv) \leq \D(\postr,\post) + \D(\post,\postv)$ for all $\pi \in \cP(\Ru).$
\end{enumerate}

\subsection{Total Variation and Hellinger Metrics}

\begin{definition}\label{def:hellinger}
The \index{distance!total variation} \emph{total variation distance} between two probability density functions $\postr$ and $\postv$ is defined by\footnote{Here the integrals are over $\Ru$. For simplicity, in this chapter we do not write the domain of integration when it is clear by context.} 
\[\dtv (\postr,\postv)\coloneqq\frac{1}{2}\int|\postr(u)-\postv(u)| \, du=\frac{1}{2}\|\postr-\postv\|_{L^1}.\]
The \index{distance!Hellinger}\emph{Hellinger distance} between two probability density functions $\postr$ and $\postv$ is defined by
\[\dhell(\postr,\postv)\coloneqq\biggl(\frac{1}{2}\int \Bigl|\sqrt{\postr(u)}-\sqrt{\postv(u)}\Bigr|^2 \, du\biggr)^{1/2}=\frac{1}{\sqrt{2}}\|\sqrt{\postr}-\sqrt{\postv}\|_{L^2}.\]
\end{definition}



We now establish bounds between the \index{distance!Hellinger}Hellinger and \index{distance!total variation}total variation distance.


      \begin{lemma} \label{l:dh1}
For any probability density functions $\postr$ and $\postv$: 
\begin{itemize}
\item The total variation and Hellinger metrics are uniformly bounded; indeed
\[0\leq \dtv(\postr,\postv)\leq 1,\quad 0\leq \dhell(\postr,\postv)\leq 1;\]
\item The total variation and Hellinger metrics  bound one another; indeed
       \[\frac{1}{\sqrt{2}}\dtv(\postr,\postv)\leq \dhell(\postr,\postv)\leq \sqrt{\dtv(\postr,\postv)}.\]
       \end{itemize}
      \end{lemma}
      
      \begin{proof} For part (i) we note that the lower bounds follow immediately from the 
definitions, so we only need to prove the upper bounds. For \index{distance!total variation}total variation distance 
      \[\dtv(\postr,\postv)=\frac{1}{2}\int|\postr(u)-\postv(u)| \, du\leq \frac{1}{2}\int\postr(u) \, du+\frac{1}{2}\int\postv(u) \, du=1, \]
      and for \index{distance!Hellinger}Hellinger distance
      \begin{align*}
      \dhell(\postr,\postv)=&\ \biggl(\frac{1}{2}\int \Bigl|\sqrt{\postr(u)}-\sqrt{\postv(u)}\Bigr|^2 \, du\biggr)^{1/2}\\
      =&\ \bigg(\frac{1}{2}\int\Big(\postr(u)+\postv(u)-2\sqrt{\postr(u)\postv(u)}\,\, \Big) \, du \bigg)^{1/2}\\
      \leq&\ \biggl(\frac{1}{2}\int\big(\postr(u)+\postv(u)\big) \, du\biggr)^{1/2}\\
      =&\ 1.\end{align*}

For part (ii) we use the \index{Cauchy--Schwarz inequality}Cauchy-–Schwarz inequality 
      \begin{align*}
      \dtv(\postr,\postv)=&\ \frac{1}{2}\int\Big|\sqrt{\postr(u)}-\sqrt{\postv(u)}\Big|\Big|\sqrt{\postr(u)}+\sqrt{\postv(u)}\Big| \, du\\
      \leq&\ \biggl(\frac{1}{2}\int\Big|\sqrt{\postr(u)}-\sqrt{\postv(u)}\Big|^2 \, du\biggr)^{1/2}\biggl(\frac{1}{2}\int\Big|\sqrt{\postr(u)}+\sqrt{\postv(u)}\Big|^2 \, du\biggr)^{1/2}\\
      \leq&\ \dhell(\postr,\postv)\biggl(\frac{1}{2}\int\big(2\postr(u)+2\postv(u)\big) \, du\biggr)^{1/2}\\
      =&\ \sqrt{2}\dhell(\postr,\postv).
      \end{align*}
      Notice that $|\sqrt{\postr(u)}-\sqrt{\postv(u)}|\leq |\sqrt{\postr(u)}+\sqrt{\postv(u)}|$ since $\sqrt{\postr(u)},\sqrt{\postv(u)}\geq0$. Thus we have
      \begin{align*}
      \dhell(\postr,\postv)=&\ \biggl(\frac{1}{2}\int\Big|\sqrt{\postr(u)}-\sqrt{\postv(u)}\Big|^2 \, du\biggr)^{1/2}\\
      \leq&\ \biggl(\frac{1}{2}\int\Big|\sqrt{\postr(u)}-\sqrt{\postv(u)}\Big|\Big|\sqrt{\postr(u)}+\sqrt{\postv(u)}\Big| \, du\biggr)^{1/2}\\
      \leq&\ \biggl(\frac{1}{2}\int\big|\postr(u)-\postv(u)\big| \, du\biggr)^{1/2}\\
      =&\ \sqrt{\dtv(\postr,\postv)}.
      \end{align*}
      \end{proof}

\begin{remark}
    The preceding proof may be extended to show that $\postr$ and $\postv$ have \index{distance!total variation}total variation and \index{distance!Hellinger}Hellinger distance equal to one if and only if 
    $\int \postr(u)\postv(u) \,  du=0$; that is, if and only if they have disjoint supports.
\end{remark}

In addition to relating closeness of densities to closeness of expectations with respect to
different densities, the following lemma also provides a useful characterization of the \index{distance!total variation}total variation distance. 

      \begin{lemma} \label{lemmatv} Let $f:\Ru \to \R.$ If two densities are close in \index{distance!total variation}total variation or in \index{distance!Hellinger}Hellinger distance, expectations computed with respect to both densities are also close. 
\begin{itemize}

\item (i) Let $f$ be a function such that $
|f|_\infty:=\sup_{u\in \Ru}|f(u)|<\infty.$ It holds that
      \[\bigl|\Expect^\postr[f]-\Expect^{\postv}[f]\bigr|\leq 2|f|_\infty \dtv(\postr,\postv).\]
In fact, the following \index{variational!characterization of total variation}variational characterization of the \index{distance!total variation}total variation distance holds:
\begin{equation} \label{eq:TV_VariationalCharacterization}
\dtv(\postr, \postv) = \frac12 \sup_{|f|_\infty \le 1} \bigl|\Expect^\postr[f]-\Expect^{\postv}[f]\bigr|.
\end{equation}

\item (ii)  Let $f$ be a function such that 
$f_2:=\bigl(\Expect^\rho[|f|^2]+\Expect^{\postv}[|f|^2]\bigr)^{1/2}< \infty$. It holds that
      \[\big|\Expect^\rho[f]-\Expect^{\postv}[f]\big|\leq 2 f_2 \dhell(\postr,\postv).\]
\end{itemize}
\end{lemma}

      \begin{proof}
      For part (i) we start by noting that
     	\begin{align*}
     	\bigl|\Expect^\postr[f]-\Expect^{\postv}[f]\bigr|=&\ \Big|\int f(u)\bigl(\postr(u)-\postv(u)\bigr) \, du\Big|\\
     	\leq&\ 2|f|_\infty\cdot\frac{1}{2}\int |\postr(u)-\postv(u)| \, du\\
     	=&\ 2|f|_\infty\dtv(\postr,\postv).
     	\end{align*}
For any $f$ with $|f|_\infty =1$ we obtain 
     	 $$\dtv(\postr, \postv) \ge \frac12 \big|\Expect^\postr[f]-\Expect^{\postv}[f]\big|.$$
     We complete the proof of part (i) by exhibiting a choice of $f$ with $|f|_\infty =1$ that achieves equality.	To this end we choose $f(u):= \text{sign} \Bigl( \postr(u)- \postv(u) \Bigr)$, so that $f(u) \Bigl( \postr(u)- \postv(u) \Bigr) = |\postr(u) - \postv(u)|.$ Then $|f|_\infty =1,$ and 
     	\begin{align*}
     	\dtv(\postr, \postv) &= \frac12 \int |\postr(u) - \postv(u)| \, du \\
     	&= \frac12 \int f(u) \Bigl( \postr(u) - \postv(u) \Bigr) \, du \\
     	& = \frac12 \bigl|\Expect^\postr[f]-\Expect^{\postv}[f]\bigr|.
     	\end{align*}
     	
      
      For part (ii) of the lemma we may use the \index{Cauchy--Schwarz inequality}Cauchy--Schwarz inequality 
      to show that
     	\begin{align*}
     	\bigl|\Expect^\postr[f]-\Expect^{\postv}[f]\bigr|=&\ \biggl|\int f(u)\Bigl(\sqrt{\postr(u)}-\sqrt{\postv(u)}\Bigr)\Bigl(\sqrt{\postr(u)}+\sqrt{\postv(u)} \, \Bigr) \,du\biggr|\\
     	\leq&\ \biggl(\frac{1}{2}\int \Big|\sqrt{\postr(u)}-\sqrt{\postv(u)}\Big|^2 \, du\biggr)^{1/2} \biggl(2\int|f(u)|^2\Big|\sqrt{\postr(u)}+\sqrt{\postv(u)}\Big|^2 \,du\biggr)^{1/2}\\
     	\le &\ \dhell(\postr,\postv)\Big(4\int|f(u)|^2\bigl(\postr(u)+\postv(u)\bigr) \, du\Big)^{1/2}\\
     	= &\ 2f_2 \,\dhell(\postr,\postv).
     	\end{align*}
      \end{proof}


\subsection{\index{transport!optimal} Transportation Metrics}\label{sec:OPT}


\subsubsection{Kantorovich Formulation}\index{optimal transport!Kantorovich}
Given two densities $\postr$ and $\postv$ on $\R^d$, we define a \index{coupling}{\em coupling} as a density $\pi$ on $\R^d \times \R^d$ with the property that
$$\int_{\R^d} \pi(z,u) \, du=\postr(z), \quad \int_{\R^{d}} \pi(z,u) \, dz=\postv(u).$$
Thus the marginals of $\pi$ deliver $\postr$ and $\postv$.
We denote the set of all such \index{coupling}couplings by $\Pi_{\postr,\postv}.$
Given a cost function $\co: \R^d \times \R^d \to \R^+$ we
define the Kantorovich formulation of the 
optimal transport \index{optimal transport!Kantorovich}
problem as follows:
\begin{align}
\label{eq:KOT}
\pist&={\rm arginf}_{\pi \in \Pi_{\postr,\postv}} 
\int_{\R^{d} \times \R^d} \co(z,u)\pi(z,u) \, dz du.
\end{align}

This notion of \index{optimal transport}optimal transport may be used to define
families of metrics on probability densities as follows.


\begin{definition}
  Given a metric $\dm(\cdot,\cdot)$ on $\R^d$ and $p \geq 1,$  the \emph{Wasserstein$-p$ distance\index{distance!Wasserstein}} between two probability density functions $\postr$ and $\postv$ is defined by 
  \begin{align}
\label{eq:WP}
W_{p}(\postr,\postv)&\coloneqq \biggl({\rm inf}_{\pi \in \Pi_{\postr,\postv}}
\int_{\R^{d} \times \R^d} \dm(z,u)^p\pi(z,u) \,dz du\biggr)^{1/p}.
\end{align}
\end{definition}
This metric on probability measures has two key aspects:
first, it relates the metric to an underlying metric on
$\R^d$; and second, it allows for a meaningful \index{distance}distance to
be calculated between measures which are mutually singular. 

\begin{example}
Let $\postr = \cN( \mu_\postr,\Sigma_\postr)$ and $\postv = \cN( \mu_\postv,\Sigma_\postv).$
It may be shown that, if the metric $\dm$ induced by the Euclidean
norm $|\cdot|$ is used, then
$$W_{2}(\postr,\postv)^2= |\mu_\postr-\mu_\postv |^2+{\rm Tr}\Bigl(\Sigma_\postr+\Sigma_\postv-
2\bigl(\Sigma_\postr^{\frac12}\Sigma_\postv \Sigma_\postr^{\frac12}\bigr)\Bigr).$$
In particular, if $\postv $ is a \index{Dirac delta}Dirac measure at the origin then
$$W_{2}(\postr,\postv)^2= | \mu_\postr |^2+{\rm Tr}\bigl(\Sigma_\postr\bigr).$$

Thus, in the \index{distance!Wasserstein}Wasserstein$-2$ metric \index{Gaussian}Gaussian $\postr$ is close to
a \index{Dirac delta}Dirac at the origin if the mean and covariance of $\postr$ are
both small. 
In contrast, the total variation 
distance\index{distance!total variation}
between Gaussian $\postr$ and a Dirac at the origin is maximal, and equal to $1$, 
unless the two measures coincide ($\mu_\postr=0, \Sigma_\postr=0$) when it is $0.$


Notice also that if $\postr$ and $\postv$ are \index{Dirac delta}Diracs at $\mu_\postr$ and $\mu_\postv$, then $W_2(\postr,\postv) = |\mu_\postr - \mu_\postv|;$ thus closeness of the mass locations $\mu_\postr$ and $\mu_\postv$ in Euclidean space translates into closeness of $\postr$ and $\postv$ in \index{distance!Wasserstein}Wasserstein distance. 
\end{example} 

\subsubsection{Monge Formulation}\index{optimal transport!Monge}
The connection of \index{optimal transport}optimal transport to explicit transport maps
is made clear in the Monge formulation of optimal 
transport\index{optimal transport!Monge}. In this formulation
we explicitly link $\postv$ with a pushforward\index{pushforward} of $\postr$ through a transport map\index{transport!map} $g$ by identifying the map which minimizes the cost:
\begin{align}
\label{eq:MOT}
\gs&={\rm arginf}_{g: g_\sharp \postr = \postv}
\int_{\R^{d}} \co\bigl(z,g(z)\bigr) \postr(z)\, dz.
\end{align}
Under certain smoothness assumptions, the Kantorovich formulation
has solution within the Monge class. That is, the optimal \index{coupling}coupling is
constructed using the pushforward\index{pushforward} of a transport map: 
\begin{equation} \label{eq:CouplingMap}
  \pist(z,u)=\delta\bigl(u-{\gs(z)}\bigr) \postr(z).  
\end{equation}

\begin{remark}
    For the Euclidean norm metric $\dm(z,u) = |z-u|$, and $\postr$ being absolutely continuous with respect to the Lebesgue measure (that is it has a probability density function), there exists an optimal transport coupling in~\eqref{eq:WP} solving the Kantorivich formulation of the Wasserstein-$p$ optimal transport problem. Moreover, this coupling has the form in~\eqref{eq:CouplingMap}, which is induced by an optimal transport map $g^\star$ solving the corresponding Monge problem \eqref{eq:MOT}. We note that for $p > 1$ the objective in~\eqref{eq:WP} is strictly convex, and so the optimal transport map that solves $W_p(\postr,\postv)$  is also unique; however this result does not extend to $p=1.$
\end{remark}

\subsubsection{One-Dimensional Setting}

The optimal transport metric has as an advantage that it
directly links a metric on $\R^d$ to the metric on $\mathcal{P}(\R^d).$ However it is an implicit definition, via an optimization,
and it can be hard to gain insight about it.
In one dimension, however, there are a number of explicit formulae for the optimal transport metric which are insightful and which we describe here.

\begin{lemma}\label{lemma:wasserstein1d}
Let $\postr,\postv$ be the densities of two real-valued random variables with invertible cumulative distribution functions $F_\postr,F_\postv \colon \R \rightarrow [0,1]$. Then,  for $p \ge 1$ the Wasserstein-$p$ distance with metric $\dm$ induced by the Euclidean norm $|\cdot|$ has the form
$$W_p(\postr,\postv)^p = \int_0^1 |F_\postr^{-1}(q) - F_\postv^{-1}(q)|^p \, dq.$$
\end{lemma}

\begin{proof}
The map $g(z) = F_\postv^{-1} \circ F_\postr(z)$ pushes forward $\postr$ to $\postv$, and it can be shown to be optimal in the one-dimensional setting.
By substituting this map in the objective and performing the change of variables $q = F_\postr(z)$, we have 
\begin{align*} W_p(\postr,\postv)^p&=\inf_{g_\sharp \postr=\postv} \int_\R |z-g(z)|^p \postr(z) \, dz \\
    &= \int_\R |z-F_\postv^{-1} \circ F_\postr(z)|^p \postr(z)\, dz\\
    &= \int_0^1 |F_\postr^{-1}(q)-F_\postv^{-1}(q)|^p \, dq.
\end{align*}
\end{proof}

The Wasserstein-$p$ distance for $p=1$ has some additional computational advantages. In addition to being an integral probability metric, as discussed in Example~\ref{ex:IPM_W1}, the closed-form expression in one dimension can be computed without requiring the inverse of cumulative distribution functions.

\begin{lemma} In the setting of Lemma \ref{lemma:wasserstein1d},
    the Wasserstein-1 distance can be expressed as 
$$W_1(\postr,\postv) = \int_0^1 |F_\postr^{-1}(q) - F_\postv^{-1}(q)| \, dq = \int_\R |F_\postr(z) - F_\postv(z)| \, dz.$$
\end{lemma}

\begin{proof}
The proof of this result is shown using Figure~\ref{fig:cdf_integration}. It illustrates that integrating the difference between the cumulative distribution functions vertically (left) is equivalent to the horizontal integration (right).
\end{proof}

\begin{figure}[!htp]
    \centering    \includegraphics[width=0.9\textwidth]{figures/cdf_integration.pdf}
    \caption{Integration of the difference between cumulative distribution functions (left) and their inverses (right)}
    \label{fig:cdf_integration}
\end{figure}
      
      
\subsection{Integral Probability Metrics}\index{metric!integral probability}


We now build on the variational characterization \eqref{eq:TV_VariationalCharacterization} 
of the total variation distance.  Let $\mathcal{F}$ be a set of real-valued functions 
$f \colon \Ru \rightarrow \R$ known as discriminators\index{discriminator}.
These are used to distinguish two probability distributions according to the maximum difference of
expectations of functions from $\mathcal{F}$: for each discriminator $f \in \mathcal{F}$, we compute the expectation of this function under the two distributions and define a metric by maximizing the difference of the expectations between the distributions.

\begin{definition} Let $\mathcal{F}$ be a set of discriminator functions. An 
{\em integral probability metric}\index{metric!integral probability} (IPM) between 
densities $\postr,\postv$ is defined by
\begin{equation} \label{eq:IPM}
\mathsf{D}_\mathcal{F}(\postr,\postv) \coloneqq \sup_{f \in \mathcal{F}}\big|\Expect^\postr[f]-\Expect^{\postv}[f]\big|.
\end{equation}
\end{definition}

Notice that
$\mathsf{D}_\mathcal{F}$ is a metric if and only if
$\mathcal{F}$ separates points on the space of probability distributions: for any two different probability measures
$\postr,\postv$ there is a point in $\mathcal{F}$ with
different expectations under $\postr$ and $\postv.$



\begin{example}
Perhaps the most fundamental example of an IPM is the total variation distance, given in~\eqref{eq:TV_VariationalCharacterization}. For this metric, $\mathcal{F}$ is the scaled unit ball 
of functions bounded by $\frac12$ in $L^\infty$. 
\end{example}
    
\begin{example} \label{ex:IPM_W1}
    A second important example of an IPM is the Wasserstein-$1$ distance where $\mathcal{F}$ is the
space of Lipschitz continuous functions with Lipschitz constant less than or equal to one.
\end{example}
    
\begin{example}
    \label{ex:kernel_trick}
A third commonly occurring example of an IPM arises when $\mathcal{F}$ is defined as the unit ball of a reproducing kernel Hilbert space (RKHS) \index{reproducing kernel Hilbert space} $\mathcal{H}$  of functions $f: D \subseteq \R^d \to \R.$ As discussed in Subsection \ref{ssec:kernel}, associated with $\mathcal{H}$ there is a symmetric and non-negative kernel $c: D \times D \to \R$ with the property that pointwise evaluation of a function $f \in \mathcal{H}$ can be computed by the inner product 
 $$f(u) = \langle f, c(u,\cdot) \rangle_{\mathcal{H}}.$$ 
   This is known as the \index{reproducing property}\emph{reproducing property}. 
 The next subsection is devoted to  IPMs defined through
    an RKHS. Lemma~\ref{lem:MMDasIPM} shows that, in this case, the supremum in~\eqref{eq:IPM} is given in closed form in terms of evaluations of the kernel. The resulting metric is known as the \index{maximum!mean!discrepancy}maximum mean discrepancy.
\end{example}

\subsection{Maximum Mean Discrepancy and Energy Distance}
\label{ssec:mmded}



\begin{definition}
\label{def:dmmd}
Let $c: \Ru \times \Ru \to \R^+$ be a symmetric and non-negative kernel. The 
{\em maximum mean discrepancy}\index{maximum mean discrepancy} (MMD) between two probability density functions $\postr$ and  $\postv$ is defined by 
$$\dmmd^2(\postr,\postv) \coloneqq \bbE^{(u,u') \sim \postr \otimes \postr} \bigl[c(u,u')\bigr]+\bbE^{(v,v') \sim \postv \otimes \postv} \bigl[ c(v,v')\bigr] - 2\bbE^{(u,v) \sim \postr \otimes \postv} \bigl[c(u,v)\bigr].$$
\end{definition}

\begin{lemma} \label{lem:MMDasIPM} Define $\mathcal{F} = \{f \in \mathcal{H}: \|f\|_{\mathcal{H}} \leq 1\}$, the  unit ball of an RKHS $\mathcal{H}$ with reproducing kernel $c$.
Then the MMD is an IPM with set of discriminator functions $\mathcal{F}.$ 
\end{lemma}
\begin{proof}   Let $m_\rho(\cdot) = \Expect^{u\sim \rho} [c(u, \cdot)]$
denote the mean embedding of a distribution $\postr$.
By the reproducing property for functions $f$ in a RKHS $\mathcal{H}$ we have
$$\mathbb{E}^\postr[f] = \int f(u) \postr(u) \, du = \int \langle f, c(u,\cdot) \rangle_{\mathcal{H}} \postr(u) \, du = \left\langle f, \int c(u,\cdot) \postr(u) \, du \right\rangle_{\mathcal{H}} = \langle f, m_\postr \rangle_{\mathcal{H}}.$$
Using the dual definition of the norm $\|g\|_{\mathcal{H}} = \sup_{f \in \mathcal{F}} \langle f, g \rangle_{\mathcal{H}}$, we have

\begin{align*}
 \sup_{f \in \mathcal{F}} \left| \mathbb{E}^\postr[f] - \mathbb{E}^\postv[f]\right| 
&= \sup_{f \in \mathcal{F}} \left| \langle f, m_\postr - m_\postv \rangle_{\mathcal{H}} \right| \\
&= \|m_\postr - m_\postv\|_{\mathcal{H}} \\
&= \Bigl( \langle m_\postr, m_\postr \rangle_{\mathcal{H}} - 2 \langle m_\postr, m_\postv \rangle_{\mathcal{H}} + \langle m_\postv, m_\postv \rangle_{\mathcal{H}} \Bigr)^{1/2}.
\end{align*}
The right-hand side agrees with $\dmmd(\postr,\postv).$ To see this, we can apply for each term the reproducing property with $k$ to compute the inner product of the mean embedding. For example,
\begin{align}
    \langle m_\postr, m_\postv \rangle_\mathcal{H} &= \Bigl\langle \mathbb{E}^{u \sim \postr}[c(u,\cdot)], \mathbb{E}^{u' \sim \postv}[c(u',\cdot)] \Bigr\rangle_{\mathcal{H}} \nonumber \\
    &= \mathbb{E}^{(u,u') \sim \postr \otimes \postv} \Bigl[ \bigl\langle c(u,\cdot), c(u',\cdot) \bigr\rangle_{\mathcal{H}} \Bigr] \nonumber \\ 
    &= \mathbb{E}^{(u,u') \sim \postr \otimes \postv} \bigl[ c(u,u')\bigr].\label{eq:kernel_trick}
\end{align}
\end{proof}

\begin{remark} The reproducing property in~\eqref{eq:kernel_trick} permits the computation of inner products with respect to the kernel (or an associated infinite-dimensional feature map) using evaluations of the kernel alone. In many machine learning tasks, this property is referred to as the \index{kernel!trick}\emph{kernel trick.}
\end{remark}

\begin{remark}
    The MMD is a metric under certain conditions on the kernel. In particular, we say that the kernel is characteristic if $\mathbb{E}^\postr [f] = \mathbb{E}^\postv [f]$  for all
$f$ in the RKHS\index{reproducing kernel Hilbert space} defined by $c(\cdot,\cdot)$ implies that $\postr = \postv$. In order words, characteristic kernels produce metrics that satisfy the positivity condition. 
\end{remark}

\begin{example} 
Gaussian and Laplace kernels are examples of characteristic kernels.  
Choosing $c(u,u')=-|u-u'|,$ the negative of the Euclidean distance, produces the energy distance\index{energy distance}, which we now define. It is also a metric, despite corresponding to a negative
kernel.
\end{example}

\begin{definition} \label{def:energy}
The {\em energy distance}\index{energy distance} $\den$ between two probability density functions $\postr$ and $\postv$ is defined by
\begin{equation}
\den^2(\postr,\postv) \coloneqq 2\bbE^{(u,v) \sim \postr \otimes \postv} |u-v|-\bbE^{(u,u') \sim \postr \otimes \postr} |u-u'|
-\bbE^{(v,v') \sim \postv \otimes \postv} |v-v'|. 
\end{equation}
\end{definition}

Proof of the following is postponed to the end of Subsection \ref{ssec:ES} where we
discuss energy scores\index{energy score}:

\begin{lemma} \label{lemma:den}
The energy distance $\den$ is a metric on $\cP(\Ru).$
\end{lemma}




A key property of the MMD and the energy distance is that  they are amenable to ensemble approximation; they
can be implemented without explicit formulae for either of $\postr$ or $\postv$. For example, given independent samples $\{u^i\}_{i=1}^N \sim \postr$ and $\{v^i\}_{i=1}^M \sim \postv$, we can estimate the MMD distance by 
\begin{equation}\label{eq:MMD_ens}
    \widehat{\dmmd^2}(\postr,\postv) =  \frac{1}{N(N-1)} \sum_{i \neq j} c(u^i,u^j) + \frac{1}{M(M-1)} \sum_{i \neq j} c(v^i,v^j) - \frac{2}{NM} \sum_{i,j} c(u^i,v^j).
\end{equation}
Likewise, we can estimate the energy distance by
\begin{equation}\label{eq:energy_dist_ens}
   \widehat{\den^2}(\postr,\postv) = \frac{2}{NM} \sum_{i,j} |u^i - v^j| - \frac{1}{N(N-1)} \sum_{i \neq j} |u^i - u^j| - \frac{1}{M(M-1)} \sum_{i \neq j} |v^i - v^j|.
\end{equation}


\begin{remark}
Another important property of both the MMD with isotropic kernel and the energy distance is that 
they are rotation invariant. That is, the metrics do not change under the 
transformations $u \leftarrow Ru$ and $v \leftarrow R v$ for some unitary matrix $R$. 
\end{remark}

\subsection{Metrics on the Space of Random Probability Measures}
\label{ssec:rpm}

The space of random probability measures arises naturally when building methodologies
from empirical sampling or from Monte Carlo methods. We consider functions $\pi: \Omega \to \cP(\Ru)$,
for some abstract probability space $(\Omega,\mathcal{B},\mathbb{P});$ expectation under $\mathbb{P}$ 
is denoted by $\mathbb{E}.$ For any fixed $\omega \in \Omega$ let $\pi=\pi(\omega)$ and 
define $\pi(f) \coloneqq \int f(u)\pi(u) \, du$. 

\begin{definition}
We define the following metric on the space of random probability measures:    
$$d(\pi,\pi') \coloneqq \sup_{|f|_{\infty} \leq 1} \left|\mathbb{E}\left[\left(\pi(f) - \pi'(f)\right)^2\right]\right|^{1/2}.$$
\end{definition}


\begin{remark}
    \label{rem:rtv}
We note that $d$ reduces to the total variation distance\index{total variation distance} (up to a 1/2 factor)
when $\pi,\pi'$ are not random. 
\end{remark}

We now define Monte Carlo approximation of $\post$:
\begin{equation}
\label{eq:pmc}
\pMC (f) = \frac{1}{\Sam}\sum_{\sam=1}^{\Sam}f(u^{(\sam)}),\,\, u^{(\sam)} \sim \post \quad \index{i.i.d.}{\rm  i.i.d.}
\end{equation}
The metric as defined is well-adapted to measure the error in approximating $\post$ by $\pMC:$

\newcommand*\diff{\mathop{}\!\mathrm{d}}
      \begin{theorem}
\label{t:MC}
Given $f:\Ru\longrightarrow\mathbb{R}$ define $|f|_\infty := \sup_{u\in \Ru} |f(u)|.$ Then
       \begin{equation*}
        \begin{split}
        \sup_{|f|_\infty\leq1} \left|\Expect{\left[\pMC (f)-\post(f)\right]}\right|  &= 0,\\
        d(\pMC, \post)^2 &\leq \frac{1}{\Sam}. 
        \end{split}
        \end{equation*}
      \end{theorem}
      
      \begin{proof}
To prove that the estimator is unbiased,  use linearity of the expected value and that $u^{(\sam)} \sim \post$ to obtain the following identity, from which the desired result follows:
\begin{align*}
\Expect \left[\pMC (f) \right]  &= \Expect \Biggl[   \frac{1}{\Sam} \sum_{\sam=1}^{\Sam} f\bigl(  u^{(n)} \bigr) \Biggr] \\
&= \frac{1}{\Sam} N \post(f) = \post(f) = \Expect \bigl[ \post(f) \bigr]. 
\end{align*}


For the error estimate in $d(\cdot,\cdot)$ we note that, since $\pMC (f)$ is unbiased, its variance coincides
with its mean squared error. Using the fact that the $u^{(\sam)} \sim \post$ are independent we deduce that
\begin{align*}
\text{Var} \left[\pMC (f) \right]  &= \text{Var} \Biggl[   \frac{1}{\Sam} \sum_{\sam=1}^{\Sam} f \bigl( u^{(\sam)}\bigr) \Biggr] \\
&= \frac{1}{\Sam^2} \Sam \text{Var}_\post[f] =  \frac{1}{\Sam} \text{Var}_{\post}[f] . 
\end{align*}
Assuming $|f|_\infty \le 1,$ we have
        \begin{equation*}
        \text{Var}_{\post}[f] = \post(f^2) -\post(f)^2 \leq \post(f^2) \le 1, 
        \end{equation*}
and therefore
        \begin{equation*}
        \sup_{|f|_\infty\leq1} \left|\Expect{\left[\left(\pMC (f)-\post(f)\right)^2\right]}\right| = \sup_{|f|_\infty\leq1} \left| \frac{1}{\Sam}\text{Var}_{\post}[f]\right| \leq \frac{1}{\Sam}.
        \end{equation*}
      \end{proof}

\section{Divergences}\index{divergence}
\label{sec:div}

Recall the conditions for a metric given in Section~\ref{sec:metric}. If we remove the conditions of
symmetry and the triangle inequality then we obtain a 
{\em statistical divergence}.\index{divergence!statistical} This distance-like measure between two probability distributions is defined as a function $\D\colon \cP(\Ru) \times \cP(\Ru) \rightarrow \mathbb{R}$ that only satisfies the non-negativity and positivity conditions for a metric. To emphasize the asymmetry in their arguments, divergences are often written with double bars $\D(\postr\|\postv)$ or a colon $\D(\postr : \postv)$. We adopt
the former convention. 

\subsection{$\mathsf{f}$-Divergences}
\label{ssec:fdiv}

An important feature of $\mathsf{f}$-divergences, which we now define,
is that they depend on a ratio of two probability density functions. To simplify the presentation, throughout this section we restrict our attention to positive densities. 

\begin{definition}\label{def:fdivergence}
Let $\mathsf{f}\colon [0,\infty) \rightarrow \R$ be a strictly convex function that satisfies $\mathsf{f}(0) = \lim_{t \rightarrow 0^+} \mathsf{f}(t)$ and $\mathsf{f}(1) = 0$. 
The {\em $\mathsf{f}$-divergence}\index{$\mathsf{f}$-divergence} between distributions with positive densities $\postr$ and $\postv$ is defined by
$$\D_\mathsf{f}(\postr\|\postv) \coloneqq \int \mathsf{f}\left(\frac{\postr(u)}{\postv(u)}\right)\postv(u)\,du.$$
\end{definition}


\begin{remark}
Some $\mathsf{f}$-divergences define metrics. For example, the choice $\mathsf{f}(t) = \frac{1}{2} | t -1|$ delivers $\D_\mathsf{f}(\postr\|\postv) = \dtv(\postr,\postv)$ and the choice $\mathsf{f}(t) = (1 - \sqrt{t})^2$
delivers $\D_\mathsf{f}(\postr\|\postv)=2\dhell(\postr,\postv)^2.$ It can be shown that the only $\mathsf{f}$-divergence that is also an IPM is the total variation distance.
The next definition introduces two important $\mathsf{f}$-divergences that do not define metrics: the Kullback-Leibler divergence and the $\chi^2$ divergence. They correspond to choosing $\mathsf{f}(t) = t\log t$ and $\mathsf{f}(t) = (t-1)^2,$ respectively.
\end{remark}



\begin{definition} \label{def:KL} The {\em Kullback--Leibler (KL)  divergence}\index{divergence!Kullback--Leibler} between two positive probability density functions $\postr$ and $\postv$ is defined by
\begin{equation}
    \dkl(\postr\|\postv) \coloneqq \int \log \biggl(\frac{\postr(u)}{\postv(u)} \biggr) \postr(u) \, du.
\end{equation}
The \index{divergence!$\chi^2$} \emph{$\chi^2$ divergence} between two positive probability density functions $\postr$ and $\postv$ is defined by \label{def:chi2}
\begin{equation}\label{eq:chi2}
\dchi(\postr \| \postv) \coloneqq \int \left( \frac{\postr(u)}{\postv(u)} -1  \right)^2 \, \postv(u) \, du.
\end{equation}
\end{definition}

The $\chi^2$ divergence arises naturally in the analysis of sampling algorithms that involve weighting samples according to the ratio between two densities. In that context, the $\chi^2$ divergence has a natural interpretation as quantifying the variance of the weights. The KL divergence has a distinguished place among $\mathsf{f}$-divergences due to its appealing analytical and computational properties. The following remark shows that KL can be minimized over its first argument without knowledge of the normalizing constant of the second, which is useful in variational inference (see Chapter \ref{ch:VI}). 

\begin{remark}
\label{rem:yifan}
For any $\mathsf{f}$-divergence it holds that
$$\pi \in \argmin_{q \in \cP} \D_\mathsf{f}(q \|\pi)$$
and the minimizer is unique. The KL divergence is the only $\mathsf{f}$-divergence with the property that, for any $c>0$,
$\D_\mathsf{f}(q \|c\pi)-\D_\mathsf{f}(q \|\pi)$ is independent of $q.$\footnote{Here we extend the notion of $\mathsf{f}$-divergence in Definition \ref{def:fdivergence} to unnormalized densities $\postr$ and $\postv.$} 
Consequently, for any $c>0$,
$$\pi \in \argmin_{q \in \cP} \dkl(q \|c\pi).$$
That is, the minimizer is independent of scaling factors on the target density, such as a normalization constant. Reference to a proof of this property of the KL divergence may be found in the bibliography in Section \ref{sec:12bib}.
\end{remark}

The following result, which we use repeatedly in Chapter \ref{ch:data-dependence}, is known as the chain rule of KL divergence. 

\begin{lemma}\label{lemma:chainrule}
    Let $\postr(u,v) = \postr(u)\postr(v|u)$ and $\postv(u,v) = \postv(u)\postv(v|u)$ be two joint probability densities. It holds that 
    \begin{equation*}
        \dkl \bigl( \postr(u,v) \| \postv(u,v) \bigr) = \dkl \bigl( \postr(u) \| \postv(u) \bigr) + \dkl \bigl( \postr(v|u) \| \postv(v|u) \bigr),
    \end{equation*}
where 
\begin{equation*}
    \dkl \bigl( \postr(v|u) \| \postv(v|u) \bigr) := \int \biggl[ \int \log \biggl( \frac{\postr(v|u)}{\postv(v|u)} \biggr) \postr(v|u) \,  dv \biggr] \postr(u)\,  du. 
\end{equation*}
\end{lemma}
\begin{proof}
    By direct calculation,
    \begin{align*}
        \dkl \bigl( \postr(v|u) \| \postv(v|u) \bigr) &= \int \int \log \biggl( \frac{\postr(u,v)}{\postv(u,v)} \biggr) \postr(u,v) \, du dv  \\
        &= \int \int  \log \biggl( \frac{\postr(u)}{\postv(u)} \biggr) \postr(u) \postr(v|u) \, du dv  
        + \int \int \log \biggl( \frac{\postr(v|u)}{\postv(v|u)} \biggr) \postr(u,v) \, du dv \\
        &= \int  \log \biggl( \frac{\postr(u)}{\postv(u)} \biggr) \postr(u) \, du
        + \int \biggl[ \int \log \biggl( \frac{\postr(v|u)}{\postv(v|u)} \biggr) \postr(v|u) \,  dv \biggr] \postr(u) \, du \\
        & = \dkl \bigl( \postr(u) \| \postv(u) \bigr) + \dkl \bigl( \postr(v|u) \| \postv(v|u) \bigr),
    \end{align*}
as desired.     
\end{proof}



\begin{example}
\label{ex:klg}
The KL and $\chi^2$ divergences can be explicitly computed for some parametric distributions. For example, if $\postr = \mathcal{N}(\mu_\postr,\Sigma_\postr)$ and $\postv = \mathcal{N}(\mu_\postv,\Sigma_\postv)$ are both $d$-dimensional multivariate Gaussians, the KL and $\chi^2$ divergences are given by
\begin{align}\label{eq:kl_gaussians}
\begin{split}
\dkl(\postr\|\postv) &= \frac{1}{2}\left(\text{Tr}(\Sigma_\postv^{-1}\Sigma_\postr) - d + (\mu_\postr - \mu_\postv)^\top \Sigma_\postv^{-1}(\mu_\postr - \mu_\postv) + \log\left(\frac{\det\Sigma_\postv}{\det\Sigma_\postr}\right) \right), \\
    \dchi(\postr\|\postv) &= \frac{\det(\Sigma_\postv\Sigma_\postr^{-1})}{\det(2\Sigma_\postv\Sigma_\postr^{-1} - I)} \exp \biggl( (\mu_\postr - \mu_\postv)^\top \Sigma_\postr^{-1}( 2\Sigma_\postv\Sigma_\postr^{-1} - I)^{-1} (\mu_\postr - \mu_\postv)  - 1 \biggr). 
    \end{split}
\end{align}
\end{example}

\subsection{Relationships between $\mathsf{f}$-Divergences and Metrics}
\label{ssec:metdiv}
Here we establish bounds between some metrics and $\mathsf{f}$-divergences. We continue to work under the simplifying assumption that $\postr,\postv$ are positive densities. 

\begin{lemma} \label{l:kllemma}
The \index{distance!Hellinger}Hellinger and \index{distance!total variation}total variation metrics
are upper bounded by the \index{divergence!Kullback--Leibler}KL divergence as follows:
$$ \dhell(\postr, \postv)^2 \leq \frac{1}{2}\dkl(\postr \| \postv),
\quad \dtv(\postr, \postv)^2 \leq \dkl(\postr \| \postv).$$
\end{lemma}

\begin{proof}
It suffices to prove only the first inequality since it implies the second by Lemma \ref{l:dh1}.
Define function $\phi:\R^+ \mapsto \R$ by
$$\phi(x): = x - 1 - \log{x}.$$
Then
\begin{equation*}
\begin{split}
\phi'(x) &= 1 - \frac{1}{x}, \\
\phi''(x) &= \frac{1}{x^2}, \\
\phi(\infty) & = \phi(0) =\infty,
\end{split}
\end{equation*}
and so the function is convex on its domain.
The minimum of $\phi$ is attained at $x = 1$, and $\phi(1) = 0$;
hence $\phi(x) \geq 0$  for all $x \in (0, \infty).$ It follows that, for all $x \ge 0,$ 
\begin{equation*}
\begin{split}
x-1 &\geq \log{x}, \\
\sqrt{x} - 1&\geq \frac{1}{2}\log{x}.
\end{split}
\end{equation*}
Using this last inequality we can bound the \index{distance!Hellinger}Hellinger distance
as follows:
\begin{equation*}
\begin{split}
\dhell(\postr,\postv)^2 &= \frac{1}{2}\int \left( 1 - \sqrt{\frac{\postv(u)}{\postr(u)}} \right)^2 \postr(u) \, du \\
&=  \frac{1}{2}\int \left( 1 + \frac{\postv(u)}{\postr(u)} -  2\sqrt{\frac{\postv(u)}{\postr(u)}} \right) \postr(u) \, du \\
&= \int \left( 1 - \sqrt{\frac{\postv(u)}{\postr(u)}} \right) \postr(u)\,  du \leq -\frac{1}{2}\int \log\biggl({\frac{\postv(u)}{\postr(u)}}\biggr)\postr(u) \, du = \frac{1}{2}\dkl(\postr \| \postv ).
\end{split}
\end{equation*}
\end{proof}





The following lemma shows that the \index{divergence!$\chi^2$}$\chi^2$ divergence upper bounds the \index{divergence!Kullback--Leibler}KL divergence. By Lemma \ref{l:kllemma} this shows that
it also bounds the \index{distance!total variation}total variation 
and \index{distance!Hellinger}Hellinger distances. 

\begin{lemma}\label{l:chisq}
The \index{divergence!$\chi^2$}$\chi^2$ divergence upper bounds 
the \index{divergence!Kullback--Leibler}KL divergence
as follows:
$$\dkl(\postr \| \postv) \le \log\Bigl(\dchi(\postr\| \postv) + 1 \Bigr), \quad \quad \dkl( \postr \| \postv) \le \dchi(\postr \| \postv).$$
\end{lemma}
\begin{proof}
The second inequality is a direct consequence of the first one, noting that, for $x \ge 0,$ $\log(x + 1 ) \le x.$
To prove the first inequality note that by \index{Jensen inequality}Jensen inequality
\begin{align*}
\dkl(\postr \| \postv)  &= \int \log \biggl( \frac{\postr(u)}{\postv(u)} \biggr) \postr(u) \, du \\
& \le \log \biggl(  \int \frac{\postr(u)}{\postv(u)}   \frac{\postr(u)}{\postv(u)} \postv(u) \, du \biggr)  \\
& = \log\Bigl(\dchi(\postr\| \postv) + 1 \Bigr),
\end{align*}
where for the last equality we used that 
\begin{align*}
\dchi(\postr\| \postv) &= \int \left( \frac{\postr(u)}{\postv(u)} -1  \right)^2 \, \postv(u) \, du \\
& = \int \left( \frac{\postr(u)}{\postv(u)} \right)^2 \, \postv(u) \, du  - 2  \int \left( \frac{\postr(u)}{\postv(u)} \right) \, \postv(u) \, du  + \int  \postv(u) \, du \\
&= \int \left( \frac{\postr(u)}{\postv(u)} \right)^2 \, \postv(u) \, du  - 1.
\end{align*}
\end{proof}

\subsection{Invariance of $\mathsf{f}$-Divergences under Invertible Tranformations}
\label{ssec:idiv}
This subsection discusses an important property satisfied by all $\mathsf{f}$-divergences: they are
invariant under invertible transformations of the underlying variables. Recall the notation for
pushforward\index{pushforward} from the preface. We start with the following lemma relating to
pushforwards. The proof is a straightforward consequence of change of variables.

\begin{lemma}
\label{lem:cov}
Let $\pi$ be a probability density on $\R^d$ and
let $\ff \in C^1(\R^d,\R^d)$ be invertible everywhere on $\R^d$. 
Assume further that the determinant of the Jacobian of the inverse, 
\begin{equation}
\label{eq:invd}
{\rm det} D(\ff^{-1})(u)=\Bigl({\rm det} D\ff\bigl(\ff^{-1}(u)\bigr)\Bigr)^{-1},
\end{equation}
is positive everywhere on $\R^d$. Then, for $u=q(z)$,
$$\int \phi(z)\pi(z) \, dz=\int \bigl(\phi \circ \ff^{-1}\bigr)(u)
\bigl(\pi\circ \ff^{-1}\bigr)(u) {\rm det} D(\ff^{-1})(u) \, du .$$
Thus 
\begin{subequations}
\label{eq:cov}
\begin{align}
    \ff_\sharp \pi(u)&= \bigl(\pi \circ \ff^{-1}\bigr)(u) {\rm det} D(\ff^{-1})(u),\\
\log \ff_\sharp \pi(u)&= \log \bigl(\pi \circ \ff^{-1}\bigr)(u) +
 \log {\rm det} D\bigl(\ff^{-1}(u)\bigr). 
\end{align}
\end{subequations}
\end{lemma} 

\begin{theorem} \label{thm:invariance} Let $T \colon \R^d \rightarrow \R^d$ be an invertible and differentiable transformation. Then, for  two probability density functions $\postr,\postv$ on $\R^d$ we have
$$\D_\mathsf{f}(\postr\|\postv) = \D_\mathsf{f}(T_\sharp \postr\|T_\sharp \postv).$$
\end{theorem}


\begin{proof} Let $v = T(u)$ denote the transformed variable. For an invertible transformation, $u = T^{-1}(v)$ and $du = \det \bigl(\nabla T^{-1}(v)\bigr)\, dv$. Performing a change of variables in the divergence we have 
\begin{align*}
\D_\mathsf{f}(\postr\|\postv) &= \int \mathsf{f}\left(\frac{\postr(u)}{\postv(u)} \right) \postv(u) \, du \\
&= \int \mathsf{f} \left(\frac{\postr \bigl(T^{-1}(v)\bigr)}{\postv \bigl(T^{-1}(v)\bigr)} \right) \postv \bigl(T^{-1}(v)\bigr) \det \bigl(\nabla T^{-1}(v)\bigr) \, dv \\
&= \int \mathsf{f} \left(\frac{\postr \bigl(T^{-1}(v)\bigr)\det \bigl(\nabla T^{-1}(v)\bigr)}{\postv \bigl(T^{-1}(v)\bigr)\det \bigl(\nabla T^{-1}(v)\bigr)} \right) \postv \bigl(T^{-1}(v)\bigr) \det \bigl(\nabla T^{-1}(v)\bigr) \, dv.
\end{align*}
Using Lemma \ref{lem:cov} we see that $\postr \bigl(T^{-1}(v)\bigr)\det \bigl(\nabla T^{-1}(v)\bigr) = T_\sharp \postr(v)$ denotes the density of the pushforward random variable $v$, we have
\begin{align*}
\D_\mathsf{f}(\postr\|\postv) = \int \mathsf{f} \left(\frac{T_\sharp \postr(v)}{T_\sharp \postv(v)} \right) T_\sharp \postv(v) \, dv = \D_\mathsf{f}(T_\sharp\postr\|T_\sharp \postv).
\end{align*}


\end{proof}


\section{Scoring Rules}
\label{sec:psr}

Probabilistic scoring rules quantify the accuracy of a {\em forecast distribution} with respect to a {\em true distribution} known only through
samples; the latter is sometimes termed {\em the verification.} Let $\postr$ and $\postv$ denote the densities of the forecast and verification distributions, respectively. 
A {\em scoring rule} is a function $\mS \colon \cP(\Ru) \times \Ru \rightarrow \R$ that assigns a {\em score} $\mS(\postr,v)$ to a sample $v \sim \postv$ with
respect to the forecast distribution $\postr$. We follow the convention here that scoring rules are negatively oriented meaning that a lower score indicates a better forecast.

To compare the forecast and verification distributions, we  define the expected score
$\overline{\mS} \colon \cP(\Ru) \times \cP(\Ru) \rightarrow \R$ by
\begin{equation*}
    \overline{\mS}(\postr,\postv) \coloneqq \mathbb{E}^{v \sim \postv}[\mS(\postr, v)] = \int \mS(\postr, v) \postv(v) \, dv.
\end{equation*}

\begin{definition}\label{def:proper_score}
    A scoring rule\index{scoring rules} $\mS$ is called \emph{proper}\index{scoring rules!proper} if, for all $\postr, \postv \in \mathcal{P}(\Ru)$, $\overline{\mS}(\postv,\postv) \leq \overline{\mS}(\postr,\postv)$. A scoring rule is called \emph{strictly proper} when equality holds if and only if $\postr = \postv$.
\end{definition}
That is, for a proper scoring rule, forecasting with the true distribution results in the lowest expected score. For a strictly proper scoring rule, the lowest expected score can only be attained when forecasting with the true distribution. 
While a general scoring rule does not need to satisfy the properties in Section~\ref{sec:div} for statistical distances, it can define a divergence if strict propriety is imposed:


\begin{lemma} A strictly proper scoring rule can be used to define a divergence between two probability distributions given by
\begin{equation} \label{eq:distance_score}
    \D_{\mS}(\postr \| \postv) \coloneqq \overline{\mS}(\postr,\postv) - \overline{\mS}(\postv,\postv).    
\end{equation}
\end{lemma}

\begin{proof}
For a proper scoring rule, the distance is non-negative, i.e., $\D_{\overline \mS}(\postr,\postv) \geq 0$. If $\overline{\mS}$ is strictly proper, the distance also satisfies the positivity condition, i.e., $\D_{\overline \mS}(\postr,\postv) = 0$ if and only if $\postr = \postv$. 
\end{proof}



In the following subsections we present five probabilistic scoring rules: the energy score, the continuous ranked probability score, the quantile score, the logarithmic score and the Dawid-Sebastiani score.

\subsection{Energy Score}\index{energy score}
\label{ssec:ES}

\begin{definition} Let $\beta\in(0, 2)$ be a parameter. For a distribution with probability density function $\postr$ and finite $\beta$-moment, the {\em energy score} ($\ES$) of a sample $v$ is defined by
\begin{equation}\label{eq:energy_score}
    \ES_\beta(\postr, v) \coloneqq \mathbb{E}^{u \sim \postr}|u - v|^\beta - \frac{1}{2}\mathbb{E}^{(u,u') \sim \postr \otimes\postr}|u - u'|^\beta.
\end{equation}
\end{definition}

We  define the expected energy score
$\overline{\ES}_\beta \colon \cP(\Ru) \times \cP(\Ru) \rightarrow \R$ by
\begin{equation}\label{eq:exp_energy_score}
    \overline{\ES}_\beta(\postr,\postv) \coloneqq \mathbb{E}^{v \sim \postv}[\ES_\beta(\postr, v)] = \int \ES_\beta(\postr, v) \postv(v) \, dv.
\end{equation}

\begin{lemma}
\label{lem:CTM}
Recall the squared energy distance in Definition~\ref{def:energy}, given by
\begin{equation}
\den^2(\postr,\postv) := 2\bbE^{(u,v) \sim \postr \otimes \postv} |u-v|-\bbE^{(u,u') \sim \postr \otimes \postr} |u-u'|
-\bbE^{(v,v') \sim \postv \otimes \postv} |v-v'|.
\end{equation}
The energy score $\ES_\beta(\postr, v)$ is a strictly proper scoring rule for $\beta \in (0,2).$
Using the distance function in~\eqref{eq:distance_score} with the expected score and with
$\beta=1$, yields 
$$\frac{1}{2}\den^2(\postr,\postv) = \overline{\ES}_1(\postr,\postv) - \overline{\ES}_1(\postv,\postv).$$
\end{lemma}
\begin{proof}
It can be shown that the expected energy score \eqref{eq:exp_energy_score} can be written, for $\beta\in(0,2)$, as
\begin{equation}
\label{eq:CTM}
    \overline{\ES}_\beta(\postr,\postv) = \frac{\beta 2^{\beta - 2}\Gamma(\frac{d}{2}+\frac{\beta}{2})}{\pi^{d/2}\Gamma(1 - \frac{\beta}{2})}\int \frac{|\varphi_\postr(u) - \varphi_\postv(u)|^2}{|u|^{d+\beta}} \, du + \overline{\ES}_\beta(\postv,\postv),
\end{equation}
where $\varphi_\postr$ and $\varphi_\postv$ are the characteristic functions of $\postr$ and $\postv$, respectively. We give a reference for \eqref{eq:CTM} in the
bibliography; its proof is omitted here for reasons of brevity. It follows that the first term is minimized if and only if $\varphi_\postr = \varphi_\postv$
and hence if and only if $\postr=\postv.$ Since the second term does not depend on $\postv$, it follows that the energy score is strictly proper for $\beta\in(0, 2)$.

We show the relationship between the energy score and the energy distance as follows:
\begin{align*}
    \overline{\ES}_\beta(\postr,\postv) &= \mathbb{E}^{(u, v)\sim \postr\otimes\postv}|u - v|^\beta - \frac{1}{2}\mathbb{E}^{(u, u')\sim \postr\otimes\postr}|u - u'|^\beta,\\
    \overline{\ES}_\beta(\postv,\postv) &= \frac{1}{2}\mathbb{E}^{(u, u')\sim \postv\otimes\postv}|u - u'|^\beta.
\end{align*}
Then, for $\beta = 1$,
\begin{align*}
    \overline{\ES}_1(\postr,\postv) - \overline{\ES}_1(\postv,\postv) = \mathbb{E}^{(u, v)\sim \postr\otimes\postv}|u - v| - \frac{1}{2}\mathbb{E}^{(u, u')\sim \postr\otimes\postr}|u - u'| - \frac{1}{2}\mathbb{E}^{(u, u')\sim \postv\otimes\postv}|u - u'|,
\end{align*}
which is indeed half of the squared energy distance in Definition~\ref{def:energy}.
\end{proof}

\begin{lemma}
The energy score $\ES_2(\postr, v)$ is proper, but not strictly proper.  
\end{lemma}

\begin{proof}
Notice that
\begin{align*}
    \ES_2(\postr, v) &= \mathbb{E}^{u \sim \postr}|u|^2 - 2\mathbb{E}^{u \sim \postr}[u]^\top v + |v|^2 - \frac{1}{2}(\mathbb{E}^{u \sim \postr}|u|^2 - 2\mathbb{E}^{u \sim \postr}[u]^\top \mathbb{E}^{u \sim \postr}[u] + \mathbb{E}^{u \sim \postr} |u|^2) \\
    &= \mathbb{E}^{u \sim \postr}[u]^\top \mathbb{E}^{u \sim \postr}[u] - 2\mathbb{E}^{u \sim \postr}[u]^\top v + |v|^2 \\
    &= \bigl|\mathbb{E}^{u \sim \postr}[u] - v\bigr|^2.
\end{align*}
The minimizer of $\mathsf{J}(b):= \mathbb{E}^{v \sim \postv} |b - v|^2$ is $b^\star = \mathbb{E}^{u \sim \postv}[u],$ which shows that $\ES_2$ is proper. It is not strictly proper, since for any other distribution $\tilde{\postv}$ with $ \mathbb{E}^{u \sim \postv}[u] = \mathbb{E}^{u \sim \tilde{\postv}}[u] $ it holds that  $\overline{\ES}_2(\postv,\postv) = \overline{\ES}_2(\tilde{\postv},\postv). $
\end{proof}

\begin{remark}
When $\beta=2$ the expected energy score is the \emph{mean-square error} of $\mathbb{E}^{u \sim \postr}[u]$. Its square root, the \emph{root-mean-square error (RMSE)}\index{root-mean-square error (RMSE)} of $\mathbb{E}^{u \sim \postr}[u]$, is often used for evaluating probabilistic forecasts, despite lacking strict propriety.
\end{remark}

\begin{proof}[Proof of Lemma \ref{lemma:den}]
The proof follows from noting that, from Lemma \ref{lem:CTM} and equation \eqref{eq:CTM}
\begin{align*}
\den^2(\postr,\postv) &= \overline{\ES}_1(\postr,\postv) - \overline{\ES}_1(\postv,\postv)\\
&=\frac{\Gamma(\frac{d}{2}+\frac{1}{2})}{2\pi^{d/2}\Gamma(\frac{1}{2})}\int \frac{|\varphi_\postr(x) - \varphi_\postv(u)|^2}{|u|^{d+1}} \, du .
\end{align*}
Using the fact that $\den(\postr,\postv)$ is defined as a weighted $L^2$-norm
of the difference between the characteristic functions of the pair $(\postr,\postv)$
leads to the desired metric structure.
\end{proof}

\subsection{Continuous Ranked Probability Score}

Let $\mathbb{1}_{u \ge v}$ denote the indicator function of the set $\{u \in \R: u \ge v \}$; this is also known as the Heaviside step function.


\begin{definition} \label{def:crps} The {\em continuous ranked probability score} \index{continuous ranked probability score} ($\CRPS$) for 
$\postr \in \cP(\R)$ and a sample $v \in \R$ is defined by
    \begin{equation} \label{eq:CRPS}
    \CRPS(\postr, v) \coloneqq \int \bigl(\Fr(u) - \mathbb{1}_{u \ge v}(u)\bigr)^2\,du.
\end{equation}
\end{definition}
We define the expected CRPS 
$\overline{\CRPS} \colon \cP(\R) \times \cP(\R) \rightarrow \R$  by
\begin{equation*}
    \overline{\CRPS}(\postr,\postv) \coloneqq \mathbb{E}^{v \sim \postv}[\CRPS(\postr, v)] = \int \CRPS(\postr, v) \postv(v) \, dv.
\end{equation*}




Note that the indicator function is the cumulative density function of a Dirac mass at $v$ and so the $\CRPS$ is comparing two cumulative density functions. 
The following lemma shows that the above definition of $\CRPS$ is equivalent to the energy score in Definition~\ref{def:energy} with $\beta=1$.
\begin{lemma}\label{lemma:CRPSandE1} 
\begin{equation}
\label{eq:CRPS_energy}
    \CRPS(\postr, v) = \ES_1(\postr,v) = \mathbb{E}^{u \sim \postr}|u - v| - \frac{1}{2}\mathbb{E}^{(u, u') \sim \postr\otimes \postr}|u - u'|.
\end{equation}
\end{lemma}

\begin{proof} First, let us recall that the absolute value of a difference can be written as
$$|u-v| = \int_v^\infty \mathbb{1}_{z \leq u}(z) \, dz + \int_{-\infty}^v \mathbb{1}_{z > u}(z) \, dz,$$
by considering the two cases $v \leq u$ and $v > u$.
Taking an expectation with respect to $u \sim \postr$ and applying Fubini's theorem we have 
\begin{align}
\mathbb{E}^{u \sim \postr}|u-v| &= \int_v^{\infty} \int_{\R} \mathbb{1}_{z \leq u}(z) \postr(u) \, du dz + \int_{-\infty}^v \int_{\R} \mathbb{1}_{z > u}(z) \postr(u) \, du dz \nonumber \\
&= \int_v^{\infty} \bigl(1 - \Fr(z) \bigr) \, dz + \int_{-\infty}^v \Fr(z) \, dz \nonumber \\
&= \int_{\R}  \bigl(1 - \Fr(z)\bigr) \mathbb{1}_{z \geq v}(z) \, dz + \int_{\R} \Fr(z) \mathbb{1}_{z < v}(z) \, dz. \label{eq:CRPS_calibration}
\end{align}
Following similar steps for the second term in~\eqref{eq:CRPS_energy} and taking an expectation over $u' \sim \postr$, we have 
\begin{align}
\frac{1}{2}\mathbb{E}^{(u,u') \sim \postr \otimes \postr}\,|u-u'| 
= \int_{\R} \Fr(z) \bigl(1 - \Fr(z)\bigr) \, dz \label{eq:CRPS_spread}.
\end{align}
Lastly, subtracting ~\eqref{eq:CRPS_calibration} and~\eqref{eq:CRPS_spread} gives
\begin{align*}
\mathbb{E}^{u \sim \postr}|u-v| - \frac12 \mathbb{E}^{(u,u') \sim \postr \otimes \postr}\,|u-u'|  &= 
\int_\R  \Bigl( \mathbb{1}_{z \geq v}(z)^2  - 2 \Fr(z)\mathbb{1}_{z \geq v}(z)  +  \Fr(z)^2 \Bigr) \, dz \\
& = \int \bigl(\Fr(z) - \mathbb{1}_{z \ge v}(z)\bigr)^2\,dz = \CRPS(\postr, v).
\end{align*}
\end{proof}



The characterization of the CRPS in \eqref{eq:CRPS_energy} shows that it is composed of two parts:
a calibration term that quantifies closeness of the forecast to $v$ and a sharpness term that is related to the spread of the distribution. We note that for a deterministic forecast concentrated on some point $z \in \R$, i.e., $\Fr(u) = \mathbb{1}_{u \ge z}(u)$, the second term vanishes and the $\CRPS$ reduces to the absolute error between the point $z$ and sample $v$.

\begin{lemma}\label{lemma:CRPS}
The expected CRPS for forecast and verification distributions with probability density functions $\postr$ and $\postv$, respectively, is given by 
\begin{equation}
    \overline{\CRPS}(\postr, \postv) = \int \bigl(\Fr(u) - \Fv(u)\bigr)^2 \, du + \int \Fv(u) \bigl(1-\Fv(u)\bigr) \, du.
\end{equation}
\end{lemma}

\begin{proof}
    Start with form~\eqref{eq:CRPS} of the CRPS. Then,
    \begin{align*}
        \mathbb{E}^{v \sim \postv} \bigl[ \CRPS(\postr, v)\bigr] &= \int \mathbb{E}^{v \sim \postv} \Bigl[ \bigl(\Fr(u) - \mathbb{1}_{u \ge v}(u)\bigr)^2 \Bigr]\,du\\
        &= \int \mathbb{E}^{v \sim \postv}\Bigl[\Fr(u)^2 - 2\Fr(u)\mathbb{1}_{u \ge v}(u) + \mathbb{1}_{u \geq v}(u)^2\Bigr]\,du.
    \end{align*}
    Noting that $\mathbb{1}_{u \geq v}(u)^2 = \mathbb{1}_{u \geq v}(u)$ and that $\mathbb{E}^{v \sim \postv}[\mathbb{1}_{u \ge v}(u)] = \Fv(u)$, we obtain the result after rearranging.
\end{proof}

\begin{remark}
A direct consequence of Lemma \ref{lemma:CRPS} is that the divergence \eqref{eq:distance_score} defined by the CRPS takes the form
    \begin{align*}
       \mathsf{D_{CRPS}} = \overline{\CRPS}(\postr, \postv) - \overline{\CRPS}(\postv, \postv) &= \int \bigl(\Fr(u) - \Fv(u)\bigr)^2 \, du,
    \end{align*}
 which is known as Cram\'er's distance. Thus, we have shown that in one dimension CRPS agrees with the energy score $\mathsf{ES}_1$ (Lemma \ref{lemma:CRPSandE1}), the divergence induced by CRPS agrees with Cramer's distance (Lemma \ref{lemma:CRPS}), and the squared energy distance is exactly twice Cramer's distance (Lemma \ref{lem:CTM}).   
\end{remark}

\begin{example}
For a univariate Gaussian density $\postr = \mathcal{N}(m,\sigma^2)$, the CRPS with respect to a single observation $v$ has the form 
$$\CRPS(\postr,v) = \sigma \left(2\phi\left(\frac{v - m}{\sigma}\right) + \frac{v - m}{\sigma} \left(2\Phi\left(\frac{v - m}{\sigma} \right) - 1 \right) - \frac{2}{\sqrt{\pi}} \right),$$
where $\phi$ and $\Phi$ denote the probability density function and cumulative density function of a standard Gaussian distribution, respectively. One can observe that the CRPS is minimized for the forecast chosen to have the observation $v$ near the mean $m$ with a small-enough variance to maximize precision.
\end{example}

\subsection{Quantile Score}\index{quantile score}

To motivate the {\em quantile score}\index{quantile score} we demonstrate how the 
{\em quantile function}\index{quantile function} can be derived through a minimization 
problem. To this end let $\alpha \in [0,1].$  Start by defining the $\alpha-$parameterized family of 
functions $\ha: \R \to \R$ by 
\begin{equation}
\ha(u)=\begin{cases}
-(1-\alpha)u, & \quad u<0,\\
\alpha u, & \quad u \ge 0.
   \end{cases}
\end{equation}
Function $\ha$ is sometimes termed the {\em hinge loss}\index{hinge loss}.
The hinge loss may also be written
\begin{equation}
\ha(u)=\begin{cases}
(1-\alpha)|u|, & \quad u<0,\\
\alpha|u|, & \quad u \ge 0,
\end{cases}
\end{equation}
or as 
\begin{equation} \label{eq:hingeloss}
\ha(u)=-(\mathbb{1}_{u\leq 0}-\alpha)u.  
\end{equation}
Using this function we define another $\alpha-$parameterized family of functions $\La: \R \to \R$ by
\begin{equation}
\La(\theta)= \bbE^{v \sim \postv} \bigl[ \ha(v-\theta) \bigr].
\end{equation} 


\begin{definition}
Given a probability density function $\postv$ corresponding
to a random variable on $\R$ with cumulative density function $\Fv$, the corresponding \emph{quantile function}\footnote{For ease of presentation, we assume throughout invertibility of the cumulative density function; the ideas generalize to the non-invertible case by considering the generalized inverse distribution function.} 
is $\qv(\alpha):=\Fv^{-1}(\alpha)$. 
\end{definition}

The quantile function is solution to the $\alpha-$parameterized family of equations 
$\Fv\bigl(\qv(\alpha)\bigr)=\alpha.$ The next lemma shows that this quantile function (of $\alpha$) is also the minimizer of $\La$ (viewed as a function of $\alpha$).

\begin{lemma}
\label{l:q}
For $\alpha \in [0,1],$ it holds that $${\rm argmin}_{\theta \in \R}\,\La(\theta) = \qv(\alpha).$$
\end{lemma}

\begin{proof}
First note that
$$\La(\theta)=(\alpha-1)\int_{-\infty}^\theta (v-\theta)\postv(v) \, dv +
\alpha\int_\theta^\infty (v-\theta)\postv(v) \, dv.$$
Differentiating with respect to $\theta$ yields
\begin{align*}
    \frac{d}{d\theta}\La(\theta)&=(1-\alpha)\int_{-\infty}^\theta \postv(v) \, dv -
\alpha\int_\theta^\infty \postv(v)\, dv\\
&=\int_{-\infty}^\theta \postv(v) \, dv-\alpha\\
&=\Fv(\theta)-\alpha.
\end{align*}
Setting the derivative to zero yields the desired result.
\end{proof}



\begin{definition}
For $\postr \in \cP(\R),$ the {\em quantile score}\index{quantile score} at level $\alpha$, 
verified against $v \sim \postv$, is defined as
 \begin{equation}
\label{eq:q}
    \QS_\alpha(\postr, v) \coloneqq \left(\mathbb{1}_{v \leq \qr(\alpha)} - \alpha\right)(\qr(\alpha) - v).
\end{equation} 
\end{definition}
We  define the expected quantile score 
$\overline{\QS}_{\alpha} \colon \cP(\R) \times \cP(\R) \rightarrow \R$ by
\begin{equation*}
    \overline{\QS}_{\alpha}(\postr,\postv) \coloneqq \mathbb{E}^{v \sim \postv}[\QS_{\alpha}(\postr, v)] = \int \QS_{\alpha}(\postr, v) \postv(v) \, dv.
\end{equation*}



The quantile score arises from evaluating the hinge loss in~\eqref{eq:hingeloss} at $u = v - F_\rho^{-1}(\alpha),$ i.e.  $\QS_\alpha(\postr, v) = h_\alpha \bigl(v - F_\rho^{-1}(\alpha) \bigr).$ 
Note that constant function taking value $v$ in $(0,1)$ is the quantile
function associated with the Dirac mass at $v$: for $\alpha \in (0,1),$ we have that $F^{-1}_{\delta_v}(\alpha) = \inf\{ u: F_{\delta_v}(u) \ge \alpha \} = v,$ where here we have used the generalized inverse distribution.  
Thus equation \eqref{eq:q} is comparing the value of two quantile functions evaluated at $\alpha.$
The following is a direct consequence of Lemma~\ref{l:q}:

\begin{proposition}
Define
$$\postr^\star={\rm argmin}_{\postr}\, \overline{\QS}_\alpha(\postr, \postv).$$
Then, for all $\alpha \in [0,1],$ $\postr^\star=\postv$
is a solution of the minimization problem.
\end{proposition}

\begin{proof}
Note that 
\begin{align*}
    \bbE^{v\sim \postv}[\QS_\alpha(\postr, v)]&= \bbE^{v\sim \postv}\Bigl[h_\alpha \bigl(v - F_\rho^{-1}(\alpha) \bigr) \Bigr] \\
    &=\La\bigl(\qr(\alpha)\bigr).
\end{align*} 
By Lemma \ref{l:q} the optimal $\rho$ will be one for
    which $q_\rho(\alpha)=\qv(\alpha).$ 
    This can be achieved by setting $\postr=\postv.$
\end{proof}

The following result shows the CRPS can also be computed as twice the integral of the quantile score over all quantiles.
\begin{lemma}\label{lemma:CRPSquantile}
\begin{equation*}
    \CRPS(\postr, v) = 2\int_0^1 \QS_\alpha(\postr, v)\,d\alpha.
\end{equation*}
Hence
\begin{equation*}
    \overline{\CRPS}(\postr, \postv) = 2\int_0^1 \overline{\QS}_\alpha(\postr, \postv)\,d\alpha.
\end{equation*}

\end{lemma}
\begin{proof} Applying the change of variables $u = \Fr^{-1}(\alpha)$ to the integrated quantile score with $d\alpha = \rho(u) \, du$, we have
\begin{align*} 
2\int_0^1 \QS_\alpha(\postr, v)\,d\alpha &= 
\int_0^1 2\left(\mathbb{1}_{v\leq \Fr^{-1}(\alpha)} - \alpha\right) \left(\Fr^{-1}(\alpha) - v \right) \, d\alpha  \\
&= 2\int_{\R} \bigl(\mathbb{1}_{v\leq u} - \Fr(u)\bigr)(u - v)\rho(u) \, du.
\end{align*}
We recognize that, for $u \ne v$, $\frac{d}{du}\bigl(\mathbb{1}_{v\leq u} - \Fr(u)\bigr)^2 = -2\bigl(\mathbb{1}_{v\leq u} - \Fr(u)\bigr)\rho(u)$. Applying integration by parts gives us 
\begin{align*}
    2\int_0^1 \QS_\alpha(\postr, v)\,d\alpha &= 
    -\int_{\R} \frac{d}{du}\left(\mathbb{1}_{v\leq u} - \Fr(u)\right)^2(u - v) \, du  \\
   & = \bigl(\mathbb{1}_{v\leq u} - \Fr(u)\bigr)^2 (u-v) \Bigl|_{u = -\infty}^{u = \infty} + \int_{\R} \bigl(\mathbb{1}_{v\leq u} - \Fr(u)\bigr)^2 \, du. 
\end{align*}
Now we claim that the boundary terms in the integration by parts vanish. Indeed, by Markov's inequality it holds that $1 - F_\postr(u) \le \frac{\Expect^{w \sim \postr}|w|}{u}$ and so $\bigl(1 - F_\postr(u) \bigr)^2 u  \to 0$ as $u \to \infty. $ The limit as $u \to -\infty$ is similar. Hence, we have shown that
\begin{align*}
    2\int_0^1 \QS_\alpha(\postr, v)\,d\alpha &= \int_{\R} \bigl(\mathbb{1}_{v\leq u} - \Fr(u)\bigr)^2 \, du =  \CRPS(\postr, v),
\end{align*}
as desired.
\end{proof}

\subsection{Logarithmic Score}\index{logarithmic score}\index{ignorance|see{logarithmic score}}

The logarithmic score evaluates the negative logarithm of the forecast probability density function at a sample $v \sim \postv:$
\begin{definition}
The \emph{logarithmic score} is
\begin{equation}\label{eq:log_score}
    \mathsf{LS}(\postr,v) \coloneqq -\log\postr(v).
\end{equation}
\end{definition}
We define the expected logarithmic score
$\overline{\LS} \colon \cP(\Ru) \times \cP(\Ru) \rightarrow \R$ by
\begin{equation*}
    \overline{\LS}(\postr,\postv) \coloneqq \mathbb{E}^{v \sim \postv}[\LS(\postr, v)] = \int \LS(\postr, v) \postv(v) \, dv.
\end{equation*}
The logarithmic score is also sometimes referred to as the \emph{ignorance} when the logarithm is in base 2. Notice that the logarithmic score penalizes heavily forecasts $\postr$ that place low probability in outcomes that materialize: for small $\postr(v),$ $ \mathsf{LS}(\postr,v) \coloneqq -\log\postr(v)$ is very large. 

\begin{lemma}
The logarithmic score is a strictly proper scoring rule.
The divergence resulting from the expected logarithmic score is the KL divergence\index{divergence!Kullback--Leibler} in Definition~\ref{def:KL} between $\postv$ and $\postr$:
\begin{equation}
    \dkl(\postv\|\postr) = \overline{\LS}(\postr, \postv) - \overline{\LS}(\postv, \postv).\label{eq:logscore_kl}
\end{equation}
\end{lemma}

\begin{proof}
We have that
\begin{align*}
\overline{\mathsf{LS}}(\postr, \postv)&=\mathbb{E}^{v\sim \postv} [\mathsf{LS}(\postr, v)]=-\int \log \postr(v) \postv(v)\, dv,\\
\overline{\mathsf{LS}}(\postv, \postv)&=\mathbb{E}^{v\sim \postv}[\mathsf{LS}(\postv, v)]=-\int \log \postv(v) \postv(v) \, dv.
\end{align*}
Recalling that
$$\dkl(\postv \|\postr)=\int\log\biggl(\frac{\postv(v)}{\postr(v)}\biggr)\postv(v) \, dv$$
delivers the desired result.
\end{proof}

\subsection{Dawid--Sebastiani Score}\index{Dawid--Sebastiani score}
The Dawid--Sebasatiani score controls the first and second moments of the forecast:
\begin{definition}
The \emph{Dawid--Sebastiani} score is  
\begin{equation}\label{eq:ds_score}
    \mathsf{DS}(\postr,v) := |v - m|_C^2 + \log \bigl(\det(C)\bigr),
\end{equation}
where $m$ and $C$ are the mean and covariance of $\postr$. 
\end{definition}
It is easy to verify that the Dawid--Sebastiani score is equivalent (up to a linear transformation) to the logarithmic score in the Gaussian case, but can be used for general distributions with finite mean and covariance.
The Dawid--Sebastiani score is proper, but not strictly proper.
This is similar to the $\ES_2$ score, which reduces to controlling the first moment; the Dawid--Sebastiani score
controls first and second moments.

\subsection{Noise in the Verification}\label{sec:scores_noise}\index{scoring rules!noisy verification}

In the presence of noise in the verification, the scoring rule will generally favor more dispersed forecasts than if the noise were not present. To account for this noise, either the forecast distribution or the scoring rule itself can be modified using knowledge about the noise distribution.

Suppose that the true value of the predictand is $v \sim \postv$, but that the verification is given by $\widetilde{v} | v\sim r$, where $r(\widetilde{v} | v)$ is the conditional noise distribution. We can then modify the definition of propriety  \ref{def:proper_score} as follows:\index{scoring rules!proper}
\begin{definition}
    A scoring rule $\mS$ is called proper with respect to the noise distribution $r$ if for all $\postr$, $\mathbb{E}^{\widetilde{v}\sim \widetilde{\postv}} \bigl[{\mS}(\postv, \widetilde{v}) \bigr] \leq \mathbb{E}^{\widetilde{v}\sim \widetilde{\postv}} \bigl[  \mS(\postr,\widetilde{v}) \bigr]$, where $\widetilde{\postv}(\widetilde{v}) = \int r(\widetilde{v} | v) \postv(v) \, dv$. It is called strictly proper when equality holds if and only if $\postr = \postv$.
\end{definition}

\begin{proposition}
    If $\mS$ is proper, then $\widetilde{\mS}(\postr, \widetilde{v}) := \mS(\widetilde{\postr}, \widetilde{v})$  is proper with respect to $r$, where 
    \begin{equation*}
        \widetilde{\postr}(\widetilde{v}) := \int r(\widetilde{v} | v) \postr(v) \, dv.
    \end{equation*}
\end{proposition}
\begin{proof}
    We have
    \begin{align*}
        \mathbb{E}^{\widetilde{v}\sim \widetilde{\postv}} \bigl[ \widetilde{\mS}(\postr,\widetilde{v}) \bigr] &= \mathbb{E}^{\widetilde{v}\sim \widetilde{\postv}} \bigl[\mS(\widetilde{\postr}, \widetilde{v}) \bigr]\\
        &\geq \mathbb{E}^{\widetilde{v}\sim \widetilde{\postv}} \bigl[\mS(\widetilde{\postv},\widetilde{v}) \bigr]\\
        &= \mathbb{E}^{\widetilde{v}\sim \widetilde{\postv}} \bigl[ \widetilde{\mS}(\postv,\widetilde{v}) \bigr],
    \end{align*}
    where the second line follows from the propriety of $\mS$.
\end{proof}

Note that propriety does not guarantee an accurate ranking of forecast distributions if the forecast distributions are evaluated on verifications with different levels of noise. To ensure this property, the scoring rule must be modified for each level of noise such that the expected score is the same as it would be if there were no noise. A scoring rule possessing this property is known as \emph{unbiased}.


\subsection{Distance-Like Deterministic Scoring Rule}
\label{ssec:dldsc}
\begin{definition}\label{def:det_score}
    We call a function $\D(\cdot, \cdot): \Ru\times\Ru\to\mathbb{R}$ a \emph{distance-like deterministic scoring rule}
    \index{scoring rule!distance-like deterministic} 
    if it satisfies the following three properties for all $u, v \in \Ru:$
    \begin{enumerate}
        \item Non-negative: $\D(u, v) \ge 0.$ 
        \item Positive: $\D(u, v) = 0$ if and only if $u = v.$
        \item Symmetric: $\D(u, v) = \D(v, u).$ 
    \end{enumerate}
\end{definition}

\begin{example}
Let   $\D(u,v)=\|u-v\|^p$ for any norm $\|\cdot\|$ on $\Ru$ and any $p \in (0,\infty).$ Then $\D(\cdot,\cdot)$ is a distance-like scoring rule.\index{scoring rule!distance-like} 
\end{example}



\section{Bibliography}
\label{sec:12bib}

We recommend the paper \cite{gibbs2002choosing}  for study of 
metrics, and other distance-like functions, including divergences,
on the set of probability measures. The paper \cite{chen2023gradient} contains proof of the 
assertion made in Remark \ref{rem:yifan}.
The energy distance is overviewed in \cite{szekely_energy_2013}.
Relationships between energy distance and MMD may be found in \cite{sejdinovic2013equivalence}. An efficient algorithm to compute gradients of the energy distance is provided in \cite{hertrich_generative_2024}.
Relating the characteristic property (and universal property of positive definite kernels) to mean embedding of measures is the subject of \cite{sriperumbudur2011universality}.
An overview of probabilistic scoring rules is given in \cite{gneiting2007strictly}. The CRPS was first introduced in \cite{brown_admissible_1974} and \cite{matheson_scoring_1976}. The relationship between the quantile score and the CRPS stated in Lemma \ref{lemma:CRPSquantile} can be found in \cite{laio2007verification}; see also \cite{fakoor2023flexible,gneiting_comparing_2011}. The discussion of bias in the ensemble CRPS is given in \cite{fricker_three_2013}. 
Closed-form expressions for the CRPS for various distributions are given in \cite{jordan_evaluating_2019}, and references to some additional known expressions are given in Table 9.7 of \cite{wilks_statistical_2019}.
Although not employed here, we mention the Fréchet inception distance from \cite{heusel2017gans} 
which is widely used to evaluate image generation.

Reproducing  kernel Hilbert spaces have become a useful framework to understand and develop theoretical results for machine learning methods. The background and properties of RKHSs can be found in~\cite{berlinet2011reproducing,smola1998learning};
see also~\cite{muandet2017kernel} for a broad survey on kernel mean embeddings. Some applications of RKHSs in machine learning include comparing distributions based on two-sample tests from estimators for the maximum-mean discrepancy~\cite{gretton2012kernel} and measuring (conditional) dependence between random variables~\cite{gretton2005measuring}. The statistical properties of maximum mean discrepancy have also made it a popular metric for generative modeling~\cite{genevay2018learning}.

A framework for scoring rules in the presence of observation error in the verification is given in \cite{ferro_measuring_2017}.
An extensive discussion of scoring rules, with focus on meteorological applications, is given in  Chapter 9 of \cite{wilks_statistical_2019}. The relationship between the CRPS and the spread--error relationship is discussed in \cite{leutbecher_understanding_2021}.
The identity \eqref{eq:CTM} is proved by 
using Proposition 2 in \cite{szekely_energy_2013}. Another quantity that is widely used in the verification of spatial fields, particularly in weather forecasting, is the anomaly correlation coefficient~\cite{murphy1989skill,wilks_statistical_2019}.

\chapter{\Large{\sffamily{Unsupervised Learning and Generative Modeling}}}
\label{ch:UL}




In the field of \index{unsupervised learning}{\em unsupervised learning} the following data  assumption is made:
\begin{dataassumption}\label{assumption:unsupervised}
We have available data in the form
\begin{align}
\label{eq:datau}
U:=\{\un\}_{n=1}^N,
\end{align}
assumed to be drawn \index{i.i.d.}i.i.d. from probability density function $\Upsilon$ on $\R^d$ which is unknown.
\end{dataassumption}

Through the data, we have access to the empirical density 
\begin{align}
\label{eq:emp}
\mn(u)=\frac{1}{N} \sum_{n=1}^N \delta(u-\un).
\end{align}
The goal is to understand the data set
summarized by measure $\mn.$ One widely used approach is to study
{\em clustering}\index{clustering} within the data; we will not
pursue this important topic because it is not of direct relevance
to the solution of \index{inverse problem}inverse problems and
\index{data assimilation}data assimilation, our focus in these notes.
Instead we pursue the approach of \index{generative model}{\em generative modeling}: we try and create new samples from $\Upsilon$, given $\mn.$ 
We illustrate the idea of  generative modeling with two examples.

\begin{example}
\label{ex:g1}
A natural starting point for generative modeling is to discuss 
\emph{density estimation}\index{density estimation}. This methodology
seeks to approximate $\Upsilon(u)$, from within some class of densities, on the
basis of the data summarized in $\mn(u).$ The goal is not always generative modeling:
it may be to have a smooth density which can be differentiated or otherwise manipulated
in a way that $\mn(u)$ cannot. However, some classes of approximate $\Upsilon$ can be used
to generate new samples. An example is when the approximation is a Gaussian mixture.
\end{example}


\begin{example}
\label{ex:g2}
We introduce the {\em measure transport}\index{measure transport} task of determining
function $g: \R^{\dz} \to \R^d$ so that, given 
probability density function $\zeta$ on $\R^{\dz}$ and probability density function $\Upsilon$ on $\R^d$,
$g_\sharp \zeta = \Upsilon;$ here $g_\sharp$ denotes the 
pushforward\index{pushforward}  operation\footnote{Recall that pushforward is defined in the preface.}
and so, explicitly, we are seeking $g$ so that, if $z \sim \zeta$, then
$g(z) \sim \Upsilon.$ 
The task of identifying $g$ must be undertaken empirically, since only $\mn$ is available to us, not $\Upsilon.$
A common setting is to assume that $\zeta$ is \index{Gaussian}Gaussian. Then the aim is to find map $g$ so that samples
from \index{Gaussian}Gaussian $\zeta$, when pushed forward under $g$, will look like
samples from $\Upsilon$. 
We will also study relaxations of this problem, in which the
\index{Gaussian}Gaussian $\zeta$ is convolved with a \index{Gaussian}Gaussian whose mean is function $g$. 
\end{example}


In Section \ref{sec:den} we describe the subject of density estimation, introduced in
Example \ref{ex:g1}, and taking a particular perspective on it which links to several
themes arising in other places in the notes. In the remainder of the chapter
we study variants on the idea illustrated in Example \ref{ex:g2}.
All the methods connect the target measure $\Upsilon$, which we 
wish to sample, and defined on $\Ru$, to a measure on a latent
space $\R^{\dz}.$
In Section \ref{sec:transport2} we study a general approach to measure transport akin to the density estimation approach studied in Section \ref{sec:den}; typically these methods employ $\dz=d.$  Normalizing flows are studied in \ref{sec:NORM}; whilst $\dz \ne d$ is possible here too, in the continuum limit, using neural ODEs, this methodology has at its core an invertible mapping with $\dz=d.$ In Section \ref{sec:score} we study score-based approaches that build on Langevin sampling. 
Sections \ref{sec:auto} and \ref{sec:vauto}
introduce autoencoders and variational autoencoders respectively,
where an approximate inverse for $g$ is sought, although typically
$\dz<d$ so caution is required to define this carefully. Generative adversarial networks
(GANs) are introduced in Section \ref{sec:gan}, applicable with $\dz \ne d.$


\section{\index{density estimation} Density Estimation}\label{sec:den}

Consider the problem of estimating the probability density function
underlying data $\UN:=\{\un\}_{n=1}^N$;
we assume the data points $\un \in \R^d$ are drawn i.i.d. from the same
distribution.
Let $\cP(\R^d)$  denote the set of all probability density functions on $\R^d.$
We seek to solve the problem by finding a probability density function from 
a tractable class of probability distributions $\mathcal{Q} \subset \cP(\R^d)$,  
for the purpose of computations and for the
purpose of revealing an explicit, interpretable form. To be concrete we
assume that, for $\Theta \subseteq \R^p$, $\cQ$ comprises a set of probability
density functions $q(\cdot;\theta) \in \cP(\R^d)$  for each $\theta \in \Theta.$

Our objective is to find $\bbP(\theta|U)$ by applying Bayesian inference, as in
Chapter \ref{ch1}. If we place prior $\bbP(\theta)$ on unknown parameter $\theta,$ 
then, noticing that $\bbP(\UN|\theta)=\Pi_{n=1}^N\, q(\un;\theta)$, we obtain from Theorem \ref{t:bayes} that
\begin{equation}
    \label{eq:denb}
  \bbP(\theta|\UN) \propto   \Pi_{n=1}^N\, q(\un;\theta) \bbP(\theta).
\end{equation}


If we seek a maximum a posteriori (\index{MAP estimator}MAP) estimator for $\theta,$
then, following the developments in Section \ref{sec:112},
\begin{align*}
\thetas &\in \argmin_{\theta\in \Theta} \J_{\mbox{\tiny{\rm{MAP}}}}^N(\theta),\\
\J_{\mbox{\tiny{\rm{MAP}}}}^N(\theta) &= - \sum_{n=1}^N\, \log q(\un;\theta) -\log \bbP(\theta).
\end{align*} 
Indeed in the nomenclature of Section \ref{sec:112} the first term 
in the definition of $\J_{\mbox{\tiny{\rm{MAP}}}}^N(\cdot)$ is the loss function\index{loss function} \eqref{eq:loss}
and the second is the regularizer\index{regularizer} \eqref{eq:reg}. If we drop the regularizer,
corresponding to what is sometimes termed a \emph{flat prior}\index{prior!flat},
then we obtain the maximum likelihood estimation (MLE)\index{maximum likelihood estimation}
problem
\begin{align*}
\thetas &\in \argmin_{\theta\in\Theta} \J_{\mbox{\tiny{\rm{MLE}}}}^N(\theta),\\
\J_{\mbox{\tiny{\rm{MLE}}}}^N(\theta) &= - \sum_{n=1}^N\, \log q(\un;\theta).
\end{align*} 
This MLE may be derived by an alternative methodology. Consider the minimization
problem
\begin{align*}
\thetas &\in \argmin_{\theta\in\Theta} \F(\theta),\\
\F(\theta) &= \dkl\bigl(\Upsilon \|q(\cdot;\theta)\bigr).
\end{align*} 
Notice that the KL divergence defining the objective $\F$ is given by 
$$\dkl \bigl(\Upsilon \| q(\cdot;\theta)\bigr)=\bbE^{u \sim \Upsilon}\Bigl[\log \Upsilon(u)-\log q(u;\theta)\Bigr],$$
which involves the unknown density $\Upsilon.$ However, since optimization is over the parameter $\theta$ in the density $q(\cdot; \theta)$, minimizing $\F$ over $\theta$ is the same as minimizing 
$$-\bbE^{u \sim \Upsilon} \Bigl[ \log q(u;\theta) \Bigr]$$
over $\theta.$ Replacing expectation with respect to $\Upsilon$ with expectation with respect to the empirical density $\mn$ defined in \eqref{eq:emp}, we obtain 
$$-\bbE^{u \sim \mn} \Bigl[ \log q(u;\theta) \Bigr] = - \frac{1}{N} \sum_{n=1}^N\, \log q(\un;\theta) =  \frac{1}{N}\J_{\mbox{\tiny{\rm{MLE}}}}^N(\theta).$$






\section{Transport Methods}\label{sec:transport2}

\index{transport}
Let $\Upsilon, \zeta \in \mathcal{P}(\R^d)$. 
We now consider the task of finding invertible 
$g: \R^d \to \R^d$ with the property that $\Upsilon \approx g_\sharp \zeta$; equivalently, since $g$ is invertible, $\zeta \approx (g^{-1})_\sharp \Upsilon.$
We seek to determine a parameter such that $g$ chosen from the parametric class $g: \R^d \times \Theta \to \R^d$, with 
$\Theta \subseteq \R^{p},$ realizes this approximation. 
To this end we consider the optimization problem 
\begin{align*}
\thetas &\in \argmin_{\theta \in \Theta} \F(\theta), \\
\F(\theta)&=\dkl \bigr(\Upsilon \| g(\cdot; \theta)_\sharp \zeta \bigl).
\end{align*}
We define the resulting approximate pushforward\index{pushforward} 
map by $\gs=g(\cdot;\thetas).$
Notice that this approach agrees with the density estimation approach in Section \ref{sec:den}, now parameterizing the approximating densities $q(\cdot; \theta) = g(\cdot;\theta)_\sharp \zeta$ as pushfoward of a fixed reference density $\zeta$ by a parameterized transport map $g(\cdot ; \theta).$


\begin{remark}
Note that there exist perfect transport maps $g_{\rm perfect}$,
for example an \index{optimal transport}optimal transport,
for which $\dkl(\Upsilon \| (g_{\rm perfect})_\sharp \zeta)=0$. We aim
to get as close as possible to a perfect transport solution, within our
parametric class, by minimizing $\F$ over $\theta.$ In practice, when $\Upsilon$ is unknown this task needs to be undertaken based on the data summarized in the empirical measure $\mn.$
Whilst \index{optimal transport}optimal transport---studied in Section \ref{sec:OPT} in the context of transport distances between probability distributions---provides a deep mathematical structure within which to consider the \index{transport!measure}measure transport problem, there are numerous applications where the optimality constraint on the transport confers
few advantages over other transports, and may unnecessarily complicate the computational task of finding the transport. For these reasons, in this chapter we focus on  other approaches to transport that relax the optimality constraint, but preserve the core idea of sampling probability distributions by constructing transports from a known distribution (that we know how to sample) to the target, and in particular
they resonate with the Monge formulation of optimal transport.
\index{optimal transport!Monge}
\end{remark}
As in Section \ref{sec:den},  to optimize $\F(\cdot)$ we will identify $\J(\cdot)$, 
a function which differs from the KL divergence only by a constant independent of $\theta,$
and optimize $\J(\cdot).$
Lemma \ref{lem:cov} is useful in determining an explicit form
of $\J$ for computational purposes.
We now use this lemma to find a pair of expressions for $\J(\cdot)$ that are 
useful for a variety of specific instances 
of the general measure transport problem of interest. 
Using the expression for the KL divergence we find that
$$\F(\theta)=\dkl \bigr(\Upsilon \| g(\cdot; \theta)_\sharp \zeta \bigl)  = \bbE^{u \sim \Upsilon} \Bigl[\log \Upsilon(u) - \log g_\sharp \zeta(u)\Bigr].$$
Thus, noting that the desired minimization is independent of $\theta-$independent constants, and using (\ref{eq:cov}b) 
we define
\begin{equation}
\label{eq:OT}
\J(\theta) = -\bbE^{u \sim \Upsilon} \Bigl[\log \zeta \circ g^{-1}(u;\theta)+ \log {\rm det}  D_u(g^{-1})(u;\theta) \Bigr].
\end{equation}
Note that $\F(\theta)=\J(\theta)+c$ where constant $c$ is
independent of parameter $\theta$ to be optimized over.
Our desired minimization problem for $\F(\cdot)$ 
is thus equivalent to minimizing
\eqref{eq:OT}. Furthermore, using \eqref{eq:invd} in \eqref{eq:OT}, we may write
\begin{equation}
\label{eq:OT99}
\J(\theta)= -\bbE^{u \sim \Upsilon} \Bigl[\log \zeta \circ g^{-1}(u;\theta)- \log {\rm det}  D_u g\bigl(g^{-1}(u;\theta);\theta\bigr) \Bigr].
\end{equation}

\begin{remark}
\label{rem:discuss}
In practice, if $\Upsilon$ is only available empirically, objective
\eqref{eq:OT} or \eqref{eq:OT99} can be approximated as follows: 
\begin{align}
\label{eq:OT991}
\begin{split}
\J^N(\theta)&= 
-\frac{1}{N} \sum_{n=1}^N  \Bigl[\log \zeta \circ g^{-1}(u^{(n)};\theta)+ \log {\rm det}  D_u(g^{-1})(u^{(n)};\theta) \Bigr]\\
&=-\frac{1}{N} \sum_{n=1}^N \Bigl[\log \zeta \circ g^{-1}(u^{(n)};\theta)- \log {\rm det}  D_u g\bigl(g^{-1}(u^{(n)};\theta);\theta\bigr) \Bigr].
\end{split}
\end{align}


Then the \index{forward!map}forward map $\gs$ is obtained at $\theta^\star$ which minimizes $\J^N(\cdot)$.
By minimizing \eqref{eq:OT991} we thus find an approximate expression for $\Upsilon$, known only through samples, as the pushforward under $\gs$ of $\zeta.$ 
Once we have the map $\gs$ we can generate new (approximate)
samples from $\Upsilon$ by \index{sampling}sampling $\zeta$ and applying $\gs.$
An important point to note here is that, to determine 
$\gs$, minimization of either form of the loss function  $\J^N$ in \eqref{eq:OT991} 
requires evaluation of $g^{-1}.$ Thus $g$ must be readily invertible. 
Section \ref{sec:NORM} addresses this issue in the context 
of \index{normalizing flow}normalizing flows.
\end{remark}

\begin{remark}\label{rem:invparam}
The ideas in this section are also useful in the context where $\Upsilon$ is a known simple measure, from which samples are easily drawn, and $\zeta$ is a more complicated measure which we wish to characterize and sample from; in such a setting, which we consider in Section \ref{sec:LPrtoPo}, the objective is to determine $T=g^{-1}$ so that $\zeta=(g^{-1})_\sharp \Upsilon.$ Since \eqref{eq:OT} is expressed
entirely in terms of $T=g^{-1}$, and not $g$ itself, it is possible
to approach this problem by directly parameterizing $T=g^{-1}$ rather
than $g.$ 
\end{remark}

\section{\index{normalizing flow} Normalizing Flows}\label{sec:NORM}

The \index{transport}transport approach from Section \ref{sec:transport2} requires
invertibility of the map $g$, and efficient computation of the determinant
of the Jacobian. Invertibility of the map $g$ is also useful in other
contexts. \index{normalizing flow}Normalizing flows address this issue; \emph{normalizing}
reflects the fact that distribution $ \zeta$ is often a \index{Gaussian}Gaussian, whilst 
\emph{flow} connotes the breaking up of the map $g$  into a sequence of
simpler maps which are themselves parameterized, rather than
parameterizing $g$ itself. 

To this end we fix $J \in \mathbb{N}$ and introduce the iteration 
\begin{subequations}
\begin{align}
v_{j+1}&=H(v_j;\theta), \quad j=0,\dots,J-1, \\
v_0&=z,
\end{align}
\end{subequations}
where we define $u:=v_J$. Then 
$u=g(z;\theta)$ where 
\begin{equation}
    \label{eq:compose}
g(\cdot;\theta)=H(\cdot;\theta) \circ H(\cdot;\theta) \circ \dots \circ H(\cdot;\theta),
\end{equation}
the $J-$fold
composition of $H(\cdot;\theta)$. 
The proposed method is thus simply a transport of the type
discussed in Section \ref{sec:transport2}, with a specific
construction of $g$ in compositional form. The remainder of
the section comprises two components: firstly showing
specifics of the formulation of the minimization problems
\eqref{eq:OT} or \eqref{eq:OT99} in this compositional
setting; and secondly showing a continuum limit of the
compositional setting, which recovers neural ODEs\index{neural ODEs}.

\subsection{Structure in the Optimization Problem for $\theta$}


We assume that $H(\cdot;\theta)$ 
is invertible, with inverse
$H^{-1}(\cdot;\theta)$, and differentiable, with 
derivative $DH(\cdot;\theta)$. 
Assume that $z \sim \zeta$ and let $p_j(v_j)$ 
denote the density of $v_j$. Then the goal of normalizing
flow is to choose parameter $\theta$ in $H$ so that
$p_J \approx \Upsilon$ and hence (approximately)
$u \sim \Upsilon;$ this is potentially a more 
straightforward task than working with a directly parameterized $g,$ 
the approach described in Section \ref{sec:transport2}.



Formulae \eqref{eq:invd}, \eqref{eq:cov} show that, since $v_j=H^{-1}(v_{j+1};\theta)$, 
\begin{equation*}
\log p_{j+1}(v_{j+1}) = \log p_j(v_j) - \log {\rm det} DH(v_j;\theta).
\end{equation*} 
By induction, we obtain that
\begin{equation*}
\log p_{J}(v_{J}) = \log p_0(v_0) - \sum_{j=0}^{J-1} \log {\rm det} DH(v_j;\theta),
\end{equation*}
and hence
\begin{equation}
\label{eq:cov2}
\log g_\sharp \zeta(u)   = \log \zeta(z) - \sum_{j=0}^{J-1} \log {\rm det} DH(v_j;\theta),
\end{equation}
where $u=g(z;\theta)$ and $v_j=H^{(j)}(z;\theta)$, which we use to denote the $j-$fold composition of $H(\cdot;\theta)$.
Note that $v_j=(H^{-1})^{(J-j)}(u;\theta)$, the $(J-j)-$fold 
composition of $H^{-1}(\cdot;\theta).$
In particular $z$ is found as the $J-$fold
composition of $H^{-1}(\cdot;\theta)$  evaluated at $u$.

With these relationships defined between $(z,\{v_j\})$ and $u$, and
noting that they are parameterized by $\theta$, we obtain from 
the general loss function~\eqref{eq:OT99}
\begin{equation}
\label{eq:OT999}
\J(\theta)= -\bbE^{u \sim \Upsilon} \Bigl[\log \zeta(z)- \sum_{j=0}^{J-1}
\log {\rm det}  DH(v_j;\theta) \Bigr].
\end{equation}
As before we set
$$\thetas\in \argmin_{\theta \in \Theta} \J(\theta)$$
and define the resulting approximate pushforward\index{pushforward} map by 
$\gs=g(\cdot;\thetas).$
Note that $g(\cdot;\thetas)$ is found from the $J-$fold
composition of $H(\cdot;\thetas)$.  Again, in practice the expectation 
over $\Upsilon$ in \eqref{eq:OT999} can be approximated using the empirical density $\mn.$ 



\begin{remark}
\label{rem:nfna}
    The preceding setting can be generalized to one in which
    each map in the composition is different and carries its
    own set of parameters to be optimized, so that \eqref{eq:compose} is replaced by
    \begin{equation}
    \label{eq:compose2}
g(\cdot;\theta)=H_{J-1}\bigl(\cdot;\theta^{(J-1)}\bigr) \circ H_{J-2}\bigl(\cdot;\theta^{(J-2)}\bigr) \circ \dots \circ H_0\bigl(\cdot;\theta^{(0)}\bigr),
\end{equation}
and $\theta= \bigl\{\theta^{(j)} \bigr\}_{j=0}^{J-1}.$ 
\end{remark}


\subsection{Neural ODEs}
Neural ODEs\index{neural ODEs} map a probability distribution $\zeta$  on the initial condition into a probability distribution $g_\sharp \zeta$ on the solution of an ODE at time $t=1;$ here $g$ is the solution map of an ODE with flow defined by a parameterized vector field. 

A continuum limit of \index{normalizing flow}normalizing flows
can be used to construct neural ODEs. To this end we define  
\begin{align}
\label{eq:nfode}
\begin{split}
\frac{dv}{dt}&=h(v;\theta),\\
v(0)&=z.
\end{split}
\end{align}
Noting that $v(t)$ depends on $z$ we set $g_t(z;\theta)=v(t)$
and $g(z;\theta)=g_1(z;\theta)=v(1).$
An advantage of the continuum perspective is that the inverse 
of map $g$ is readily computed as follows. Define the equation
\begin{align*}
\frac{dw}{dt}&=-h(w;\theta),\\
w(0)&=u.
\end{align*}
Then $g^{-1}_t(u;\theta)=w(t)$ and, in particular, $g^{-1}(u;\theta)=w(1).$




\begin{lemma}
Assume that in \eqref{eq:nfode} the initial condition satisfies
$z \sim \zeta$. Then 
\begin{equation}
\label{eq:cov3}
\log g_\sharp \zeta(u)   = \log \zeta(z) - \int_0^1 
\div h\bigl(v(s);\theta\bigr) \, ds.
\end{equation}
\end{lemma}

\begin{proof}
This may be derived from the discrete \index{normalizing flow}normalizing flow, by setting
$H(\cdot;\theta)=\Id+\Delta t h(\cdot;\theta)$ where $J\Delta t=1$.
Note that this corresponds to an Euler approximation of the continuum 
picture in which $v_j \approx v(j\Delta t).$ Furthermore
$${\rm det} DH={\rm det}(I_d+\Delta t Dh)=1+\Delta t {\rm Tr} Dh
+{\mathcal O}(\Delta t^2).$$
Now note that ${\rm Tr}\, Dh=\div h.$ Thus,
substituting this expression for ${\rm det} DH$
into \eqref{eq:cov2}, expanding the logarithm in powers
of $\Delta t$, summing over $j$ and letting $\Delta t \to 0$ yields
the desired result.
\end{proof}


The continuum analog of \eqref{eq:OT999} is then 
\begin{equation}
    \label{eq:noopt}
\J(\theta)=
 -\bbE^{u \sim \Upsilon} \Bigl[\log \zeta(z)- \int_0^1 
\div h\bigl(v(s);\theta\big) \, ds \Bigr],
\end{equation}
where $z=g^{-1}(u;\theta)$ and $v(t)=g^{-1}_{1-t}(u;\theta).$ 
As before, up to an additive constant,
$\J(\theta)=\dkl(\Upsilon\|g_\sharp \zeta).$
Minimizing $\J$ over $\theta$, to obtain $\thetas$,
thus leads to $\gs(\cdot)=g(\cdot;\thetas)$ and
$(\gs)_\sharp \zeta \approx \Upsilon.$ 


\begin{remark}
\label{rem:nfna2}
Using the setting of Remark \ref{rem:nfna} leads
to a generalized form of neural ODE taking the form

\begin{align}
    \label{eq:nfodetimedep}
\begin{split}
\frac{dv}{dt}&=h\bigl(v,t;\theta(t)\bigr),\\
v(0)&=z.
\end{split}
\end{align}
Optimization is now over a function of time, $\theta(t)$, and
some form of regularization is needed to enforce continuity
of $\theta(\cdot)$. For example we may replace 
\eqref{eq:noopt} by
\begin{equation}
    \label{eq:noopt2}
\J(\theta)=
 -\bbE^{u \sim \Upsilon} \Bigl[\log \zeta(z)- \int_0^1 
\div h\bigl(v(s),s;\theta(s)\big) \, ds \Bigr]+\lambda
\int_0^1 \Bigl|\frac{d\theta}{dt}(s)\Bigr|^2 \, ds.
 \end{equation}
 Notice that $z=v_0$ and $v(s)$ are functions of $u$, defined by the backward
 evolution of the ODE \eqref{eq:nfodetimedep}. 
\end{remark}


\section{Score-Based Approaches}\label{sec:score}
We have overviewed a variety of techniques for generative modeling, starting with density estimation,
and then concentrating on various transport-based methods. An important
shift of perspective, leading to alternative methodologies, follows from understanding the role
of the Langevin equation\index{Langevin equation} 
in generating samples from a measure with probability density $\Upsilon:$ 
\begin{equation}
\label{eq:lan}
    \frac{du}{dt}=\nabla \log \Upsilon+\sqrt{2} \frac{dW}{dt}
\end{equation}
with $u(0) \sim \zeta.$ Under mild tail and smoothness assumptions on $\Upsilon$ this equation is ergodic: for suitable
classes of test function $\varphi:\R^d \to \R,$ we have almost surely that
$$\lim_{T \to \infty} \frac{1}{T}\int_0^T \varphi\bigl(u(t)\bigr) \, dt = \bbE^{u \sim \Upsilon} \bigl[\varphi(u)\bigr].$$
This suggests sampling via use of the gradient of its log-density $\nabla \log \Upsilon$, which is known as the \emph{score function}\index{score function}. Learning the score function
and solving the Langevin equation approximately provides one such method, but other variants on 
this are available and we now present some of them.


We would like to find a function $s_\theta \colon \R^d \rightarrow \R^d$  so that $s_\theta \approx \nabla \log \Upsilon.$ We are given only samples from $\Upsilon$: we do not assume access to the target density $\Upsilon$ itself. We assume that $\theta$ is chosen from set $\Theta \subseteq \R^p$. 
A natural objective results in the following regression problem:
\begin{subequations} \label{eq:score_matching_regression}
\begin{align}
  \J(\theta;\Upsilon) &= \int |s_\theta(u) - \nabla \log \Upsilon(u)|^2 \Upsilon(u) \, du,\\
  \thetas &\in \argmin_{\theta \in \Theta} \J(\theta).
\end{align}
\end{subequations}
Then $\ss=s_{\thetas}$ is the approximate score at the optimal $\theta.$ 

\begin{remark} Let $\Upsilon_\theta$ be a distribution whose score is given by $s_\theta = \nabla \log \Upsilon_\theta$. Then, the objective $\J$ corresponds to the squared \emph{Fisher divergence}\index{Fisher divergence} 
$$d_F(\Upsilon \|\Upsilon_\theta)^2 \coloneqq \int | \nabla \log \Upsilon_\theta(u) - \nabla \log \Upsilon(u)|^2 \Upsilon(u) \, du.$$
\end{remark}

This approach looks attractive, but since the true score is not available, approximate evaluation
of the objective $\J$, directly employing \eqref{eq:score_matching_regression}, is not feasible in practice. 
However, the following two propositions show that $\J$ can be minimized using a score-matching procedure that uses integration by parts to redefine the objective into one that only depends on $\Upsilon$ in an outer expectation that can be readily approximated using samples from $\Upsilon.$

\begin{proposition} Assume the score of $\Upsilon$ is square-integrable, i.e., $\int |\nabla \log \Upsilon(u)|^2 \Upsilon(u) \, du < \infty$. Then, the optimal score that minimizes $\J(\theta;\Upsilon)$ is given by $\ss=s_{\thetas}$
where
\begin{equation} \label{eq:score_matching_IBP}
  \thetas \in \argmin_{\theta \in \Theta} \int \Bigl(|s_\theta(u)|^2 +2 {\rm Tr}\bigl(\nabla s_\theta(u)\bigr)\Bigr) \Upsilon(u) \, du.  
\end{equation}
\end{proposition}

\begin{proof}
Expanding the Euclidean norm, the least-squares objective \eqref{eq:score_matching_regression} yields
\begin{align*}
\J(\theta;\Upsilon) 
&= \int \Bigl(|s_\theta(u)|^2 - 2\bigl\langle s_\theta(u), \nabla \log \Upsilon(u)\bigr\rangle + |\nabla \log \Upsilon(u)|^2\Bigr)\Upsilon(u) \, du.
\end{align*}
Using integration by parts and that $\Upsilon$ is a density which decays to zero as $|u| \rightarrow \infty$, we can write the second term as 
$$\int \bigl\langle s_\theta(u), \nabla \log \Upsilon(u)\bigr\rangle \Upsilon(u) \, du = 
\int  \bigl\langle s_\theta(u), \nabla \Upsilon(u) \bigr\rangle \, du = -\int \text{Tr}\bigl(\nabla s_\theta(u)\bigr)\Upsilon(u) \, du.$$
We can thus rewrite the objective $\J$ as 
\begin{subequations}
\begin{align*}
\J(\theta;\Upsilon) & = \int \Bigl(|s_\theta(u)|^2 + 2\text{Tr}\bigl(D s_\theta(u)\bigr)\Bigr) \Upsilon(u) \, du + K, \\
K &= \int |\nabla \log \Upsilon(u)|^2 \Upsilon(u) \, du.
\end{align*}
\end{subequations} 
Since $K$ is independent of $\theta$ and finite by assumption, we deduce that the minimizers of $\J(\theta;\Upsilon)$ coincide with those defined in \eqref{eq:score_matching_IBP}.   
\end{proof}

\begin{remark}
We note that, in contrast to \eqref{eq:score_matching_regression}, the objective 
\eqref{eq:score_matching_IBP} requires evaluation of 
the gradient of the approximate score function $\nabla s_\theta$, which is a Hessian matrix of size $d \times d$. This matrix can be challenging to compute and store in high-dimensions. However, one may leverage techniques from randomized linear algebra to estimate the trace of this matrix.
\end{remark}



The need to evaluate the Hessian can also be avoided by use of \emph{denoising score-matching}\index{score-matching!denoising}.  This approach estimates the score function for an approximate distribution defined by the convolution of $\Upsilon$ with a kernel $p_\sigma \colon \R^d \times \R^d \rightarrow \R_{+}$ that has bandwidth $\sigma > 0$. That is,
\begin{equation} \label{eq:smoothed_distribution}
\Upsilon_\sigma(u) \coloneqq \int p_\sigma(u,w) \Upsilon(w) \, dw.    
\end{equation}
For example, $p_\sigma$ can be a Gaussian kernel 
$$p_\sigma(w,u) \propto \exp\Bigl(-\frac{1}{2\sigma^2}|w - u|^2\Bigr).$$ 
This choice is motivated by the facts that: (i) for bandwidth $\sigma \rightarrow 0$ we
obtain that $p_\sigma$ converges to a Dirac measure and so $\Upsilon_\sigma(u)$ converges to $\Upsilon(u)$,
the original distribution; (ii) on the other hand, larger bandwidths smooth larger-scale features of $\Upsilon$. 
The following proposition shows that score matching for $\Upsilon_\sigma$ can be performed without knowing the score of $\Upsilon$ directly.

\begin{proposition} \label{prop:denoising_score_matching} Assume that 
\begin{equation*}\int |\nabla \log \Upsilon_\sigma(u)|^2 \Upsilon_\sigma(u) \, du + \int \int |\nabla_u \log p_\sigma(u,w)|^2 \Upsilon_\sigma(w,u) \Upsilon(u) \, dwdu < \infty.
\end{equation*}
Then, the optimal score that minimizes $\J(\theta;\Upsilon_\sigma)$ is given by $\ss=s_{\thetas}$ where
\begin{equation}
    \label{eq:definedin}
    \thetas \in \argmin_{\theta \in \Theta} \int \int |s_\theta(u) - \nabla_u \log p_\sigma(u,w)|^2 p_\sigma(u,w)\Upsilon(w) \, dudw.
\end{equation}
\end{proposition}

\begin{proof}
The score of the smoothed distribution $p_\sigma$ is given by
\begin{align*}
\nabla \log \Upsilon_\sigma(u) = \frac{\nabla \Upsilon_\sigma(u)}{\Upsilon_\sigma(u)} &= \frac{1}{\Upsilon_\sigma(u)}\int \nabla_u p_\sigma(u,w) \Upsilon(w) \, dw \\
&= \frac{1}{\Upsilon_\sigma(u)}\int \nabla_u \bigl(\log p_\sigma(u,w)\bigr) p_\sigma(u,w) \Upsilon(w) \, dw.
\end{align*}
Thus, the inner product of $s_\theta$ and the score of the smoothed distribution is given by
$$\int \bigl \langle s_\theta(u), \nabla \log \Upsilon_\sigma(u) \bigr \rangle \Upsilon_\sigma(u) \, du = \int \int \bigl \langle s_\theta(u), \nabla_u \log p_\sigma(u,w) \bigr \rangle p_\sigma(u,w) \Upsilon(w) \, dwdu.$$
Furthermore
$$ \int |s_\theta(u)|^2 \Upsilon_\sigma(u) \, du= \int \int |s_\theta(u)|^2  p_\sigma(u,w) \Upsilon(w) \, dwdu$$
by definition of $\Upsilon_\sigma.$
Substituting the two preceding expressions into the objective $\J(\theta;\Upsilon_\sigma)$ gives
\begin{align*}
    \J(\theta;\Upsilon_\sigma) &= \int \int |s_\theta(u) - \nabla_u \log p_\sigma(u,w)|^2 p_\sigma(u,w)\Upsilon(w) \, dudw+K,\\
    K &= \int |\nabla \log\Upsilon_\sigma(u)|^2 \Upsilon_\sigma(u) \, du  - \int \int|\nabla_u \log p_\sigma(u,w)|^2 p_\sigma(u,w)\Upsilon(w) \, dudw.
\end{align*}
Noting that $K$ is independent of $\theta$ and finite by assumption, we deduce that the minimizers of $\J(\theta;\Upsilon_\sigma)$ coincide with those defined in \eqref{eq:definedin}.
\end{proof}

The score of smoothed distribution $\Upsilon_\sigma$ that is computed by Proposition~\ref{prop:denoising_score_matching} can also be expressed in terms of a conditional expectation of the underlying random variables. The next lemma presents this result, which is known as \emph{Tweedie's formula}\index{Tweedie's formula}. 

\begin{lemma} \label{lem:tweedie} Let $u = w + \sigma \eta$ where $w \sim \Upsilon$ and $\eta \sim \mathcal{N}(0,I_d)$. Define $\pi^w$ to be the posterior density\footnote{Note that this is the correct normalization 
by~\eqref{eq:smoothed_distribution}.}
$$\pi^w(w|u) = \frac{1}{\Upsilon_\sigma(u)} p_\sigma(u,w)\Upsilon(w),$$
where $p_\sigma$ is the Gaussian kernel. 
Then the score $\nabla \log \Upsilon_\sigma(u)$ satisfies the identity 
\begin{equation}
\label{eq:othertweedie}
\mathbb{E}^{w \sim \pi^w}[w] = u + \sigma^2 \nabla \log \Upsilon_\sigma(u).
\end{equation}
\end{lemma}

\begin{proof}
First note that the score of the Gaussian kernel is
$$\nabla_u \log p_\sigma(u,w) = -\frac{(u - w)}{\sigma^2}.$$
Using this we can write the score of the smoothed distribution as 
\begin{align*}
\nabla \log \Upsilon_\sigma(u) &= \frac{1}{\Upsilon_\sigma(u)}\int \nabla_u \bigl( \log p_\sigma(u,w)\bigr) p_\sigma(u,w) \Upsilon(w) \, dw \\
&= \int \frac{-(u - w)}{\sigma^2} \frac{p_\sigma(u,w) \Upsilon(w)}{\Upsilon_\sigma(u)} \, dw \\
&= \frac{1}{\sigma^2}\mathbb{E}^{w \sim \pi^w}[w - u],
\end{align*}
and the desired result follows.
\end{proof}

Tweedie's formula shows that computing a score function is related to an inverse problem. It may be rearranged
to give:
$$\nabla \log \Upsilon_\sigma(u)=\frac{1}{\sigma^2}\Bigl(\mathbb{E}^{w \sim \pi^w}[w] - u\Bigr).$$
Given a noisy realization $u$ of the random variable $w,$ the score is given in terms of the conditional expectation $\mathbb{E}[w|u]$, which is the posterior mean for the unknown $w$. Notice that $\mathbb{E}[w|u]$ is the function of $u$ that minimizes $\mathbb{E} | w - \phi(u) |^2$ over measurable maps $\phi: \R^d \to \R^d.$ Thus, to learn $D\log \Upsilon_\sigma(u)$ we can seek parameterized map $\phi_\theta: \R^d \times \Theta \to \R^d$ that minimizes $\mathbb{E} | w - \phi_\theta(u) |^2.$ This problem can be empirically approximated without having access to the density $\Upsilon$. Specifically, given only data $\{w^{(n)}\}_{n=1}^N $ independently sampled from $\Upsilon,$ we set $u^{(n)}:= w^{(n)} + \sigma \eta^{(n)},$ where $\eta^{(n)} \sim \mathcal{N}(0,I_d)$ i.i.d. We then set $\theta^\star \in \arg \min_\theta \sum_{n=1}^N | w^{(n)} - \phi_\theta (u^{(n)}) |^2,$ define $\phi^\star = \phi_{\thetas}$ and approximate 
$D\log \Upsilon_\sigma(u) \approx \frac{1}{\sigma^2} \bigl(\phi^\star(u) - u\bigr)$.


\section{Autoencoders\index{autoencoder}}\label{sec:auto}
Autoencoders are primarily used as a technique for uncovering
latent low-dimensional structure in high dimensional data. We introduce
them here and then demonstrate in the next section that a natural
probabilistic relaxation of the idea leads to generative models 
termed \index{autoencoder!variational}variational autoencoders.

\index{transport}Transport ideas may be used to (approximately) represent a complicated 
probability distribution, perhaps only known through samples, as the 
pushforward\index{pushforward} of a simpler measure. In this section we go a step further,
by seeking a simpler measure which lives in a lower dimensional \index{latent}latent space.
\index{autoencoder}Autoencoders are one natural approach to such problems.

The basic idea of \index{autoencoder}autoencoders is to find an approximate factorization
of the identity which is accurate in the support of density $\Upsilon$, but
using only the empirical approximation of $\Upsilon$ by $\mn$. 
Let $f: \R^d \times \Theta_f \to \R^{\dz}$
and  $g: \R^{\dz} \times \Theta_g \to \R^d$ where $\Theta_f \subseteq
\R^{p_f}$ and $\Theta_g \subseteq \R^{p_g};$ in particular each of $f$
and $g$ can be a \index{neural network}neural network, as defined in Section \ref{sec:NN},
generalized to vector-valued output. Recalling that $\Id$ denotes the 
identity mapping on $\R^d$,  define\footnote{The notation
$\hm$ is used in the next chapter, equation \eqref{eq:norm}, in the
context of real-valued functions and is readily generalized to
$\R^d-$valued functions.} 
$$\J(\theta_f,\theta_g)= 
\Bigl\|\Id-g\bigl(f(\cdot;\theta_f);\theta_g\bigr)\Bigr\|_{\hm}^2:=
\mathbb{E}^{u \sim \Upsilon}\bigl|u-g\bigl(f(u;\theta_f);\theta_g\bigr)\bigr|^2.$$ 
Now consider the following optimization problem: 
\begin{align} 
\label{eq:erm99} 
(\thetas_f,\thetas_g)\in \argmin_{(\theta_f,\theta_g) \in \Theta_f \times
\Theta_g} \J(\theta_f,\theta_g). 
\end{align}
We then define $\fs(u)=f(u;\thetas_f)$ and $\gs(z)=g(z;\thetas_g).$
Roughly speaking, and dropping the dependence on parameters for
expository purposes, we are seeking functions $f$ and $g$ 
such that $g\bigl(f(u)\bigr) \approx u.$ In practice the
optimization is implemented empirically, and we minimize
$$\J^N(\theta_f,\theta_g)= \Bigl\|\Id-g\bigl(f(\cdot;\theta_f);\theta_g\bigr)\Bigr\|_{\hm^N}^2
=\frac{1}{N}\sum_{n=1}^N\bigl|u^{(n)}-g\bigl(f(u^{(n)};\theta_f);\theta_g\bigr)\bigr|^2.$$ 

\begin{remark}
This approach reduces the \index{autoencoder}autoencoder to a particular form of supervised
learning in which the inputs and outputs are equal, so we seek to
approximate the identity, and in which we impose
a specific structure on the class of approximating function -- as
composition of $g$ with $f$. 
We refer to $\R^{\dz}$ as the {\em latent space}\index{latent}
and note that a primary application of the methodology 
is to identify \index{latent}latent spaces of dimension
$\dz$ which is much less than the dimension $d$ of the data space. The
approximate factorization of the identity found by composing $g$ with $f$
provides a way of moving between the data space and the \index{latent}latent space.
\end{remark}

\begin{example}
We demonstrate that \emph{principal component analysis},
often referred to simply as PCA\index{PCA}, may be viewed
as a form of autoencoder. Define 
\begin{align*}
    m & = \mathbb{E}^{u \sim \Upsilon} u ,\\
    C & = \mathbb{E}^{u \sim \Upsilon} \Bigl[(u-m)\otimes (u-m)\Bigr].
\end{align*}
Then consider the eigenpairs $(\varphi^{(i)},\lambda^{(i)}) \in
\R^d \times \R^+$ solving
\begin{align*}
    C\varphi^{(i)}&=\lambda^{(i)} \varphi^{(i)},\\
    |\varphi^{(i)}|&=1.
\end{align*}
The eigenvalues are positive and we assume them to be decreasingly ordered  
with respect to $i.$ Moreover, the eigenvectors are orthonormal.

For given $\dz \le d,$ we now define the maps
\begin{align*}
   f(u) &=\Bigl(\langle u, \varphi^{(1)}\rangle, \cdots, \langle u, \varphi^{(d_z)}\rangle\Bigr),\\
   g(z) &= \sum_{j=1}^{d_z} z_j \varphi^{(j)}.
\end{align*}
Then, their composition gives us
\begin{align*}
   g\bigl(f(u)\bigr) &= \sum_{j=1}^{d_z} \langle u, \varphi^{(j)}\rangle \varphi^{(j)}\\
   &=\Bigl(\sum_{j=1}^{d_z} \varphi^{(j)}\otimes \varphi^{(j)}\Bigr)u.
\end{align*}
Thus, the PCA method may be viewed as truncating the representation
of the identity defined by the 
spectral theorem\index{spectral!theorem} for positive,
symmetric matrices. The specific basis used is defined by
$\Upsilon$ but it is approximated in practice knowing only $\mn$ by computing the empirical mean and covariance. 
\end{example}

\section{Variational Autoencoders \index{autoencoder!variational}}\label{sec:vauto}
In the preceding section, note that $\zeta=(\fs)_\sharp \Upsilon$ 
gives the (approximate) distribution 
in the \index{latent}latent space, but that we cannot specify $\zeta$; mapping
$g$ (approximately) solves a \index{transport!measure}measure transport problem from $\zeta$ to $\Upsilon$, 
but choice of measure $\zeta$ is not within our control. 
It is natural to ask whether the methodology can be 
generalized to settings in which it is desirable
to impose a specified distribution $\zeta$. This leads to the topic
of {\em variational autoencoders.} \index{autoencoder!variational}

Let $\pi$ be a \index{coupling}coupling of $\Upsilon$ and $\zeta$ 
and note that the following two identities hold:
\begin{align*}
\pi(u,z)&=\bbP(u|z)\zeta(z),\\
\pi(u,z)&=\bbP(z|u)\Upsilon(u).
\end{align*}
The idea of the \index{autoencoder!variational}variational autoencoder is to approximate the two conditional
densities $\bbP(u|z), \bbP(z|u)$ appearing in these identities by 
parameterized families. A parameter choice is made to ensure that the two  
resulting approximate expressions for $\pi(u,z)$ are close. 
To be explicit we assume that
\begin{align*}
u|z & \sim \cN\bigl(g(z;\theta_g),\sigma_g^2 I\bigr),\\
z|u & \sim \cN\bigl(f(u;\theta_f),\sigma_f^2 I\bigr), 
\end{align*}
noting that this is a relaxation of the setting for \index{autoencoder}autoencoders.
Invoking these \index{Gaussian!approximation}Gaussian approximations for the conditionals we obtain
the following two approximations for the \index{coupling}coupling density:
\begin{align*}
\pi_g(u,z)&=\frac{1}{Z_g}\exp\Bigl(-\frac{1}{2\sigma_g^2}|u-g(z;\theta_g)|^2\Bigr) \zeta(z),\\
\pi_f(u,z)&=\frac{1}{Z_f}\exp\Bigl(-\frac{1}{2\sigma_f^2}|z-f(u;\theta_f)|^2\Bigr) \Upsilon(u).
\end{align*}
A common choice is to assume that $\zeta$ is the density of
a standard unit \index{Gaussian}Gaussian; we make this assumption throughout what follows.

For simplicity,  we consider the standard deviations 
$\sigma_f, \sigma_g$ to be fixed, and determine the parameters 
of $f$ and $g$.  We do this by asking that $\pi_f$ and
$\pi_g$ are close. If we measure closeness by means of 
\index{divergence!Kullback--Leibler} KL divergence, with $\pi_f$ in the first argument,
then using the \index{Gaussian}Gaussian assumptions on the conditionals and on $\zeta$
leads to insightful explicit calculations. To see this, we first note that 
\begin{align*}
\dkl(\pi_f\|\pi_g) = \bbE^{u \sim \Upsilon} \biggl[\bbE^{z \sim \bbP(z|u)}
\Bigl[ \frac{1}{2\sigma_g^2}|u-g(z;\theta_g)|^2 \Bigr] +
\dkl\bigl(\bbP(\cdot|u)\| \zeta \bigr)\biggr]+{\rm const},
\end{align*}
where the constant is independent of the parameters we wish to learn
and where $\bbP(z|u)$ and $\zeta(z)$ are given by their assumed \index{Gaussian}Gaussian structure.
Using the expression in Example \ref{ex:klg} for the \index{divergence!Kullback--Leibler}KL
divergence between two \index{Gaussian}Gaussians we obtain
\begin{align*}
\dkl(\pi_f\|\pi_g) = \bbE^{u \sim \Upsilon} \biggl[\bbE^{z \sim \cN\bigl(f(u;\theta_f),\sigma_f^2 I\bigr)} \Bigl[\frac{1}{2\sigma_g^2}\big|u-g(z;\theta_g)\big|^2 \Bigr]+
\frac{1}{2}|f(u;\theta_f)|^2\biggr]+{\rm const.}
\end{align*}
Noting that $z \sim \cN\bigl(f(u;\theta_f),\sigma_f^2 I\bigr)$ is
the same in law as $f(u;\theta_f)+\sigma_f \xi$ where $\xi \sim
\cN(0,I),$ we may write this \index{divergence}divergence as
\begin{align*}
\dkl(\pi_f\|\pi_g) = 
\J(\theta_f,\theta_g)+{\rm const},
\end{align*} 
where
\begin{align*}
\J(\theta_f,\theta_g) = \bbE^{u \sim \Upsilon} \biggl[\bbE^{\xi \sim \cN(0,I)} \Bigl[\frac{1}{2\sigma_g^2}\Big|u-g\bigl(f(u;\theta_f)+\sigma_f \xi;\theta_g\big)\Big|^2 \Bigr]+
\frac{1}{2}|f(u;\theta_f)|^2\biggr]
\end{align*}
and the constant term is independent of $(\theta_f,\theta_g).$


This constitutes a regularized version of the standard \index{autoencoder}autoencoder;
in particular the preceding expression for the \index{divergence}divergence clearly
regularizes the basic concept that $g\bigl(f(u)\bigr) \approx u$
under density $\Upsilon.$ 


\begin{remark}
In practice this is implemented with expectation 
over $\Upsilon$ approximated empirically by $\mn.$
This leaves an optimization problem in which the \index{objective}objective
is defined via expectation over $\xi.$ Stochastic
gradient descent\index{gradient descent!stochastic} from
Chapter \ref{ch:optimization} 
may be used to tackle this problem. After training, approximate samples 
from $\Upsilon$ may be obtained by sampling $z\sim \zeta$ and then 
sampling $u|z \sim \Nc \bigl(g(z; \theta_g), \sigma_g^2\big)$. 
\end{remark}





\section{Generative Adversarial Networks}\label{sec:gan}
\index{generative adversarial network}


The \index{autoencoder!variational}variational autoencoder trains a probabilistic model
for $u$ by learning $\bbP(u|z)$ and specifying $\bbP(z).$
The \index{generative adversarial network}generative adversarial network is
another method for training such a probabilistic model, which
also allows for low dimensional \index{latent}latent space. 
To be concrete we assume that it has the same structural 
form, namely
\begin{align*}
u|z & \sim \cN\bigl(g(z;\theta_g),\sigma_g^2 I\bigr),\\
z & \sim \cN\bigl(0,I\bigr).
\end{align*}
Thus samples from $u$ are created from samples from $z$. We
write the resulting density of $u$ as $\Upsilon_g$, with $g$ for generative. 
It is desired that samples from $\Upsilon_g$ are similar to those
specified by the data, which is drawn from density $\Upsilon$.

The \index{generative adversarial network}generative adversarial network starts by defining a
\emph{discriminator} $\mathsf{d}: \R^d \times \Theta_{\mathsf{d}} \to [0,1]$,
to be thought of as taking values which are probabilities.
Here $\Theta_{\mathsf{d}} \subset \bbR^{p_{\mathsf{d}}}.$ 
It is instructive to think of $\mathsf{d}(u;\theta_{\mathsf{d}})$ as being the
probability that $u$ is drawn from the density $\Upsilon$, and
$1- \mathsf{d} (u;\theta_{ \mathsf{d} })$ as the probability of $u$ being drawn
from the \index{generative model}generative model $\Upsilon_g.$
We then define $v: \Theta_g \times \Theta_{ \mathsf{d} } \to \bbR$ by
$$v(\theta_g,\theta_{ \mathsf{d} })=\bbE^{u \sim \Upsilon} \Bigl[\log  \mathsf{d}  (u; \theta_{ \mathsf{d} }) \Bigr] +
\bbE^{u \sim \Upsilon_g} \Bigl[\log \bigl(1-  \mathsf{d}  (u; \theta_{ \mathsf{d} })\bigr)\Bigr].$$
The optimal parameter values are defined by 
\begin{align*}
\widetilde{\theta}_{ \mathsf{d} }(\theta_g) & \in \argmax_{\theta_{ \mathsf{d} }} v(\theta_g,\theta_{ \mathsf{d} }),\\
\thetas_g & \in \argmin_{\theta_g} v\bigl(\theta_g, \widetilde{\theta}_{ \mathsf{d} }(\theta_g)\bigr),\\
\thetas_{ \mathsf{d}} & = \widetilde{\theta}_{ \mathsf{d} }(\thetas_g).
\end{align*}
In the maximization step, the parameters of the discriminator are chosen
to maximize $v$ -- the discriminator acts adversarially to try and find data
under $\Upsilon_g$ which does not look like data under $\Upsilon$. In the minimization
step the generator acts to reduce $v$ to try and make the two data sources
look similar. Ideally, through an iterative process, a solution is found in
which $ \mathsf{d}  (\cdot;\thetas_{ \mathsf{d} }) \equiv \frac12$, so that the data and generated
data are indistinguishable. The value of $\thetas_g$ defines the generative
model once this indistinguishable state has been reached.


\section{Bibliography}\label{sec:IPMLBib}



Density estimation\index{density estimation} is covered in numerous texts; we refer the reader to
the book \cite{silverman2018density} and the literature cited there. For a foundational reference concerning the use of normalizing flows
in machine learning see \cite{rezende2015variational}; more recent
applications may be found in \cite{winkler2019learning}, \cite{gabrie2021efficient}.
The neural ODE perspective was popularized in the paper
\cite{chen2018neural}; earlier papers \cite{haber2017stable, weinan2017proposal} anticipated the idea but did not make a practical tool in the way that the neural ODE paper \cite{chen2018neural} did. 
The subject of \index{optimal transport}optimal transport is overviewed
and systematically
developed in \cite{villani2009optimal}; computational
methodology is overviewed and developed in
\cite{peyre2017computational}.
Triangular transport maps are overviewed as a method for \index{sampling}sampling in 
\cite{marzouk2016sampling}.


Score-based methods have become popular in the context of generative diffusion models~\cite{song2020score}. 
The integration by parts method and denoising score matching approaches were first proposed in~\cite{hyvarinen2005estimation} and~\cite{vincent2011connection}, respectively. These approximate scores have been used for sampling using Langevin dynamics; see~\cite{lee2023convergence, block2020generative} for sampling guarantees. They have also been used in other unsupervised learning tasks, like learning probability graphical models. \index{autoencoder}Autoencoders
have a long history; see 
\cite{goodfellow2016deep,hinton1993autoencoders,schmidhuber2015deep} 
and the citations therein. 
Variational autoencoders were introduced concurrently in  
\cite{kingma2013auto} and \cite{rezende2014stochastic}.
For overviews of variational autoencoders see
\index{autoencoder!variational}
\cite{zhang2018advances,kingma2019introduction}.
The idea of conducting \index{unsupervised learning}unsupervised learning with 
\index{generative adversarial network} GANs was introduced
in \cite{goodfellow2014generative}. 

Although not covered here, because our focus is on generative modeling,
\index{clustering}clustering is
a widely used methodology in unsupervised learning; it is overviewed in \cite{von2007tutorial}. The paper \cite{ng2001spectral} describes an 
underlying mathematical framework, based on eigenvalue perturbation theory. Understanding large data limits of spectral clustering methods is a subject
developed in \cite{von2008consistency,hoffmann2022spectral}. The use of graph Laplacians, which underpin spectral \index{clustering}clustering,
in the solution of \index{inverse problem}inverse problems, is undertaken in
\cite{garcia2018continuum,dunlop2020large,trillos2017consistency,harlim2019kernel,sanz2020spde,harlim2022graph}.

\chapter{\Large{\sffamily{Supervised Learning}}}
\label{ch:SL}

This chapter is concerned with the \index{supervised learning}{\em supervised learning} task of determining a function $\psid: D \subseteq \R^d \to \R$ from data in the form of input-output
pairs from the map. The codomain of $\psid$ may have finite cardinality (classification) or infinite cardinality (regression). We focus on regression  since this task arises naturally in the context of learning forward maps for inverse problems and dynamical systems for data assimilation.
Our data assumption
is as follows:


\begin{dataassumption}
\label{data:sl}
Data is available in the form 
\begin{align}
\label{eq:data}
\Bigl\{\un, y^{(n)} \Bigr\}_{n=1}^N,
\end{align}
where the $\{\un\}_{n=1}^N$ 
are generated \index{i.i.d.}i.i.d. from probability density function $\Upsilon(u)$, supported on $D \subseteq \R^d,$ and where
$y^{(n)}=\psid(\un) + \sqrt{\lambda} \xi^{(n)}$,  where
$\{\xi^{(n)}\}_{n=1}^N$ is an \index{i.i.d.}i.i.d. mean zero 
noise process. 
\end{dataassumption}



The parameter $\lambda \ge 0$ allows us to consider noiseless data ($\lambda = 0)$ and noisy data $(\lambda >0).$
Since the goal is to determine $\psid$ we are concerned with function 
 \index{approximation}approximation, and to that end we will study three approaches to parameterize and learn functions: \index{neural network}neural networks (Section \ref{sec:NN}), \index{random features}random features (Section  \ref{sec:RF}), and Gaussian processes (Section \ref{sec:GP}). 
We will concentrate on the noiseless case $\lambda = 0$, but will briefly mention the noisy case $\lambda >0$ in the context of \index{random features}random features and \index{Gaussian!process}Gaussian processes. 

We let $\hm$ denote the Hilbert space 
of real-valued functions on $D$ 
with inner-product and induced norm
$$\la \psi, \phi \ra_{\hm}=\int_{D} \psi(u)\phi(u)\Upsilon(u) \,du, \quad |\psi|_{\hm}^2=\la \psi,\psi \ra_{\hm}.$$
Thus
\begin{equation}\label{eq:norm}
|\psi|_{\hm}=\biggl( \int_D \psi(u)^2  \Upsilon(u) \, du\biggr)^{1/2}.
\end{equation}

In practice, the probability density function $\Upsilon$ is typically unknown but may be approximated by the empirical density $\mn$ of the data $\{\un\}_{n=1}^N$, given by
\begin{align*}
\mn(u)=\frac{1}{N} \sum_{n=1}^N \delta(u-\un).
\end{align*} 
We may then define an empirical approximation of $|\psi|_{\hm}$
by replacing $\Upsilon$ by $\mn$ in \eqref{eq:norm} to obtain
$$|\psi|_{\hmn}=\Biggl( \frac{1}{N} \sum_{n=1}^N \psi(\un)^2 \Biggr)^{1/2}.$$


\section{\index{neural network} Neural Networks}\label{sec:NN}
A \index{neural network}neural network is a parametric family of functions. By use of the data a value of the parameter may be chosen so as to determine an approximation of $\psid.$
For simplicity we work under Data Assumption \ref{data:sl} in the setting $\lambda=0.$
To define a \index{neural network}neural network we first define:

\begin{definition} An {\em activation function}\index{activation function}
$\sigma: \R \to \R$ is a monotonic non-decreasing function. It is extended to
$\sigma: \R^s \to \R^s$ pointwise: $\sigma(u)_m=\sigma(u_m)$ for $u=(u_1,\cdots, u_m,\cdots, u_s)$
and $\sigma(u)=\bigl(\sigma(u)_1,\cdots, \sigma(u)_m,\cdots, \sigma(u)_s \bigr).$
\end{definition}

\begin{example} The \emph{Rectified Linear Unit (ReLU)}\index{ReLU} activation function is $\sigma(u)={\rm max}(u,0).$ The  
\emph{Gaussian Error Linear Unit (GELU)}\index{GELU}
activation function is $\sigma(u)=uF(u)$, where $F$ is the cumulative distribution function of the scalar unit centred Gaussian.
The \emph{Scaled Exponential Linear Unit (SELU)}\index{SELU} activation function is
\begin{align}
    \sigma(u)=
    \begin{cases}
        \kappa u, &\quad u>0,\\
        \kappa \alpha 
   \bigl(\exp(u)-1\bigr), &\quad u \le 0.
   \end{cases}
\end{align}
The \emph{Exponential Linear Unit (ELU)}\index{ELU} activation function is obtained from
the SELU by setting $\kappa = 1.$ 
\end{example}

Now introduce
$\Theta \subseteq \R^{d_\theta}$ and then $\psi: \R^d \times \Theta \to \R$
via the iteration
\begin{align}
\label{eq:dnn}
\psi_0(u;\theta)&=u,\\
\psi_{\ell+1}(u;\theta)&=\sigma\bigl(W_{\ell}\psi_{\ell}(u; \theta)+b_\ell\bigr), \quad
\ell=0,\dots, L-1,\\
\psi(u;\theta)&=\beta^\top \psi_{L}(u; \theta),
\end{align}
where, for $\ell \in \{0,\ldots, L-1\}$,
$W_{\ell} \in \R^{d_{\ell+1}\times d_{\ell}}$ and $b_{\ell} \in \R^{d_{\ell+1}},$ with $d_0 = d$ and $\beta \in \R^{d_{L}};$ together the matrices $\{W_\ell\}_{\ell = 0}^{L-1}$ and vectors $\{b_\ell\}_{\ell = 0}^{L-1}$
define $\theta$ (and $d_\theta$). Indeed here we define
$\ttheta=\{W_\ell, b_\ell\}_{\ell=0}^{L-1}$ and $\theta=(\ttheta,\beta).$


Resulting function $\psi: \R^d \times \Theta \to \R$ is known as a 
\emph{(deep\footnote{Deep if $L$ is large enough; often $3$ or more is considered large in this context. Lower values are sometimes referred to as \emph{shallow neural networks}\index{neural network!shallow}.}) neural network}\index{neural network!deep}. The reader will note that the concept is readily
generalized to $\psi: \R^d \times \Theta \to \R^q$ for any integer $q;$ we concentrate on $q=1$ for simplicity
of exposition only.



An idealized approach to determining $\theta$ is to minimize the
{\em risk} $$\J(\theta):=|\psid-\psi(\cdot;\theta)|_{\hm}^2$$
by setting
\begin{align}
\thetas \in \argmin_{\theta \in \Theta} \J(\theta).
\end{align}
However, this requires knowing $\psid,$ which is of course not given, as well as the probability density function $\Upsilon$. 
Instead the optimal parameter $\thetas$ is chosen to minimize the {\em empirical risk}\index{risk!empirical}
$$\J^N(\theta):= |\psid-\psi(\cdot;\theta)|_{\hmn}^2.$$
Notice that
\begin{equation}
\label{eq:erm}   
\J^N(\theta)=\frac{1}{N} \sum_{n=1}^N |y^{(n)}-\psi(u^{(n)};\theta)|^2.
\end{equation}

\begin{remark}
We have derived this loss function $\J^N(\cdot)$ under Data Assumption \ref{data:sl}
with $\lambda=0$. However it may also be derived under the more general assumption
that data set $(u^{(n)},y^{(n)})$ is drawn i.i.d from a probability measure $\pi$ on $\cP(\R^\du \times \R^\dy).$ Examples of such measures may be found from Data Assumption \ref{data:sl} for any $\lambda \ge 0,$ but the setting is much more
general. The risk may then be written as 
$$\J(\theta):=\Expect^{(u,y) \sim \pi}|y-\psi(u;\theta)|^2$$
and approximated empirically to again obtain \eqref{eq:erm}.
\end{remark}


Minimizing \eqref{eq:erm} leads to an implementable strategy for function approximation.
The empirical risk is typically non-convex as a function of $\theta$, 
with multiple saddle points and local
minima; it is observed that minimization via the use of stochastic gradient
descent (Chapter \ref{ch:optimization}) works well for many problems. 
Once $\thetas$ is learned, we write $\psis(u):=\psi(u;\thetas).$




\section{\index{random features}Random Features}\label{sec:RF}


We continue to work under Data Assumption \ref{data:sl} in the setting $\lambda=0.$
Now consider a thought experiment in which, rather than optimizing over
all of $\Theta$, the parameters $\ttheta=\{W_{\ell}, b_{\ell}\}_{\ell=0}^{L-1}$
are fixed and optimization is performed only over $\beta.$ 
Note that $\psi_L$ depends only on $\ttheta$ and not $\beta$; indeed
$\psi_L(\cdot;\ttheta): \R^d \to \R^{d_L}$ and we may define
$\varphi_i(\cdot;\ttheta): \R^d \to \R$ to be the $i^{th}$ component, for $i=1,\ldots, d_L$, of
the vector-valued output function. We can then write
\begin{align}
\label{eq:rf_form}
\psi(u;\ttheta,\beta):=\sum_{i=1}^{d_L}\beta_{i}\varphi_i(u;\ttheta),
\end{align}
viewing $\psi(\cdot;\ttheta,\beta)$ as parameterized by $\beta$, since
the remaining elements $\ttheta$ of $\theta$ have been fixed. From $\psid$ we may define 
\begin{align*}
\betas&\in \argmin_{\beta \in \R^{d_L}} |\psid-\psi(\cdot;\ttheta,\beta)|_{\hmn}^2\\
&= \argmin_{\beta \in \R^{d_L}} \sum_{n=1}^N |y^{(n)}-\psi(u^{(n)};\ttheta,\beta)|^2
\end{align*}
and $\psis(u):=\psi(u;\ttheta,\betas).$ In contrast to full optimization over $\theta,$ this leads to a convex, indeed quadratic, optimization problem that can be readily solved. %


However, we have simply fixed $\ttheta;$ we have not discussed how to choose it.
One idea is to simply pick $\ttheta$ at random from some probability distribution.
With our current construction,
the resulting collection of functions $\{\varphi_i\}$ are then random but
not, in general, \index{i.i.d.}i.i.d.
A variant on this idea is to choose $q \in \cP(\R^{d_\vartheta})$, define $\varphi: \R^d \times
\R^{d_\vartheta} \to \R$ and set
\begin{equation}
\label{eq:RFE}
\psi(u;\beta):=\sum_{i=1}^{d_L}\beta_{i}\varphi(u;\ttheta_i), \quad \ttheta_i \sim q, \, \index{i.i.d.}\text{i.i.d.}
\end{equation}

\begin{example}
\label{ex:RFF}
Random Fourier features take the form
$$\varphi(u;\ttheta)=\cos\bigl(\langle \omega, u \rangle + b\bigr)$$
where $\ttheta=(\omega,b)$ is chosen at random. It is natural to take $b \sim U[0,2\pi]$,
and we assume $\omega \sim W,$  for some 
$W \in \cP(\R^d).$
\end{example}

\begin{example}
Each $\varphi(\cdot;\ttheta_i)$ may be chosen as a  neural network, for example, with  the parameters of that
neural network chosen i.i.d. at random from  given distribution $q$.
\end{example}




Empirical risk minimization to determine vector $\beta$ in \eqref{eq:RFE} again leads to a linear system
for $\beta$ found by minimizing a quadratic loss\index{loss} function. This loss function may be 
regularized\index{regularizer} and then $\betas$ is defined via 
\begin{align}
\label{eq:erm3}
\betas&\in \argmin_{\beta \in \R^{d_L}} \J^N(\beta),\\
\J^N(\beta)&:=\frac12 \sum_{n=1}^N |y^{(n)}-\psi(u^{(n)};\beta)|^2
+\frac{\lambda}{2}|\beta|^2.
\end{align}
Similarly to before we write $\psis(u):=\psi(u;\betas).$ 

\begin{remark}
The regularization\index{regularizer} is quadratic and hence does not change the simplicity
of the optimization problem for $\beta:$ it still results in solution of a linear system.
Furthermore the specific regularization arises naturally in the context of noisy data $\xi^{(n)} \sim \mathcal{N}(0, I)$ in \eqref{eq:data} -- see Remark \ref{rem:MCGP}. 
\end{remark}

We refer to the functions $\varphi(\cdot;\ttheta)$, with $\ttheta \sim q$, as 
{\em random features}\index{random features}.
It is natural to ask how correlated these functions 
are at different points in $D$. To this end, we
introduce a {\em kernel}\index{kernel} $c: D \times D \to \R$ defined by
\begin{align}
\label{eq:kernel}
c(u,u'):=\bbE^q \bigl[\varphi(u;\ttheta)\varphi(u';\ttheta) \bigr], 
\end{align}
where expectation is over $\ttheta \sim q.$

\begin{example}
Consider Example \ref{ex:RFF}. We note that 
\begin{align*}
    c(u,u')&=\int I(\omega) W(\omega) \, d\omega,\\
    I(\omega) & =\frac{1}{2\pi} \int_0^{2\pi} \cos\bigl(\langle \omega,u \rangle +b\bigr) \cos\bigl(\langle \omega,u' \rangle +b\bigr) \, db\\
    &=\frac{1}{2} \cos\bigl(\langle \omega, u-u' \rangle \bigr).
    \end{align*}
\end{example}


\section{Gaussian Processes \index{Gaussian!process}}\label{sec:GP}



\subsection{Kernels\index{kernel}} \label{ssec:kernel}
The theory of \index{Gaussian!process}Gaussian process regression starts from a kernel 
satisfying two key properties:
\begin{definition}
\label{d:mk} Let $D \subseteq \R^\du.$
A kernel\index{kernel} $c: D \times D \to \R$ is \emph{symmetric} 
if $c(u,u')=c(u',u)$ for all $(u,u') \in D \times D.$
It is \emph{non-negative definite} if, for all $N \in \mathbb{N},$
all $\{u^{(i)}\}_{i=1}^N  \subset D$ and all $e \in \R^N,$
$$\sum_{i=1}^N \sum_{j=1}^N c\bigl(u^{(i)}, u^{(j)}\bigr) e_i e_j \ge 0.$$ 
If equality implies that $e = 0,$ the kernel is called \emph{positive definite}. 
\end{definition} 


A symmetric non-negative definite kernel may be viewed as a {\em covariance function}
of a \index{Gaussian}Gaussian random field. From kernel $c$, we define the integral operator
\begin{align}
\label{eq:IE}
(\cC\phi)(u)=\int_{D} c(u,u')\phi(u') \,du'. 
\end{align}
Provided that $D$ is compact and $c$ is continuous and positive 
definite, $\cC$ is a \index{positive definite}positive definite trace-class
operator on $L^2(D)$ and we may define the domain of the inverse of its square root as $\Kk= \text{Dom}(\cC^{-\frac12})$.
Furthermore we define 
$\Kk^*$ the dual space of linear functionals on $\Kk$; thus
$\Kk \subset L^2(D) \subset \Kk^*$. In fact $\Kk$ is compactly embedded into $L^2(D)$
and $\cC^{-\frac12}$ is densely defined on $L^2(D)$.
We define
$$\langle \phi,\psi \rangle_{\Kk}=\langle \cC^{-\frac12} \phi,\cC^{-\frac12} \psi \rangle_{L^2(D)}$$
endowing $\Kk$ with a Hilbert space structure. Then
$$\|\phi\|_{\Kk}^2=|\cC^{-\frac12}\phi|^2.$$
We may also define $\cC^{-1}: \Kk \to \Kk^*.$
The operator $\cC$ defines a Gaussian measure $\cN(0,\cC)$; the measure is supported on
$L^2(D)$  since $\Tr(\cC)<\infty.$ 
The space $\Kk$ is known as the \emph{Cameron-Martin space}\index{Cameron-Martin space} associated with the Gaussian measure.

Assume now that $\Kk^*$ is rich enough that it contains \index{Dirac delta}Dirac measures in $D$ (and hence pointwise evaluation) and define $\cC^{-1}: \Kk \to \Kk^*.$
It follows that, for all $v \in D$, 
\begin{align}
\label{eq:GF}
\cC^{-1}c(\cdot,v)=\delta_{v}(\cdot).
\end{align}
We may then note that
$$\langle \phi, c(\cdot,v)\rangle_{\Kk}=\langle \cC^{-\frac12}\phi, \cC^{-\frac12}c(\cdot,v) \rangle
=\langle \phi,\cC^{-1}c(\cdot,v) \rangle=\langle \phi, \delta_{v} \rangle =\phi(v).$$
This is the reproducing property and under the conditions leading to it $\Kk$ is a
\emph{reproducing kernel Hilbert space}\index{reproducing kernel Hilbert space} -- RKHS
for short.

\subsection{Regression}


We work under Data Assumption \ref{data:sl} in the setting $\lambda>0.$
We  assume that $\Kk$ is an RKHS and seek to find approximation to $\psid$, function $\psis$, through the following minimization problem:
\begin{subequations}
\label{eq:erm4}    
\begin{align}
\psis &\in \argmin_{\psi \in \Kk} \J^N(\psi),\\
\J^N(\psi)&:=\frac12 \sum_{n=1}^{N}|y^{(n)}-\psi(u^{(n)})|^2+\frac{\lambda}{2}\|\psi\|_{\Kk}^2.
\end{align}
\end{subequations}
This infinite dimensional optimization problem may be viewed as a function
space version of \eqref{eq:erm} where we minimize over functions $\psi \in \Kk$, rather
than parameter $\theta \in \Theta \subset \Ru.$ It may be derived by
application of a generalization of Bayes Theorem \ref{t:bayes}, and then a generalization of the notion of MAP estimator from Definition \ref{def:map},
from $\Ru$ to $L^2(D).$

\begin{remark} \label{rem:MCGP}
The minimization problems \eqref{eq:erm3} and \eqref{eq:erm4} are connected. If the RKHS
$\Kk$ in \eqref{eq:erm4} is replaced by the RKHS
$$\Kk_{d_L}= \Bigl\{\psi \in \Kk: \psi(u;\beta):=\sum_{i=1}^{d_L}\beta_{i}\varphi(u;\ttheta_i), \quad \beta_i \in \R\,\, \forall i \in \{1,\cdots, d_L\} \Bigr\},$$
where $\ttheta_i \sim q $ i.i.d.  then the optimization reduces to one over
$\beta \in \R^{d_L}$ and it may be shown that this reduces to \eqref{eq:erm3}. Thus
\eqref{eq:erm3} may be viewed as approximation of \eqref{eq:erm4} via a Monte Carlo approximation of
the RKHS $\Kk.$
\end{remark}


\begin{remark} \label{rem:gpbayes}
The minimization problem \eqref{eq:erm4} corresponds to determining
the mean of a \index{posterior}posterior distribution of an infinite dimensional \index{Bayesian!inverse problem}Bayesian inverse problem defined as follows. We place as \index{prior}prior on $\psi$ a \index{Gaussian}Gaussian random field with mean zero and covariance function $c(u,u');$ alternatively we may write $\cN(0,\cC).$  The 
\index{likelihood}likelihood is defined by assuming noisy data in \eqref{eq:data}, 
where $\xi^{(n)} \sim \mathcal{N}(0,I)$ \index{i.i.d.}i.i.d. and then the negative log-likelihood
is given by 
$$\frac{1}{2\lambda}\sum_{n=1}^N |y^{(n)}-\psi(\un)|^2.$$  
The \index{posterior}posterior mean, which is also a form of \index{MAP estimator}MAP estimator, 
then satisfies \eqref{eq:erm4}. We also remark that minimization 
of \eqref{eq:erm3} also has a similar interpretation as a \index{MAP estimator}MAP
estimator, but with respect to a \index{Gaussian!process}Gaussian process with  mean zero and covariance function a random approximation
of $c(u,u').$ 
\end{remark}

The infinite dimensional optimization problem
over $\Kk$ has the following remarkable property, which
is often referred to as the 
{\em representer theorem}\index{representer theorem}, and demonstrates
that the optimization problem is intrinsically finite dimensional: 

\begin{theorem}
\label{t:this1}
Function $\psis$ solving \eqref{eq:erm4} has the form
\begin{align}
\label{eq:eform}
\psis(u)=\sum_{n=1}^N \alphas_n c(u,\un).
\end{align}
Furthermore, the coefficients $\alphas$ solve the
following quadratic minimization problem:
\begin{align}
\label{eq:erm5}
\alphas& \in  \argmin_{\alpha \in \R^N} \mathsf{A}^N (\alpha),\\
\mathsf{A}^N(\alpha)&:=\frac12 \sum_{r=1}^N\Big|y^{(r)}-  \sum_{ n=1}^N  \alpha_n c(\xr, \un  )\Big|^2+\frac{\lambda}{2}\sum_{n,r=1}^N \alpha_n \alpha_r c(\xr,\un).
\end{align}
\end{theorem}

\begin{remark}
    In the context of supervised learning, notice the key fact that solution to the optimization problem is
    defined entirely by knowledge of the kernel $c$ and by the data $\Bigl\{\un, y^{(n)} \Bigr\}_{n=1}^N.$
\end{remark}

\begin{proof}[Proof of Theorem \ref{t:this1}]
The Euler-Lagrange equations for \index{objective}objective function $\J^N$ in \eqref{eq:erm4} yield 
$$\lambda (\cC^{-1}\psis)(u)=\sum_{n=1}^N \bigl(y^{(n)}-\psis(\un)\bigr)\delta_{\un}(u).$$
Now note formally from \eqref{eq:GF}, or directly from \eqref{eq:IE}, that $(\cC\delta_{u'})(u)=c(u,u').$ 
Thus applying $\cC$ to the Euler-Lagrange equations shows that $\psis(u)$ is in the linear
span of $\{c(\cdot,\un)\}_{n=1}^N,$ establishing the first part of the result.


For the second part, let 
$$\Kk^N= \Bigl\{\psi \in \Kk: \psi(u)=\sum_{n=1}^N \alpha_n c(u,\un), \quad \alpha_n \in \R\,\, \forall n \in \{1,\cdots, N\} \Bigr\}$$
and define the optimization problem 
\begin{subequations}
\label{eq:erm44}    
\begin{align}
\psis &\in  \argmin_{\psi \in \Kk^N} \J^N(\psi),\\
\J^N(\psi)&:=\frac12 \sum_{n=1}^{N}|y^{(n)}-\psi(u^{(n)})|^2+\frac{\lambda}{2}\|\psi\|_{\Kk}^2.
\end{align}
\end{subequations}
Because of the established form \eqref{eq:eform} of the minimizer 
$\psis$ of \eqref{eq:erm4} we see that  $\psis$ will also be the minimizer
of \eqref{eq:erm44}. 
Now, note that
$$\|\psi\|_{\Kk}^2=|\cC^{-\frac12}\psi|_{L^2(D)}^2=\langle \psi, \cC^{-1} \psi \rangle_{L^2(D)}.$$
In $\Kk^N$ we have
\begin{align*}
    \cC^{-1}\psi(u)&=\sum_{n=1}^N \alpha_n \cC^{-1}c(u,\un)\\
    &=\sum_{n=1}^N \alpha_n \delta_{\un}(u).
\end{align*}
Thus, also in $\Kk^N$, we have, using the symmetry of $c(\cdot,\cdot)$,
$$\|\psi\|_{\Kk}^2=\Big\langle \sum_{r=1}^N \alpha_r c(\cdot,\xr),\sum_{n=1}^N \alpha_n \delta_{\un}(\cdot)\Big\rangle_{L^2(D)}=\sum_{n,r=1}^N \alpha_n \alpha_r c(\xr,\un)$$
as required.
\end{proof}

We define $C \in \R^{N \times N}$ to be the matrix with entries
$C_{nr}=c(\un,\xr)$ and $S$ to be its inverse, with entries $S_{nr}$; 
notice that $C$ is positive definite (and hence invertible, so that $S$ is defined) provided that the kernel $c$ is positive definite. Then we have: 


\begin{corollary}
If $\ps \in \R^N$ is vector with entries $\ps_n=\psis(\un),$ then
$\ps=C\alphas$ and
\begin{align}
\label{eq:erm6}
\ps&\in  \argmin_{p \in \R^N} \J^N(p),\\
\J^N(p)&:=\frac12\sum_{n=1}^N |y^{(n)}-p_n|^2+\frac{\lambda}{2}\sum_{n,r=1}^N p_n p_r S_{n,r}.
\end{align}


\end{corollary}


\section{Approximation Properties}
\label{sec:AP}
All of the preceding three methods can, in principle, approximate
continuous functions to arbitrary accuracy, over a compact set.
Doing so requires sufficient data. Furthermore, in the case of 
\index{neural network}neural networks, this also requires sophisticated optimization 
techniques to obtain close to optimal solutions; in contrast,
the \index{random features}random features and \index{Gaussian!process}Gaussian process approaches only require solution
of linear systems, resulting from a quadratic optimization problem.
Typical instances of the resulting approximation theory for
the three supervised learning techniques typically shows that, 
for given $\delta>0$, 
there is a volume of data $N$ such that, with high probability with
respect to the data,
\begin{equation}
\label{eq:eb}
\sup_{u \in D} |\psid(u)-\psi^\star(u)| < \delta.
\end{equation}
Theory establishing results of this form is cited in the bibliography
which follows.

\section{Bibliography}
\label{sec:slbib}

The subject of \index{neural network}neural network function \index{approximation}approximation, the
core task of \index{supervised learning}supervised learning,
is overviewed in \cite{devore2021neural}.
Universal \index{approximation}approximation theorems may be found in
\cite{cybenko1989approximation,pinkus1999approximation}.
The use of \index{random features}random features was popularized as a methodology,
and analyzed rigorously, in the collection of papers
\cite{rahimi2007random,rahimi2008weighted,rahimi2008uniform}.
\index{Gaussian!process}Gaussian processes are described in \cite{williams2006gaussian}
and kernel-based methods more generally are described in
\cite{owhadi2019operator}. Error estimates for interpolation
using \index{Gaussian!process}Gaussian processes are developed in \cite{wendland2004scattered}.
The link between regression and \index{Bayesian!inversion}Bayesian inversion with
\index{Gaussian!process}Gaussian process \index{prior}priors is developed in depth in
\cite{craven1978smoothing,wahba1990spline}. A definition of
\index{MAP estimator}MAP estimator in infinite dimensions, appropriate for the
discussion in Remark \ref{rem:gpbayes}  may be found in \cite{dashti2013map}. 
We have articulated a specific link between \index{neural network}neural networks
and \index{random features}random features; a related concept underpins the subject of the
{\em neural tangent kernel} \cite{jacot2018neural}.
The use of various machine-learning inspired \index{approximation}approximation
methods in the solution of PDEs may be found in
\cite{raissi2019physics,chen2021solving,nelsen2021random,kovachki2021neural}.


\chapter{\Large{\sffamily{Time Series Forecasting}}}\label{ch:ts_forecasting}


In most other chapters we have used $n$ to index data and $j$ to
index (discrete) time in (possibly stochastic) dynamical systems.
In this chapter the two are conflated as the data comes from
time series:


\begin{dataassumption} \label{da:forc}
Let $\mathsf{N}=\{0,1,\cdots,N-1\}.$
    We are given a time-series $\{\vd_n\}_{n \in \mathsf{N}}$, 
    of elements in $\R^{\du}.$
\end{dataassumption}

For this reason the (possibly stochastic) dynamical systems in this
chapter will be indexed by $n$ not $j.$ The following formal
and informal definitions will be useful to us:



\begin{definition}
    A process $\{v_n\}$ is \emph{strictly stationary}\index{strictly stationary process} if, for all $p$, the joint distribution of $(v_n, \ldots, v_{n+p})$ does not change with $n$.
\end{definition}

We use the following informal definition of an ergodic time series.
A process $\{v_n\}$, in $\R^{\du},$ is \emph{ergodic}\index{ergodicity} if there is probability measure
$\mu$ on $\R^{\du}$ such that, for a sufficiently wide class of
test functions $\varphi$,
\begin{equation}
\label{eq:erg}    
\lim_{N \to \infty} \frac{1}{N} \sum_{n=0}^{N-1} \varphi(v_n)=
\int_{\R^{\du}} \varphi(v) \, \mu(dv).
\end{equation}
If the process is deterministic it is possible that measure
$\mu$ will not have density with respect to Lebesgue measure
which is why, in contrast to much of the remainder of the notes,
we have not used a probability density function in this
definition.

In Section \ref{sec:linear_autoregressive} we introduce
linear autoregressive models\index{autoregressive model!linear}.
Section \ref{sec:AF} studies analog forecasting methods.
In Section \ref{sec:RS} we look at fitting Markovian models
to the data, and non-Markovian models with a recurrent
structure to capture memory. Section \ref{sec:NGAR} introduces
non-Gaussian autoregressive models, generalizing  the
content of Section \ref{sec:linear_autoregressive}.
We conclude in Section \ref{sec:TSB} with bibliographic remarks.


\section{Linear Autoregressive Models}\index{autoregressive model!linear} \label{sec:linear_autoregressive}

A vector autoregressive (VAR) process is one of the most simple time-series models.

\begin{definition}
The $p$th-order VAR model, written VAR($p$), is
\begin{equation}
    v_n = c + \sum_{\ell=1}^p A_\ell\,v_{n - \ell} + \varepsilon_n,
\end{equation}
where the $A_\ell$ are constant matrices, $c$ is a constant vector, and $\varepsilon_n\sim\mathcal{N}(0, C)$. When $v_n$ is a scalar, the process is known simply as an autoregressive (AR) model. Note that $\varepsilon_n$ can also be a different strictly stationary and ergodic process, but we use Gaussian errors here for simplicity.
\end{definition}

\begin{theorem}\label{theorem:var1_dist}
    If $\{v_n\}$  is a stationary VAR(1) process with $c=0$, then the distribution of $v_n$ is $\mathcal{N}(0, C_\infty)$, where
    \begin{equation*}
        \operatorname{vec}(C_\infty) = (I - A\otimes A)^{-1}\operatorname{vec}(C).
    \end{equation*}
    Note that we take $c=0$ for simplicity, but the proof is easily modified for $c\neq 0$.
\end{theorem}
\begin{proof}
     First note that under Gaussian errors, the marginal distribution of $v_n$ is Gaussian (see the Bibliography section for references). By stationarity, we must have that
     \begin{equation*}
         \mathbb{E}v_n = A_1 \mathbb{E}v_{n-1} = \mathbb{E}v_{n-1},
     \end{equation*}
     which implies that $\mathbb{E}v_n = 0$. We must also have that
     \begin{equation*}
         \mathbb{E}[v_n v_n^\top] = A_1 \mathbb{E}[v_{n-1} v_{n-1}^\top] A_1^\top + C = \mathbb{E}[v_{n-1} v_{n-1}^\top],
     \end{equation*}
     where the second equality follows from elementary properties of Gaussians. This is a discrete Lyapunov equation, which can be solved using properties of vectorization. We obtain
     \begin{equation*}
         \operatorname{vec}(\mathbb{E}[v_{n-1} v_{n-1}^\top]) = (I - A_1\otimes A_1)^{-1}\operatorname{vec}(C).
     \end{equation*}
\end{proof}

\section{Analog Forecasting}\index{analog forecasting}
\label{sec:AF}

We again make Data Assumption \ref{da:forc}.
The goal of \emph{forecasting}\index{forecasting} 
is to predict $v_{q}$
given $v_0$, and given the time-series data provided 
in Data Assumption \ref{da:forc}. 
\emph{Analog forecasting}\index{forecasting!analog} 
specifically operates by predicting from  given specific point,
by looking for nearby points in data and seeing how they evolved.




\subsection{Analog Forecasting}\index{analog forecasting}

Let $\D$ be a distance-like deterministic scoring rule
    \index{scoring rule!distance-like deterministic} 
    on $\R^{\du}$ from Definition \ref{def:det_score}, 
    recalling that any norm on $\R^{\du}$ provides
    an example. \emph{Analog forecasting} works as follows. Let
\begin{equation}
n^\star \in \argmin_{n \in \mathsf{N}} \D(v_0,\vd_{n}).\label{eq:argmin_analog}
\end{equation}
Then the desired prediction is, for $n^\star < N-q,$
\begin{equation*}
v_{q}=\vd_{n^\star+q};
\end{equation*}
for $n^\star \ge N-q$ no prediction is made because
the data does not support doing so.

The intuition behind the forecast is simple to articulate:
find the closest point in the data set to $v_0$ and ask what happened $q$ time units later in the data set; this is used
as the prediction. 

\begin{remark}
The predictions produced by analog forecasting are discontinuous
with respect to changes in $v_0$, since the closest point to $v_0$ can change 
as it is varied continuously. In the next subsection we describe a generalization
which removes this discontinuous behaviour.
\end{remark}

\begin{remark}
The success of analog forecasting will depend on the availability of close analogs to $v_0$, 
as well as the Lyapunov spectrum\index{Lyapunov spectrum} of the system that generated 
$\{v^\dagger_n\}$. The first point is intuitive. We now explain the second point. 
Suppose that $\{v^\dagger_n\}$ is generated by the deterministic dynamical system $\Psi$, so that
\begin{equation*}
    v^\dagger_{n+1} = \Psi(v^\dagger_n).
\end{equation*}
Suppose further that $\Psi$ has a global attractor\index{attractor!global}, supporting
an invariant measure $\mu$. Let $\Psi^{(n)}$ denote the $n$-fold composition of $\Psi$ with itself.
Under conditions described by Oseledet's Theorem (see Bibliography
Section \ref{sec:TSB}), we can define the maximal \emph{Lyapunov exponent}\index{Lyapunov exponent} 
of $\Psi$ as
\begin{equation}
    \lambda_{\text{max}} = \lim_{n\to\infty}\lim_{\epsilon\to 0^+}\frac{1}{n}\log\frac{|\Psi^{(n)}(v^\dagger + \epsilon e) - \Psi^{(n)}(v^\dagger)|}{\epsilon},
\end{equation}
for $\mu$- almost every $v^\dagger$ and almost every vector $e$  picked uniformly at random from the unit sphere. 

For simplicity consider the case $\Psi(v)=Av$ where $A$ is positive and symmetric (and hence diagonalizable) and the spectral radius of $A$, $\lambda$, is attained at unique eigenvector $\varphi.$ This does not satisfy the standard assumptions of the theory, but is simple enough to provide intuition. Provided that
the projection of $e$ onto $\varphi$ is non-zero (which will happen almost surely) it is clear that 
$\lambda_{\text{max}}=\lambda.$ Thus the maximal Lyapunov exponent\index{Lyapunov exponent} delivers
the typical growth rate of perturbations to the system.



We now discuss how Lyapunov exponents\index{Lyapunov exponent} manifest in analog forecasting.
Recall that the analog forecast from $v_0$ is found by identifying $n$ such that $v^\dagger_n$
is the closest point in the data set to $v_0$ and setting $v_q=v^\dagger_{n+q}=\Psi^{(q)}(v^\dagger_n).$
Thus, approximately for $|v^\dagger_n-v_0|$ small, we have that on average
\begin{equation}
    |v_{q} - \Psi^{(q)}(v_0)|\approx |v^\dagger_n-v_0|e^{\lambda_{\text{max}} q}.
\end{equation}




\end{remark}


\subsection{Kernel Analog Forecasting}\index{analog forecasting!kernel}

Let $p:\R^{\du} \times \R^{\du} \to \R^+$ be a positive-definite
\emph{kernel}\index{kernel!positive-definite}. Then make
prediction
$$v_q=\frac{1}{N-q}\sum_{n=0}^{N-1-q} p(v_0,\vd_{n})\vd_{n+q}.$$

This method, too, has a simple intuitive explanation, generalizing
analog forecasting.
Rather than forecasting using $q$ steps ahead from a single closest point in the data set to the initial condition, $q$-step forecasts
are made from all points in the data set (for which it is
possible to forecast $q$ steps ahead). These are then
weighted according to how close the starting point in
the data set is to $v_0$; the kernel performs this weighting.
A typical choice of kernel is the radial basis function kernel $p(v,w)=\exp(-|v-w|^{2}/\lambda)$,
and the choice of $\lambda$ is crucial to the success of the algorithm.

\begin{remark}
Assuming that the kernel is continuous in its arguments it
follows that this forecast will be continuous with respect to
$v_0.$
\end{remark}


\section{Recurrent Structure}
\label{sec:RS}

We again seek to forecast but now we attempt to do so
by learning a map from the data given in Data Assumption
\ref{da:forc}.

\subsection{Markovian Prediction} \label{sec:TimeSeries_Markovian}

We seek to explain the data $\{\vd_n\}_{n=0}^{N-1}$ as being the
outcome of deterministic Markovian map on $\R^d,$ of form
\begin{subequations}
\begin{align*}
v_{n+1}=\psi(v_n;\theta).
\end{align*}
\end{subequations}
We can view this as a generalization of the supervised learning problem, defined by Data Assumption \ref{data:sl}, where the
inputs are no longer i.i.d. The function $\psi(\cdot;\theta)$
can be, for example, a neural network, a random features model
or the mean of a Gaussian process as in Chapter \ref{ch:SL}.

To learn $\theta$ define
\begin{subequations}
\begin{align}
\J^N(\theta) & = \frac{1}{N}\sum_{n=0}^{N-1}\bigl|\vd_{n+1}-\psi(\vd_n;\theta)\big|^2,\\
\thetas & \in \arg \min_{\theta \in \Theta} \J^N(\theta).
\end{align}
\end{subequations}

The population-level optimization problem that this approximates
may be defined as follows. Assume that data is given in the form
of probability density function $\pi(v,w)$ in $\mathcal{P}(\R^d \times \R^d),$ representing the two-point correlation function
of a stationary ergodic process. Then define
\begin{subequations}
\begin{align}
\J(\theta) & = \bbE^{(v,w) \sim \pi}\bigl|w-\psi(v;\theta)\big|^2,\\
\thetas & \in \arg \min_{\theta \in \Theta} \J(\theta).
\end{align}
\end{subequations}
If data $\{\vd_n\}_{n=0}^{N-1}$ is derived from
such a stationary ergodic process, then $\J(\theta)$ is the pointwise limit of $\J^N(\theta)$, by ergodicity.

\subsection{Memory and Prediction} \label{sec:TimeSeries_memory}

The premise of the preceding subsection is that 
data $\{\vd_n\}_{n=0}^{N-1}$ derives from a Markov process
and there often arise settings where this is not the case. In
such a setting it is of interest to introduce an unobserved latent
variable $\{r_n\}_{n=0}^{N-1}$, with $r_n \in \R^{r}$ and then
hypothesize a model of the form
\begin{subequations}
\label{eq:rnn}
\begin{align}
v_{n+1}&=\psi(v_n,r_n;\theta_v),\\
r_{n+1}&=\phi(v_n,r_n;\theta_r).
\end{align}
\end{subequations}
If $\psi, \phi$ are neural networks then the overall structure is known as a \emph{recurrent neural network},\index{recurrent neural network} or RNN for short.
We define $\theta=(\theta_v,\theta_r) \in \Theta = \Theta_v \times \Theta_v$ and 
learn $\theta$ by solving the minimization problem
\begin{subequations}
\begin{align}
\J^N(\theta) & = \frac{1}{N}\sum_{n=0}^{N-1}\bigl|\vd_{n+1}-\psi(\vd_n, r_n;\theta_v)\big|^2,\\
r_{n+1}&=\phi(\vd_n,r_n;\theta_r), \, r_0=0,\\
\thetas & \in \arg \min_{\theta \in \Theta} \J^N(\theta).
\end{align}
\end{subequations}


\begin{remark}
The choice $r_0=0$ is arbitrary and a change of initial condition can always be shifted to
the origin by redefining the right-hand side. However it is also possible to learn the best choice
of $r_0$, using data assimilation, given training data in form of an observed time-series
in the space where sequence $\{v_n\}$ lives.
\end{remark}

\begin{remark}
    The need for memory in time-series prediction can be motivated not only for non-Markovian systems, but also for Markovian but partially observed systems. One way to see this is using \emph{Takens' Theorem}\index{Takens' Theorem}, which says (roughly) that under quite general conditions, given partial observations of a Markovian system but enough memory, one can reconstruct the original dynamics.
    
    We state Takens' Theorem informally; see the bibliography for references. Suppose that $\Psi: \mathbb{R}^d\to\mathbb{R}^d$ defines a deterministic dynamical system, $v^\dagger_{j+1} = \Psi(v^\dagger)$, with an invariant set $A$. Then, define a \emph{time-delay vector}\index{time-delay embedding} of embedding dimension $m$ for a scalar-valued observation function $h: \mathbb{R}^d\to\mathbb{R}$, 
    \begin{equation*}
        H(v^\dagger_j) = \Bigl(h(v^\dagger_{j - m}), \ldots, h(v^\dagger_{j-1})\Bigr).
    \end{equation*}
    This function $H$ is defined everywhere on $A$.
    For $m$ large enough and quite generic choices of $h$, $A\to H(A)$ is one-to-one.
\end{remark}

\subsection{Memory and Reservoir Computing}

Including memory is important in many time series prediction tasks
as the data may not come from a Markov process. However learning
RNN structure can be challenging for two reasons: (i) because $r_n$ is an unobserved
latent variable; (ii) and because, within the context of gradient-based methods (Chapter \ref{ch:optimization}) propagation of
gradients of $\theta_r$ through the model is difficult. Reservoir
computing is one approach to overcome this. Rather than learning
$\theta_r$ it is simply picked at random from some probability
measure on space of appropriate dimension and the following
optimization problem is solved:
\begin{subequations}
\label{eq:rfc}
\begin{align}
\J^N(\theta_v) & = \frac{1}{N}\sum_{n=0}^{N-1}\bigl|\vd_{n+1}-\psi(\vd_n, r_n;\theta_v)\big|^2,\\
r_{n+1}&=\phi(\vd_n,r_n;\theta_r), \, r_0=0,\\
\thetas & \in \arg \min_{\theta_v \in \Theta_v} \J^N(\theta_v).
\end{align}
\end{subequations}
Crucially the optimization is only over $\theta_v$ as
$\theta_r$ is fixed at a randomly chosen value.

\begin{remark}
Typically the method requires $r$ of higher dimension than
for the RNN in order to be successful. This is related to
the issue of how expressive randomly chosen functions are.
Indeed there is a connection to the random features\index{random
features} methodology of Section \ref{sec:RF}. To see
this, note that equation (\ref{eq:rfc}b) reveals that
$$r_n=\mathcal{F}_n\bigl(\{\vd_m\}_{m=0}^{n-1};\theta_r).$$
Thus, once $\theta_r$ is chosen at random, $r_n$ is a random function of the history of the observed data up to time $n-1.$ 

\end{remark}

\section{Non-Gaussian Auto-Regressive Models} 
\label{sec:NGAR}

In this section we extend the autoregressive models with additive Gaussian noise in Section~\ref{sec:linear_autoregressive} to have a general probabilistic form. One approach to model non-Gaussian distributions uses transport (see Chapter~\ref{ch:transport}) to represent the state as a transformation of a Gaussian variable. That is, we can seek a transport $T \in \R^{(n+1)\du} \times \R^p$ depending on parameters $\theta \in \R^p$ that satisfies
\begin{equation} \label{eq:autoregressive_transport}
    T(v_1,\dots,v_{n},\epsilon;\theta) \sim \mathbb{P}(v_{n+1}|v_1,\dots,v_n), \quad \epsilon \sim \mathcal{N}(0,I),
\end{equation}
for each $(v_1,\dots,v_n) \in \R^{n\du}$. Let $\pi(v_{n+1}|v_1,\dots,v_n)$ denote the conditional density of the next step $v_{n+1}$ and let $\refT(v)$ be the standard Gaussian density, both on $\R^\du$. Then, the transport in~\eqref{eq:autoregressive_transport} satisfies the pushforward condition $T(v_1,\dots,v_n,\cdot)_\sharp \refT(v_{n+1}) = \pi(v_{n+1}|v_1,\dots,v_n)$.

If $T$ is invertible with respect to $\epsilon,$ we can use the change-of-variables formula to express the density of the transformed variable as
$$\pi(v_{n+1}|v_1,\dots,v_n) = \refT(T(v_1,\dots,v_n,\cdot;\theta)^{-1}\vert_{v_{n+1}})\det D_{v_{n+1}} T(v_1,\dots,v_n,\cdot;\theta)^{-1}\vert_{v_{n+1}}.$$

\begin{example} \label{eq:NonlinearAutoregressive}
If $T(v_1,\dots,v_{n},\epsilon;\theta) = \Psi(v_{n};\theta) + C^{1/2}\epsilon,$ for some map $\Psi \colon \R^\du \times \R^p \rightarrow \R^{\du}$ as in Subsections~\ref{sec:TimeSeries_Markovian} or~\ref{sec:TimeSeries_memory} and a positive definite matrix $C \in \R^{\du \times \du}$ we have 
\begin{align*}
    \pi(v_{n+1}|v_1,\dots,v_n) &= \refT\Bigl(C^{-1/2}\bigl(v_{n+1} - \Psi(v_n)\bigr)\Bigr) \det C^{-1/2} \\
    &= \frac{1}{\sqrt{(2\pi)^\du |C|}} \exp \left(-|v_{n+1} - \Psi(v_n)|_{C}^2 \right).
\end{align*}
That is, the conditional distribution for the next state $\pi(v_{n+1}|v_1,\dots,v_{n}) = \pi(v_{n+1}|v_n)$ is a multivariate Gaussian of the form $\mathcal{N}(\Psi(v_n),C)$.
\end{example}

These transports permit one to learn general autoregressive models that depend on an arbitrary number of past states. In this section we will learn transports that depend on at most one past state variable under Data Assumption~\ref{da:forc}. In this case, our goal is to find invertible transports $T \colon \R^{2\du} \times \R^p \rightarrow \R^\du$ so that $\pi(v_{n+1}|v_n,\theta) \coloneqq T(v_n,\epsilon;\theta)_\sharp \refT(v_{n+1})$ models the conditional distribution for the state at the next time. To simplify the notation, we denote the inverse map $T(v_n,\cdot)^{-1}\vert_{v_{n+1}}$ by $S(v_n,v_{n+1};\theta)$.

Given a sequence of data, we can learn the transport parameters by maximizing the log-likelihood of consecutive data pairs $\{(v^\dagger_{n+1},v^\dagger_{n})\}_{n=0}^{N-2}$ under the model. For a standard-Gaussian reference $\refT$, the log-likelihood is given by the loss function
\begin{align}
    \loss(\theta) &= \frac{1}{N-1} \sum_{n=0}^{N-1} \log \pi(v_{n+1}^\dagger|v_n^\dagger,\theta) \nonumber \\
    &= \frac{1}{N-1} \sum_{n=0}^{N-1} \left[\log \refT \bigl(S(v_{n}^\dagger,v_{n+1}^\dagger;\theta)\bigr) + \log \det D_{v_{n+1}} S(v_{n}^\dagger,v_{n+1}^\dagger;\theta) \right] \nonumber \\
    &= \frac{1}{N-1} \sum_{n=0}^{N-1} \left[-\frac{1}{2} |S(v_{n}^\dagger,v_{n+1}^\dagger)|^2 + \log \det D_{v_{n+1}} S(v_{n}^\dagger,v_{n+1}^\dagger) \right] + c,     \label{eq:NonlinearAutoRegLoss}
\end{align}
where $c$ is a constant that is independent of $\theta$. The optimal transport parameters are then given by 
$$\theta^\star \in \argmin_\theta \loss(\theta).$$

\begin{example} One popular non-Gaussian transformation is based on a nonlinear diagonal transformation of the form
$$S(v_n,v_{n+1};\theta) = s(v_{n+1} - \Psi(v_n;\theta);\theta),$$
where $s \in \R^{\du} \times \R^p \rightarrow \R^\du$ is an invertible function and $\Psi \in \R^{\du} \times \R^{p} \rightarrow \R^\du$. This can be re-written in terms of the direct transport as
$$T(v_n,\epsilon;\theta) = \Psi(v_n;\theta) + s^{-1}(\epsilon;\theta), \quad \epsilon \sim \refT.$$
That is, the next-state is given by the previous state with additive noise, which is non-Gaussian for nonlinear $s$. The joint distribution for the states at all times $n$ that follow this process is often referred to as a \emph{non-paranormal}\index{non-paranormal} or \emph{Gaussian copula model}\index{copula model}.
\end{example}

\begin{example} If $S(v_{n},v_{n+1};\theta) = v_{n+1} - \Psi(v_{n};\theta),$ as in example~\eqref{eq:NonlinearAutoregressive} with $C = I$, we have $D_{v_{n+1}} S(v_n,v_{n+1}) = I$. Thus, the learning problem based on the loss function in~\eqref{eq:NonlinearAutoRegLoss} reduces to
\begin{align*}
    \theta^\star \in \argmin_\theta \frac{1}{2(N-1)} \sum_{n=0}^{N-1} \left[ |v_{n+1}^\dagger - \Psi(v_{n}^\dagger;\theta)|^2 \right],
\end{align*}
That is, we can identify the model parameters by solving a supervised learning problem for the nonlinear map $\Psi$.
\end{example}




\section{Bibliography}
\label{sec:TSB}
An extensive introduction to linear autoregressive processes, including the conditions for stationarity and ergodicity, is provided in \cite{hansen_econometrics_2022}.
The Lorenz '63 model is proved to be ergodic in
\cite{tucker1999lorenz,tucker2002rigorous} providing a useful example. Indeed in this context central limit theorems have been proved \cite{holland2007central}, 
characterizing the fluctuations about the law of large numbers limit in \eqref{eq:erg}.

Analog forecasting was first introduced by Lorenz in \cite{lorenz_atmospheric_1969}. A historical overview of analog forecasting and extensions is given in \cite{farmer_exploiting_1988}. The kernel analog
regularization of Lorenz's idea was introduced and
then studied in \cite{giannakis2019data,alexander2020operator}.

Memory in the context of learning model error is discussed in \cite{levine_framework_2022}. Takens' Theorem and other embedding theorems are reviewed in \cite{sauer_embedology_1991}.


General non-linear autoregressive models have been considered for time-series modeling using various probabilistic models, such as conditional normalizing flows,  in~\cite{oliva2018transformation, rasul2020multivariate}. Some of these models rely on recurrent neural networks architectures that can summarize the past states and extract relevant features for making predictions.

\chapter{\Large{\sffamily{Optimization}}}\label{ch:optimization}

We provide here an introduction to various topics
in optimization that are pertinent to these notes.
Section \ref{sec:grad} is concerned with gradient-based
optimization, including deterministic and stochastic
gradient descent. In Section \ref{sec:auto-differentiation}
we study auto-differentiation.
Section~\ref{sec:142} is devoted to expectation-maximization.
In Section~\ref{sec:NGN} we discuss Newton and Gauss-Newton
methods. Section~\ref{sec:EKI} is devoted to ensemble Kalman
methods for parameter estimation and inversion.\footnote{Although this topic might be argued to belong in the first part of the book (Inverse Problems), it builds on ensemble Kalman methods from the second
part of the book (Data Assimilation) which is why we cover it in this appendix chapter from part three of the book.} Other topics in optimization are referenced in the bibliography Section \ref{sec:OB}.

Before moving into these sections we recall a definition
that will be useful in what follows.

\begin{definition}
    A function $f: \R^d\to\R$ is called \emph{convex}\index{convex!function} if, for all $x, y\in \R^d$ and for all $\theta\in [0, 1]$, we have that
    \begin{equation*}
        f(\theta x + (1-\theta) y) \leq \theta f(x) + (1-\theta) f(y).
    \end{equation*}
    A function is called \emph{strictly convex} if the inequality is strict for $x \ne y.$
\end{definition}


\section{Gradient Descent}\index{gradient descent}
\label{sec:grad}

\subsection{Deterministic Gradient Descent}\index{gradient descent!deterministic}

\begin{definition} Given function $f \in C^1(\R^\du,\R)$, 
    \emph{gradient descent} refers to
the iterative generation of sequence $\{x_j\}_{j \in \Z^+}$
from a sequence of step-sizes $\{\alpha_j\}_{j \in \Z^+}$ by picking an $x_0
\in \R^\du$ and then iterating as follows:
    \begin{equation*}
        x_{j+1} = x_j - \alpha_j \nabla f(x_j), \qquad j \in \Z^+.
    \end{equation*}
\end{definition}

\begin{remark}
Often the sequence $\{\alpha_j\}_{j \in \Z^+}$ is determined
online as the algorithm progresses, with $\alpha_j$ depending
on $\{x_i\}_{i=1}^{j}.$ 
In the simplest case, $\alpha_j = \alpha$ is some fixed constant, chosen small enough that $f(x_j)$ decreases with increasing $j$; however being able to make such a choice depends on having bounds
on the size of $Df.$ The next theorem considers a case where such bounds follow from assumptions about the Hessian of $f$. 
\end{remark}

The following theorem demonstrates that a specific fixed $\alpha$, under assumptions on the Hessian, leads to a linear convergence of gradient descent to the global minimum.


\begin{theorem} Let $f \in C^2(\R^\du,\R)$ with Hessian satisfying, for all $x \in \R^\du$,
$$\mu I \preceq D^2 f(x) \preceq L I$$
for some $0<\mu \le L<\infty.$
Then $f(\cdot)$ has a unique global minimum $x^\star$. Furthermore, at iteration $j \ge 1$ of gradient descent initialized at $x_0$ with step size $\alpha_j \equiv 1/L$, 
    \begin{equation*}
        f(x_j) - f(x^\star) \leq \left(1 - \frac{\mu}{L}\right)^j \bigl(f(x_0) - f(x^\star)\bigr).
    \end{equation*}
\end{theorem}
\begin{proof} The existence of a unique global minimizer is a consequence of the convexity of $f$ implied by the bounds on the
Hessian. By Taylor's theorem for a twice-differentiable function $f$ we have
\begin{align*}
f(y) &= f(x) + \langle \nabla f(x), y - x\rangle + \frac{1}{2}(y - x)^\top H (y - x),\\
H & = \int_0^1 D^2 f\bigl(sx+(1-s)y\bigr) \, ds.
\end{align*}
From the uniform bound on the Hessian, we have the upper and lower bounds
\begin{subequations}
\label{eq:QuadBound}    
\begin{align}
    f(y) &\leq f(x) + \langle \nabla f(x), y - x\rangle + \frac{L}{2}|y - x|^2, \label{eq:QuadUpperBound} \\
    f(y) &\geq f(x) + \langle \nabla f(x), y - x\rangle + \frac{\mu}{2}|y - x|^2. \label{eq:QuadLowerBound}
\end{align}
\end{subequations}
Taking $y = x_{j+1}$ and $x = x_{j}$ in~(\ref{eq:QuadBound}a) with the gradient descent update $x_{j+1} = x_j - \alpha_j \nabla f(x_j)$ we have
\begin{align}
f(x_{j+1}) &\leq f(x_j) + \langle \nabla f(x_j), x_{j+1} - x_j \rangle + \frac{L}{2}|x_{j+1} - x_j|^2 \nonumber \\
&= f(x_j) - \alpha_j |\nabla f(x_j)|^2 + \frac{L}{2}|\alpha_j \nabla f(x_j)|^2 \nonumber \\
&=  f(x_j) - \frac{1}{2L}|\nabla f(x_j)|^2, \label{eq:GradDescentGuarantee}
\end{align}
where in the last line we have used that $\alpha_j = 1/L$. 

Now take $y = x^\star$ and $x = x_j$ in~(\ref{eq:QuadBound}b) and multiply both sides by a negative sign to get
$$f(x_j) - f(x^\star)\leq \langle \nabla f(x_j),  x_j - x^\star \rangle - \frac{\mu}{2}|x^\star - x_j|^2.$$
Adding and subtracting the norm of the gradient to the right-hand-side, we have
\begin{align*}
f(x_j) - f(x^\star) &\leq \langle \nabla f(x_j), x_j - x^\star\rangle - \frac{\mu}{2}|x^\star - x_j|^2 \\
&= \frac{1}{2\mu}|\nabla f(x_j)|^2 - \frac{1}{2\mu}|\nabla f(x_j)|^2 + \langle \nabla f(x_j), x_j - x^\star\rangle - \frac{\mu}{2}|x^\star - x_j|^2 \\
&= \frac{1}{2\mu}|\nabla f(x_j)|^2 - \frac{1}{2}\left|\sqrt{\frac{1}{\mu}}\nabla f(x_j) - \sqrt{\mu}(x^\star - x_j) \right|^2 \\
&\leq \frac{1}{2\mu}|\nabla f(x_j)|^2.
\end{align*}
Re-arranging the terms we have $-|\nabla f(x_j)|^2 \leq -2\mu \bigl(f(x_j) - f(x^\star)\bigr)^2$. Substituting this on the right-hand side of~\eqref{eq:GradDescentGuarantee} gives us
$$f(x_{j+1}) \leq f(x_j) -\frac{\mu}{L}\bigl(f(x_j) - f(x^\star)\bigr).$$
If we subtract $f(x^\star)$ from both sides and let $e_{j+1} = f(x_{j+1}) - f(x^\star),$ we have
$$e_{j+1} \leq e_j - \frac{\mu}{L}e_j = \left( 1 - \frac{\mu}{L}\right)e_j$$
for all $j \geq 1$. By induction on $j$, we have the desired result. 
\end{proof}

\begin{remark} Consider convex functions with Lipschitz gradients, properties that follow from the Hessian bounds in the
preceding theorem. For such objective functions
    there are modifications of gradient descent that have better convergence rates than the one stated above. For instance, Nesterov's accelerated gradient descent has a quadratic convergence rate, which is optimal for this class of functions.\index{gradient descent!Nesterov's accelerated} We will not discuss these other methods here but provide references in the bibliography.
\end{remark}

\subsection{Stochastic Gradient Descent}\index{gradient descent!stochastic}

Here we consider the minimization of an objective function $f:\R^\du \to \R$ that is defined by an expectation of a function $F\colon \R^d \times \R^{d_z} \rightarrow \R$. That is, 
\begin{equation}
\label{eq:fF}
f(x) = \int F(x,z) \, d\zeta(z).   
\end{equation}
Here $\zeta$ denotes the probability density function of the random variable $z \in \R^{d_z}$. While explicit evaluations of $f$ or its gradients are challenging as a result of the expectation, we assume that it is possible to evaluate $D_x F(x,z)$ for any realization of the random variable $z$.

Assuming that $\zeta$ is replaced by an empirical approximation 
\begin{equation*}
    \zeta^N = \frac{1}{N}\sum_{n=1}^N \delta_{z^{(n)}},
\end{equation*}
with the $z^{(n)}$ sampled i.i.d. from $\zeta,$ then $f$ becomes
\begin{equation}
\label{eq:fF2}
f(x) = \frac{1}{N}\sum_{n =1}^N F(x,z^{(n)}).   
\end{equation}
The gradient of $f$ is then given by 
\begin{equation}\label{eq:grad_full}
    D f(x) = \frac{1}{N}\sum_{n =1}^N D_x F(x,z^{(n)}).
\end{equation}
This also has the interpretation as a Monte Carlo estimator of
the gradient of $f$ defined by \eqref{eq:fF}.

For large $N$, the evaluation of the above sum may be too expensive. Instead, one can pick $M < N$ i.i.d. samples from $\zeta^N$; this corresponds to picking $M$ random indices $\{\omega^{(m)}\}_{m=1}^M$, where the elements of this
set $\omega^{(m)}$ are sampled uniformly with replacement from $1,\ldots,N$. Then the gradient can be approximated as
\begin{equation*}
    D f(x) \approx \frac{1}{M}\sum_{m=1}^M D_x F(x,z^{(\omega^{(m)})}).
\end{equation*}
This is known as a \emph{mini-batch}.\index{mini-batch} Carrying out gradient descent with this mini-batch is known as \emph{stochastic gradient descent}. 

\begin{definition} Given function  $F \in C^{1,0}(\R^\du \times \R^{\dz}, \R),$ 
    \emph{stochastic gradient descent} with respect to $f$ defined
    by \eqref{eq:fF2}, refers to
the iterative generation of sequence $\{x_j\}_{j \in \Z^+}$
from a sequence of step-sizes $\{\alpha_j\}_{j \in \Z^+}$
and $j$-indexed sets $\{\omega_j^{(m)}\}_{m=1}^M$ with points  sampled uniformly with replacement from $1,\ldots,N$, independently for each $j$,
by picking an $x_0 \in \R^\du$ and then iterating as follows:
$$x_{j+1} = x_{j} - \frac{\alpha_j}{M}\sum_{m=1}^M D_x F(x_j,z^{(\omega^{(m)}_j)}).$$
\end{definition}



\begin{remark}
    Even if the full gradient with respect to the empirical measure \eqref{eq:grad_full} can be feasibly computed, the stochasticity in stochastic gradient descent can be helpful in escaping from local minima for non-convex objective functions; in the context of optimizing neural networks
    it is also sometimes advocated as a method to avoid overfitting.
\end{remark}

\section{Automatic Differentiation}\index{auto-differentiation}
\label{sec:auto-differentiation}

Gradients (and higher-order derivatives) are often difficult to obtain in closed form for complex cost functions. Finite difference approximations, on the other hand, are often inaccurate and expensive for high-dimensional problems.

\emph{Automatic differentiation} involves repeated application of chain rule on elementary operations that enables computing derivatives accurately to working precision. That is, suppose an output variable $y\in\mathbb{R}^{d_n}$ is related to an input variable $x\in\mathbb{R}^{d_0}$ by some function $f$, i.e., $y = f(x),$ and suppose that the Jacobian of $f$ is not readily available in closed form. We assume the implementation of $f$ in computer code is made up of $n$ elementary operations $f_i: \mathbb{R}^{d_{i-1}}\to\mathbb{R}^{d_i}$ (for instance, addition, multiplication, logarithms, etc.), such that
\begin{equation}
    f(x) = f_n \circ f_{n-1} \circ \cdots \circ f_1(x),
\end{equation}
where the Jacobians for these elementary operations, $\nabla f_i: \mathbb{R}^{d_{i-1}}\to\mathbb{R}^{d_{i}\times d_{i-1}}$, are available in closed form. The goal of automatic differentiation is to evaluate $Df(x)$ from the Jacobians of the elementary operations.

By representing the output $g_i = f_i(g_{i-1})$ of each elementary operations by a node, we can use a graph to represent the function evaluation where the directed edges encode the input dependencies $g_{i-1}$ (i.e., parents) that are required to evaluate $f_i$. This is known as the \emph{computational graph}\index{computational!graph}. The nodes without parents correspond to the original inputs $x$ to the function $f$. After constructing the graph, we can define the \emph{forward mode}\index{forward!mode} as the process of computing the output $y$, and possibly the gradient of $f$, by traversing the graph starting from the inputs $x$. The \emph{reverse mode}\index{reverse!mode} starts with the final output node and traverses the graph back to the inputs to compute the gradient of $f$. The following two subsections demonstrate how the full Jacobian of $f$ is assembled in forward and reverse mode automatic differentiation.

\begin{remark}
    In realistic implementations, instead of multiplying the full Jacobians of each operation, only the partial derivatives of variables that interact with each other in the computational graph are used. For simplicity of exposition, we present the algorithms with the full Jacobians here.
\end{remark}

\subsection{Forward Mode}
Forward mode automatic differentiation proceeds to accumulate the incremental function evaluations along with their derivatives.

Writing the partial evaluations up to $i\leq n$ as
\begin{equation*}
    g_i = (f_i\circ\cdots\circ f_1)(x),
\end{equation*}
by the chain rule we have that
\begin{equation}\label{eq:jacob_prod}
    D_x f(x) =  \bigl(D_{g_{n-1}}f_n(g_{n-1})\bigr)\cdots \bigl(D_{g_1}f_2(g_1)\bigr)\bigl(D_x f_1(x)\bigr).
\end{equation}
This suggests the following algorithm:
\begin{algorithm}
\caption{\label{alg:forward_autodiff}Forward Mode Automatic Differentiation}
\begin{algorithmic}[1]
\STATE {\bf Input}:  The functions $\{f_i(\cdot)\}_{i=1}^n$, their corresponding Jacobians $\{Df_i(\cdot)\}_{i=1}^n$, and the function input $x$.
\STATE Set $g_1 = f_1(x)$ and $J_1 = D f_1(x)$.
\STATE For $i = 2, \ldots, n$: set $g_i = f_i(g_{i-1})$ and $J_i = \bigl(Df_i(g_{i-1})\bigr) J_{i-1}$.
\STATE{\bf Output}: The function output $y = f(x) = g_n$ and the derivative $Df(x) = J_n$.
\end{algorithmic}
\end{algorithm}
\FloatBarrier

The number of floating point operations required to compute $Df(x)$ is
\begin{equation*}
    d_0 \sum_{i=1}^{n-1} d_{i+1} d_i.
\end{equation*}
Assuming for simplicity that all the $d_i$ except for $d_0$ and $d_n$ are fixed at $d$, we have a cost of $d^2(n-2)d_0 + d_n d d_0$. This scales favorably for large $d_n$ (large output dimension), but not for large $d_0$ (large input dimension).

\subsection{Reverse Mode}

Motivated by the poor scaling of forward mode automatic differentiation with input dimension, \emph{reverse mode} automatic differentiation also computes the product of Jacobians \eqref{eq:jacob_prod},
\begin{equation*}
    D_x f(x) =  \bigl(D_{g_{n-1}}f_n(g_{n-1})\bigr)\cdots \bigl(D_{g_1}f_2(g_1)\bigr) \bigl(D_x f_1(x)\bigr),
\end{equation*}
but instead of computing the product from right to left, it computes it from left to right. The algorithmic implementation requires a forward pass to evaluate the function and a backwards pass to compute the derivative:
\begin{algorithm}
\caption{\label{alg:reverse_autodiff}Reverse Mode Automatic Differentiation}
\begin{algorithmic}[1]
\STATE {\bf Input}:  The functions $\{f_i(\cdot)\}_{i=1}^n$, their corresponding Jacobians $\{Df_i(\cdot)\}_{i=1}^n$, and the function input $x$.
\STATE Set $g_1 = f_1(x)$.
\STATE For $i = 2, \ldots, n$: set and store $g_i = f_i(g_{i-1})$.
\STATE Set $J_n = D f_n(g_{n-1})$.
\STATE For $i = n-1, \ldots, 1$ set $J_i = J_{i+1}Df_i(g_{i-1})$.
\STATE{\bf Output}: The function output $y = f(x) = g_n$ and the derivative $Df(x) = J_1$.
\end{algorithmic}
\end{algorithm}
\FloatBarrier

This leads to the number of floating point operations in computing the Jacobian being
\begin{equation*}
    d_n \sum_{i=1}^{n-1} d_{i-1} d_i.
\end{equation*}
Again assuming that all the $d_i$ are fixed at $d$ except for $d_0$ and $d_n$, the total cost is $d^2(n-2)d_n + d_n d d_0$. As opposed to forward mode automatic differentiation, reverse mode thus scales favorably with a large number of inputs (large $d_0$), but poorly with a large number of outputs (large $d_n$).

\begin{remark}
    Backpropagation, a common method for computing the gradient of the objective function with respect to the weights of a neural network, is a special case of reverse mode differentiation.
\end{remark}

\section{Expectation-Maximization}\label{sec:142}\index{expectation maximization}
 The \index{expectation maximization}expectation-maximization (EM) algorithm is a general-purpose approach to \index{maximum likelihood estimation}maximum likelihood estimation with \index{latent}latent variables. Central to the abstract derivation of the EM algorithm is the following lower bound of the \index{likelihood}log-likelihood function, obtained using \index{Jensen inequality}Jensen inequality:
\begin{align*}
 \log \Prob (Y | \theta) &= \log \int \Prob (V, Y| \theta) \, dV \\ 
&  = \log \int \frac{\Prob (V, Y| \theta)}{q(V)} q(V) \, dV \\ 
& \ge \int\log\biggl( \frac{\Prob (V, Y| \theta)}{q(V)} \biggr)  q(V)  \, dV \\
&  = \ELBO(\Prob(V,Y | \theta), q) \\ 
&  =:\mathcal{L}(q, \theta),
\end{align*}
where $q$ is any probability density function over the \index{latent}latent variables $V$ with compatible support, $\ELBO$ denotes the evidence lower bound introduced in Definition \ref{d:elbo}, and the last line defines $\mathcal{L}(q,\theta)$. 
In fact, the following theorem shows that the difference between $\log \Prob (Y | \theta)$ and $\mathcal{L}(q, \theta)$ is given by the \index{divergence!Kullback--Leibler}KL divergence $\dkl \bigl( q \| \Prob(V|Y,\theta)\bigr),$ which is always non-negative. Notice that the proof is identical to that of the \index{variational!formulation of Bayes theorem}variational formulation of \index{Bayes theorem}Bayes theorem in Chapter~\ref{ch:VI}. A similar result was also used in the proof of Theorem \ref{theorem:filter_factorized} in Chapter \ref{ch:LG}.

\begin{theorem}\label{th:EMlikecharacterization}
It holds that 
\begin{equation*}
\log \Prob (Y | \theta) = \mathcal{L}(q, \theta) + \dkl \bigl( q \| \Prob(V|Y,\theta)\bigr).
\end{equation*}
\end{theorem}
\begin{proof}
Using the definition of $\mathcal{L}(q, \theta),$ product rule, and the definition of the \index{divergence!Kullback--Leibler}KL divergence in Chapter \ref{ch:distances}, we have
\begin{align*}
\mathcal{L}(q, \theta) &= \int\log\biggl( \frac{\Prob (V, Y)| \theta)}{q(V)} \biggr)  q(V)  \, dV \\
& = \int \log \biggl( \frac{\Prob(V|Y,\theta)}{q(V)} \biggr) q(V) \, dV + \int \log \Prob(Y|\theta) q(V) \, dV \\
& = - \dkl \bigl(q \| \Prob(V |Y, \theta) \bigr) + \log \Prob(Y|\theta),
\end{align*}
as desired.
\end{proof}

Theorem \ref{th:EMlikecharacterization} motivates an iterative approach to maximize the \index{likelihood}log-likelihood function $\log \Prob (Y | \theta),$ which is equivalent to maximizing the \index{likelihood}likelihood $\Prob (Y | \theta)$ since the logarithm is an increasing function.
Given  the current iterate  $\theta_j,$ we obtain the next iterate  $\theta_{j+1}$ in two steps, maximizing in turn the two components of the lower bound:
\begin{enumerate}
\item First,  we find $q_j(V)$ that maximizes the lower bound $\mathcal{L}(q, \theta_j)$  over probability density function $q.$  From Theorem \ref{th:EMlikecharacterization}, 
$$\log \Prob (Y | \theta_j) = \mathcal{L}(q, \theta_j) + \dkl \bigl( q \| \Prob(V|Y,\theta_j)\bigr),$$
and it follows that maximizing $\mathcal{L}(q, \theta_j)$ or minimizing $\dkl \bigl( q \| \Prob(V|Y,\theta_j)\bigr)$ over $q$ are equivalent. Since the \index{divergence!Kullback--Leibler}KL divergence is minimized when both arguments agree, we obtain that $q_j(V) = \Prob(V|Y,\theta_j).$
\item Second, we  obtain $\theta_{j + 1}$ by maximizing the lower bound  $\mathcal{L}(q_j, \theta)$ over $\theta.$ Note that 
\begin{equation}
\mathcal{L}(q_j, \theta) = \int \log\Prob(V, Y | \theta) \Prob(V|Y, \theta_j) \, dV + c,
\end{equation}
where $c$ is independent of $\theta.$ Hence, the quantity to maximize is the expected value of the joint log-density $\log  \Prob (V, Y | \theta)$ with respect to $q_j(V) = \Prob(V|Y, \theta_j).$
\end{enumerate}


Combining these two steps gives the \index{expectation maximization}EM framework: 
\begin{algorithm}
\caption{\label{alg:EM} Expectation Maximization}
\begin{algorithmic}[1]
\STATE {\bf Input}:  Initialization $\theta_0.$
\STATE For $j = 0, 1, \ldots$ do the following expectation and maximization steps:
\STATE {\bf E-Step}: Compute 
\begin{align*}
\Expect^{V \sim  \Prob(V|Y, \theta_j)} \Bigl[ \log \Prob(V, Y | \theta) \Bigr]= \int \log \Prob(V, Y | \theta) \Prob(V|Y, \theta_j) \, dV. 
\end{align*}
\vspace{-0.5cm}
\STATE{{{\bf M-Step}}}: Compute 
\begin{equation*}
\theta_{j+1} \in \arg \max_\theta \Expect^{V \sim  \Prob(V|Y, \theta_j)} \Bigl[ \log \Prob(V, Y | \theta) \Bigr].
\end{equation*}
\STATE{\bf Output}: Parameter estimates $\{\theta_j\}_{j \ge 0}.$
\end{algorithmic}
\end{algorithm}
\FloatBarrier


The following result shows that the \index{expectation maximization}EM framework has the desirable property that the \index{likelihood}likelihood function increases monotonically along iterates $\theta_j.$ 

\begin{theorem}\label{th:EMmonotone}
Let $\{\theta_j \}_{j \ge 0}$ be the iterates of the EM Algorithm \ref{alg:EM}. Then, 
\begin{equation}
\log \Prob(Y | \theta_j) \le \log \Prob (Y | \theta_{j + 1}).
\end{equation}
\end{theorem}
\begin{proof}
Let $q_j(V) = \Prob(V|Y, \theta_j).$  Using the \index{likelihood}log-likelihood characterization in Theorem \ref{th:EMlikecharacterization}, it holds that 
\begin{align*}
\log \Prob (Y | \theta_{j + 1}) &=\mathcal{L}(q_j, \theta_{j + 1}) + \dkl \bigl( q_j \| \Prob(V|Y,\theta_{j + 1})\bigr) \\ 
&\ge \mathcal{L}(q_j, \theta_{j}) +  \dkl \bigl( q_j \| \Prob(V|Y,\theta_{j + 1})\bigr) \\
&\ge \mathcal{L}(q_j, \theta_{j})  + \dkl \bigl( q_j \| \Prob(V|Y,\theta_{j })\bigr) \\
& = \log \Prob (Y | \theta_{j}).
\end{align*}
The first inequality follows because $\theta_{j + 1} \in \arg \max_\theta \mathcal{L}(q_j, \theta);$ the second because $\dkl \bigl(q_j \| \Prob(V|Y, \theta_j) \bigr) = 0$ since $q_j = \Prob(V|Y, \theta_j),$ while $\dkl \bigl( q_j \| \Prob(V|Y,\theta_{j+1 })\bigr) \ge 0.$ 
\end{proof}

\begin{remark}
\label{rem:em}
As a consequence of Theorem \ref{th:EMmonotone} it is possible to deduce---under mild assumptions---that the iterates $\theta_j$ of the \index{expectation maximization}EM algorithm converge, as $j \to \infty,$ to a local maximizer of the \index{likelihood}likelihood function. It is important to note, however, that the expectation in the E-step and the \index{optimization}optimization in the M-step are often intractable. \index{Monte Carlo}Monte Carlo, \index{filtering}filtering, or \index{smoothing}smoothing algorithms may be employed to approximate the E-step, and \index{optimization}optimization algorithms to approximate the M-step. Such approximations can cause loss of monotonicity and convergence guarantees. 
\end{remark}

\section{Newton and Gauss--Newton}
\label{sec:NGN}

\subsection{Newton's Method}\index{Newton's method}

Newton's method is a common root-finding method, which can also be applied to optimization.
\begin{definition} Given function $f \in C^2(\R^\du,\R)$, 
with invertible Hessian,
    \emph{Newton's method} refers to
the iterative generation of sequence $\{x_j\}_{j \in \Z^+}$
by picking an $x_0 \in \R^\du$ and then iterating as follows:
    \begin{equation}\label{eq:newton}
        x_{j+1} = x_j - \bigl(D^2 f(x_j)\bigr)^{-1}Df(x_j).
    \end{equation}
\end{definition}



Newton's method proceeds by optimizing successive quadratic approximations to $f$, as the following theorem shows.
\begin{theorem}
    If $f$ is convex, then $f(x_{j+1})$ is the local minimum of the quadratic approximation of $f$ around $x_j$.
\end{theorem}
\begin{proof}
    We first approximate $f$ around $x_j$ by its second-order Taylor expansion:
    \begin{equation}\label{eq:taylor_quad}
        f(x_j + t) \approx f(x_j) + \langle \nabla f(x_j), t\rangle + \frac{1}{2}t^\top D^2 f(x_j) t,
    \end{equation}
    where $t$ is some vector. Since $f$ is convex, the Hessian is positive semidefinite, and the right-hand side of \eqref{eq:taylor_quad} is convex as a function of $t$, meaning that it can be minimized by setting the derivative to 0. Differentiating $f(x_j + t)$ with respect to $t$ and setting it to 0,
    \begin{equation*}
        Df(x_j) + D^2 f(x_j) t = 0,
    \end{equation*}
    and thus
    \begin{equation*}
        t = -\bigl(D^2 f(x_j)\bigr)^{-1}Df(x_j).
    \end{equation*}
\end{proof}



\subsection{Gauss--Newton}\index{Gauss--Newton}
Let $g$ be an $\R^m$-valued function and consider 
the nonlinear least squares optimization problem 
\begin{subequations}
\label{eq:nnlsq}
\begin{align}
    \J(x) &= \frac12 g(x)^\top g(x) = \frac12 \sum_{k=1}^m g_k(x)^2,\\
    x^\star &\in  \arg \min_{x \in \R^d} \J(x).
\end{align}
\end{subequations}

\begin{definition}
Given function $g \in C^1(\R^\du,\R^m)$ 
such that $(\bigl(Dg(x_j)\bigr)^\top \bigl(Dg(x_j)\bigr)$
is invertible,
    the \emph{Gauss--Newton method} for minimizing nonlinear least squares problems of the form \eqref{eq:nnlsq}
     refers to the iterative generation of sequence 
     $\{x_j\}_{j \in \Z^+}$
by picking an $x_0 \in \R^\du$ and then iterating as follows:
    \begin{align*}
        x_{j+1} &= x_j -\Bigl(\bigl(Dg(x_j)\bigr)^\top \bigl(Dg(x_j)\bigr)\Bigr)^{-1}\bigl(Dg(x_j)\bigr)^\top g(x_j). 
    \end{align*}
\end{definition}

Gauss--Newton results from applying Newton's method \eqref{eq:newton} to (\ref{eq:nnlsq}a), and neglecting the second-order terms of $g$ in the Hessian of $\J$. Notice that
\begin{equation*}
    D\J(x) =  \bigl(Dg(x)\bigr)^\top g(x),
\end{equation*}
and that
\begin{equation}\label{eq:hessian_J}
    \bigl(D^2\J(x)\bigr)_{ij} = \bigl(Dg(x)^\top Dg(x)\bigr)_{ij} + \sum_{k=1}^m g_k(x) \bigl(D^2g_k(x)\bigr)_{ij}.
\end{equation}
Substituting these expressions into Newton's method \eqref{eq:newton} and setting the second term in \eqref{eq:hessian_J} to 0, recovers the Gauss--Newton method.

\section{Ensemble Kalman Inversion}\index{ensemble Kalman inversion}
\label{sec:EKI}

We describe here a derivative-free optimization method for nonlinear least squares problems. Consider the cost function
\begin{equation*}
    \J(u) = \frac{1}{2} | y- G(u)|_{\Gamma}^2,
\end{equation*}
for some (possibly) nonlinear function $G(\cdot)$ and positive definite matrix $\Gamma$.

\emph{Ensemble Kalman inversion}\index{ensemble Kalman inversion} (EKI) involves first drawing an initial set of $\Sam$ particles from a Gaussian distribution with a given mean $m_0$ and covariance $C_0$, i.e.,
\begin{equation*}
    u_0^{(\sam)} \sim \mathcal{N}(m_0, C_0)\quad\text{i.i.d.}, \quad \sam=1,\ldots,\Sam.
\end{equation*}
EKI proceeds to evolve these particles for iterations $j=1,\ldots,J$ 
according to
\begin{subequations}
\begin{align}
u_{j+1}^{(\sam)} &= u_j^{(\sam)}+K_{j+1}\bigl(y-\eta_{j+1}^{(\sam)}-G(u_j^{(\sam)})\bigr),\quad \sam=1,\ldots,\Sam,\\
\eta_{j+1}^{(\sam)} &\sim \Nc(0,\Gamma) \quad\text{i.i.d.},
\end{align}
\end{subequations}
where the matrix $K_{j+1}$ is calculated according to
\begin{subequations}
\begin{align}
\bar{u}_{j+1} &= \frac{1}{\Sam}\sum^{\Sam}_{\sam=1} u_{j+1}^{(\sam)}, \\
\bar{G}_{j+1} &= \frac{1}{\Sam}\sum^{\Sam}_{\sam=1} G(u_{j+1}^{(\sam)}), \\
C_{j+1}^{ug} &= \frac{1}{\Sam}\sum^{\Sam}_{\sam=1}\bigl(u^{(\sam)}_{j+1}-\bar{u}_{j+1}\bigr)\otimes \bigl(G(u^{(\sam)}_{j+1})-\bar{G}_{j+1}\bigr),\\
C_{j+1}^{gg} &= \frac{1}{\Sam}\sum^{\Sam}_{\sam=1}\bigl(G(u^{(\sam)}_{j+1})-\bar{G}_{j+1}\bigr)\otimes \bigl(G(u^{(\sam)}_{j+1})-\bar{G}_{j+1}\bigr),\\
C_{j+1}^{yy} &= C_{j+1}^{gg}+\Gamma,\quad
K_{j+1} = C_{j+1}^{ug}\bigl(C_{j+1}^{yy}\bigr)^{-1}.
\end{align}
\end{subequations}

\begin{remark}
The algorithm produces an ensemble $\{u_j^{(\sam)}\}_{\sam=1}^N$ which, for each $j$, remains in the
linear span of the initial ensemble $\{u_0^{(\sam)}\}_{\sam=1}^N.$ Thus the algorithm may be viewed
as seeking to minimize the objective function over a finite-dimensional subspace. In the case
of linear $G(\cdot)$ this leads to a thorough theoretical understanding of the algorithm, and
variants on it including Tikhonov regularization and continuous time. Furthermore, EKI can often still approximate the minimizer of the loss function well in the nonlinear setting, with a relatively small $J$ and $N$.
\end{remark}

\begin{remark}
    As the name suggests, there is similarity between EKI and the ensemble Kalman filter (EnKF: Section \ref{sec:enkf}). At every iteration, EKI approximates the solution to a nonlinear inverse problem using an ensemble approximation to the solution of a linear Gaussian inverse problem (Example \ref{ex:loss-l2}) and formally replacing the linear forward model with the nonlinear one.
\end{remark}

\section{Bibliography}
\label{sec:OB}

Optimization is reviewed in a number of textbooks, including \cite{boyd_convex_2004,nocedal_numerical_2006}. Convergence
proofs for gradient descent and stochastic gradient descent
may be found in \cite{sanz-alonso_inverse_2023} in simple
settings. Nesterov's accelerated gradient method and its rate of convergence is discussed in detail in \cite{nesterov_introductory_2004}.
Gradient descent can be formulated in continuous time as a \emph{gradient flow};\index{gradient flow} see
\cite{hale,ambrosio2005gradient}.
A detailed overview of automatic differentiation is given in \cite{griewank_evaluating_2008}.

The EM framework for \index{maximum likelihood estimation}maximum likelihood estimation was introduced in \cite{dempster1977maximum}; see \cite{meng1997algorithm}
for a review and see \cite{sahu1999convergence} for an insightful connection to Gibbs sampling. The generalization of the EM framework for optimization problems where the objective does not necessarily involve conditional expectations is known as the Minorize-Maximization (MM), or equivalently Majorize-Minimization, algorithm. An overview of MM algorithms and their properties can be found in~\cite{lange2016mm}.

The book \cite{nocedal_numerical_2006} includes discussion of Newton and Gauss--Newton methods. 

Ensemble Kalman inversion (EKI) as defined here was introduced in \cite{iglesias2013ensemble}, and
various adaptations of it may be found in \cite{iglesias2015iterative,iglesias2016regularizing,chada2019tikhonov,iglesias2021adaptive}; it is 
also discussed in the final chapter of the textbook \cite{sanz-alonso_inverse_2023}. 
For analysis in continuous time see \cite{schillings2017analysis,schillings2018convergence}.
A mean field perspective on EKI and an interpretation of the method as a covariance-preconditioned gradient flow is provided in \cite{calvello22}. Variants of EKI are discussed in \cite{huang2021unscented2,huang2022iterated}. The use of EKI to train machine learning models, or machine learning models embedded within physical models, is discussed in \cite{kovachki2019ensemble,lopez2022training,wu2023learning,chen_neural_2024}.

Reinforcement learning\index{reinforcement learning}, a form of online optimization, is seeing growing use in numerous
applications of machine learning. For historical underpinnings of the field see
\cite{kaelbling1996reinforcement,sutton1999reinforcement}; for recent developments see
\cite{wiering2012reinforcement,arulkumaran2017deep}.

A workhouse sampling algorithm for Bayesian computation is Monte Carlo Markov Chain \index{Monte Carlo!Markov chain} (MCMC)\index{MCMC} that builds a sequence of correlated samples from a target distribution; see~\cite{gamerman2006markov, meyn2012markov} for a general introduction. MCMC methods can  also be useful for non-convex optimization by constructing a target distribution from the  objective function. We refer to Section~\ref{sec:14} for more references and discussion on Monte Carlo methods. 

\begin{thebibliography}{392}
\providecommand{\natexlab}[1]{#1}
\providecommand{\url}[1]{\texttt{#1}}
\expandafter\ifx\csname urlstyle\endcsname\relax
  \providecommand{\doi}[1]{doi: #1}\else
  \providecommand{\doi}{doi: \begingroup \urlstyle{rm}\Url}\fi

\bibitem[Adrian et~al.(2024)Adrian, Sanz-Alonso, and Willett]{adrian2024data}
M.~Adrian, D.~Sanz-Alonso, and R.~Willett.
\newblock {Data assimilation with machine learning surrogate models: A case
  study with FourCastNet}.
\newblock \emph{arXiv preprint arXiv:2405.13180}, 2024.

\bibitem[Agapiou et~al.(2017{\natexlab{a}})Agapiou, Burger, Dashti, and
  Helin.]{agapiou2017sparsity}
S.~Agapiou, M.~Burger, M.~Dashti, and T.~Helin.
\newblock {Sparsity-promoting and edge-preserving maximum \textit{a posteriori}
  estimators in non-parametric Bayesian inverse problems}.
\newblock \emph{Inverse Problems}, 34\penalty0 (4):\penalty0 045002,
  2017{\natexlab{a}}.
\newblock \doi{10.1088/1361-6420/aaacac}.

\bibitem[Agapiou et~al.(2017{\natexlab{b}})Agapiou, Papaspiliopoulos,
  Sanz-Alonso, and Stuart]{agapiou2017importance}
S.~Agapiou, O.~Papaspiliopoulos, D.~Sanz-Alonso, and A.~M. Stuart.
\newblock Importance sampling: Intrinsic dimension and computational cost.
\newblock \emph{Statistical Science}, 32\penalty0 (3):\penalty0 405--431,
  2017{\natexlab{b}}.
\newblock \doi{10.1214/17-STS611}.

\bibitem[Agarwal et~al.(2024)Agarwal, Amrhein, and
  Grooms]{agarwal_cross-attractor_2024}
N.~Agarwal, D.~E. Amrhein, and I.~Grooms.
\newblock Cross-attractor transforms: {{Improving}} forecasts by learning
  optimal maps between dynamical systems and imperfect models.
\newblock \emph{{Earth and Space Science Open Archive}}, 2024.
\newblock \doi{10.22541/essoar.171770532.25438818/v1}.

\bibitem[Agrawal et~al.(2022)Agrawal, Kim, Sanz-Alonso, and
  Strang]{agrawal2022variational}
S.~Agrawal, H.~Kim, D.~Sanz-Alonso, and A.~Strang.
\newblock A variational inference approach to inverse problems with gamma
  hyperpriors.
\newblock \emph{SIAM/ASA Journal on Uncertainty Quantification}, 10\penalty0
  (4):\penalty0 1533--1559, 2022.
\newblock \doi{10.1137/21M146209X}.

\bibitem[{Al-Ghattas} and {Sanz-Alonso}(2024)]{al-ghattas_non-asymptotic_2024}
O.~{Al-Ghattas} and D.~{Sanz-Alonso}.
\newblock Non-asymptotic analysis of ensemble {{Kalman}} updates: Effective
  dimension and localization.
\newblock \emph{Information and Inference: A Journal of the IMA}, 13\penalty0
  (1):\penalty0 iaad043, 2024.
\newblock \doi{10.1093/imaiai/iaad043}.

\bibitem[Al-Ghattas and Sanz-Alonso(2024)]{al2024covariance}
O.~Al-Ghattas and D.~Sanz-Alonso.
\newblock Covariance operator estimation via adaptive thresholding.
\newblock \emph{arXiv preprint arXiv:2405.18562}, 2024.

\bibitem[Al-Ghattas et~al.(2023)Al-Ghattas, Chen, Sanz-Alonso, and
  Waniorek]{al2023covariance}
O.~Al-Ghattas, J.~Chen, D.~Sanz-Alonso, and N.~Waniorek.
\newblock {Covariance operator estimation: sparsity, lengthscale, and ensemble
  Kalman filters}.
\newblock \emph{arXiv preprint arXiv:2310.16933}, 2023.

\bibitem[Al-Jarrah et~al.(2023)Al-Jarrah, Jin, Hosseini, and
  Taghvaei]{al2023optimal}
M.~Al-Jarrah, N.~Jin, B.~Hosseini, and A.~Taghvaei.
\newblock Optimal transport-based nonlinear filtering in high-dimensional
  settings.
\newblock \emph{arXiv preprint arXiv:2310.13886}, 2023.

\bibitem[Albergo et~al.(2024)Albergo, Goldstein, Boffi, Ranganath, and
  Vanden-Eijnden]{albergostochastic}
M.~S. Albergo, M.~Goldstein, N.~M. Boffi, R.~Ranganath, and E.~Vanden-Eijnden.
\newblock Stochastic interpolants with data-dependent couplings.
\newblock In \emph{Forty-first International Conference on Machine Learning},
  2024.

\bibitem[Alexander and Giannakis(2020)]{alexander2020operator}
R.~Alexander and D.~Giannakis.
\newblock Operator-theoretic framework for forecasting nonlinear time series
  with kernel analog techniques.
\newblock \emph{Physica D: Nonlinear Phenomena}, 409:\penalty0 132520, 2020.
\newblock \doi{10.1016/j.physd.2020.132520}.

\bibitem[Ambrosio et~al.(2005)Ambrosio, Gigli, and
  Savar{\'e}]{ambrosio2005gradient}
L.~Ambrosio, N.~Gigli, and G.~Savar{\'e}.
\newblock \emph{Gradient Flows: In Metric Spaces and in the Space of
  Probability Measures}.
\newblock Springer Science \& Business Media, 2005.
\newblock \doi{10.1007/978-3-7643-8722-8}.

\bibitem[Amezcua and {van Leeuwen}(2018)]{amezcua_time-correlated_2018}
J.~Amezcua and P.~J. {van Leeuwen}.
\newblock Time-correlated model error in the (ensemble) {{Kalman}} smoother.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  144\penalty0 (717):\penalty0 2650--2665, 2018.
\newblock \doi{10.1002/qj.3378}.

\bibitem[Anderson(2009)]{anderson_spatially_2009}
J.~Anderson.
\newblock Spatially and temporally varying adaptive covariance inflation for
  ensemble filters.
\newblock \emph{Tellus A: Dynamic Meteorology and Oceanography}, 61\penalty0
  (1):\penalty0 72--83, 2009.
\newblock \doi{10.1111/j.1600-0870.2007.00361.x}.

\bibitem[Anderson(2001)]{anderson2001ensemble}
J.~L. Anderson.
\newblock {An ensemble adjustment Kalman filter for data assimilation}.
\newblock \emph{Monthly Weather Review}, 129\penalty0 (12):\penalty0
  2884--2903, 2001.
\newblock \doi{10.1175/1520-0493(2001)129<2884:AEAKFF>2.0.CO;2}.

\bibitem[Anderson(2010)]{anderson2010non}
J.~L. Anderson.
\newblock {A non-Gaussian ensemble filter update for data assimilation}.
\newblock \emph{Monthly Weather Review}, 138\penalty0 (11):\penalty0
  4186--4198, 2010.
\newblock \doi{10.1175/2010MWR3253.1}.

\bibitem[Andrieu and Roberts(2009)]{andrieu2009pseudo}
C.~Andrieu and G.~O. Roberts.
\newblock The pseudo-marginal approach for efficient {Monte} {Carlo}
  computations.
\newblock \emph{The Annals of Statistics}, 37\penalty0 (2):\penalty0 697--725,
  2009.
\newblock \doi{10.1214/07-AOS574}.

\bibitem[Andrieu et~al.(2010)Andrieu, Doucet, and
  Holenstein]{andrieu2010particle}
C.~Andrieu, A.~Doucet, and R.~Holenstein.
\newblock {Particle Markov chain Monte Carlo methods}.
\newblock \emph{Journal of the Royal Statistical Society: Series B (Statistical
  Methodology)}, 72\penalty0 (3):\penalty0 269--342, 2010.
\newblock \doi{10.1111/j.1467-9868.2009.00736.x}.

\bibitem[Archambeau et~al.(2007)Archambeau, Opper, Shen, Cornford, and
  Shawe-Taylor]{archambeau2007variational}
C.~Archambeau, M.~Opper, Y.~Shen, D.~Cornford, and J.~Shawe-Taylor.
\newblock Variational inference for diffusion processes.
\newblock \emph{Advances in Neural Information Processing Systems}, 20, 2007.

\bibitem[Arridge et~al.(2019)Arridge, Maass, {\"O}ktem, and
  Sch{\"o}nlieb]{arridge2019solving}
S.~Arridge, P.~Maass, O.~{\"O}ktem, and C.-B. Sch{\"o}nlieb.
\newblock Solving inverse problems using data-driven models.
\newblock \emph{Acta Numerica}, 28:\penalty0 1--174, 2019.
\newblock \doi{10.1017/S0962492919000059}.

\bibitem[Arulkumaran et~al.(2017)Arulkumaran, Deisenroth, Brundage, and
  Bharath]{arulkumaran2017deep}
K.~Arulkumaran, M.~P. Deisenroth, M.~Brundage, and A.~A. Bharath.
\newblock Deep reinforcement learning: A brief survey.
\newblock \emph{IEEE Signal Processing Magazine}, 34\penalty0 (6):\penalty0
  26--38, 2017.
\newblock \doi{10.1109/MSP.2017.2743240}.

\bibitem[Asch et~al.(2016)Asch, Bocquet, and Nodet]{asch2016data}
M.~Asch, M.~Bocquet, and M.~Nodet.
\newblock \emph{Data Assimilation: Methods, Algorithms, and Applications},
  volume~11.
\newblock SIAM, 2016.

\bibitem[Asim et~al.(2020)Asim, Daniels, Leong, Ahmed, and
  Hand]{asim2020invertible}
M.~Asim, M.~Daniels, O.~Leong, A.~Ahmed, and P.~Hand.
\newblock Invertible generative models for inverse problems: mitigating
  representation error and dataset bias.
\newblock In \emph{International Conference on Machine Learning}, pages
  399--409. PMLR, 2020.

\bibitem[Bach and Ghil(2023)]{bach_multi-model_2023}
E.~Bach and M.~Ghil.
\newblock {A multi-model ensemble Kalman filter for data assimilation and
  forecasting}.
\newblock \emph{Journal of Advances in Modeling Earth Systems}, 15\penalty0
  (1):\penalty0 e2022MS003123, 2023.
\newblock \doi{10.1029/2022MS003123}.

\bibitem[Bach et~al.(2021)Bach, Mote, Krishnamurthy, Sharma, Ghil, and
  Kalnay]{bach_ensemble_2021}
E.~Bach, S.~Mote, V.~Krishnamurthy, A.~S. Sharma, M.~Ghil, and E.~Kalnay.
\newblock Ensemble {{Oscillation Correction}} ({{EnOC}}): Leveraging
  oscillatory modes to improve forecasts of chaotic systems.
\newblock \emph{Journal of Climate}, 34\penalty0 (14):\penalty0 5673--5686,
  2021.
\newblock \doi{10.1175/JCLI-D-20-0624.1}.

\bibitem[Bach et~al.(2024)Bach, Krishnamurthy, Mote, Shukla, Sharma, Kalnay,
  and Ghil]{bach_improved_2024}
E.~Bach, V.~Krishnamurthy, S.~Mote, J.~Shukla, A.~S. Sharma, E.~Kalnay, and
  M.~Ghil.
\newblock Improved subseasonal prediction of {{South Asian}} monsoon rainfall
  using data-driven forecasts of oscillatory modes.
\newblock \emph{Proceedings of the National Academy of Sciences}, 121\penalty0
  (15):\penalty0 e2312573121, 2024.
\newblock \doi{10.1073/pnas.2312573121}.

\bibitem[Bain and Crisan(2008)]{bain2008fundamentals}
A.~Bain and D.~Crisan.
\newblock \emph{{Fundamentals of Stochastic Filtering}}, volume~60.
\newblock Springer Science \& Business Media, 2008.

\bibitem[Bal(2012)]{bal2012introduction}
G.~Bal.
\newblock \emph{{Introduction to Inverse Problems}}.
\newblock Unpublished, Department of Applied Physics and Applied Mathematics,
  Columbia University, New York, 2012.

\bibitem[Bao et~al.(2024)Bao, Zhang, and Zhang]{bao_score-based_2024}
F.~Bao, Z.~Zhang, and G.~Zhang.
\newblock A score-based filter for nonlinear data assimilation.
\newblock \emph{Journal of Computational Physics}, 514:\penalty0 113207, 2024.
\newblock \doi{10.1016/j.jcp.2024.113207}.

\bibitem[Baptista et~al.(2023)Baptista, Marzouk, and
  Zahm]{baptista2023representation}
R.~Baptista, Y.~Marzouk, and O.~Zahm.
\newblock On the representation and learning of monotone triangular transport
  maps.
\newblock \emph{Foundations of Computational Mathematics}, pages 1--46, 2023.
\newblock \doi{10.1007/s10208-023-09630-x}.

\bibitem[Baptista et~al.(2024{\natexlab{a}})Baptista, Hosseini, Kovachki,
  Marzouk, and Sagiv]{baptista2023approximation}
R.~Baptista, B.~Hosseini, N.~Kovachki, Y.~Marzouk, and A.~Sagiv.
\newblock An approximation theory framework for measure-transport sampling
  algorithms.
\newblock \emph{Mathematics of Computation}, 2024{\natexlab{a}}.

\bibitem[Baptista et~al.(2024{\natexlab{b}})Baptista, Hosseini, Kovachki, and
  Marzouk]{baptista2020conditional}
R.~Baptista, B.~Hosseini, N.~B. Kovachki, and Y.~M. Marzouk.
\newblock {Conditional sampling with monotone GANs: from generative models to
  likelihood-free inference}.
\newblock \emph{SIAM/ASA Journal on Uncertainty Quantification}, 12\penalty0
  (3):\penalty0 868--900, 2024{\natexlab{b}}.
\newblock \doi{10.1137/23M1581546}.

\bibitem[Basu(1977)]{basu1977nuissance}
D.~Basu.
\newblock On the elimination of nuisance parameters.
\newblock \emph{Journal of the American Statistical Association}, 72\penalty0
  (358):\penalty0 355--366, 1977.
\newblock \doi{10.2307/2286800}.

\bibitem[Batzolis et~al.(2021)Batzolis, Stanczuk, Sch{\"o}nlieb, and
  Etmann]{batzolis2021conditional}
G.~Batzolis, J.~Stanczuk, C.-B. Sch{\"o}nlieb, and C.~Etmann.
\newblock Conditional image generation with score-based diffusion models.
\newblock \emph{arXiv preprint arXiv:2111.13606}, 2021.

\bibitem[Benning and Burger(2018)]{benning2018modern}
M.~Benning and M.~Burger.
\newblock Modern regularization methods for inverse problems.
\newblock \emph{Acta Numerica}, 27:\penalty0 1--111, 2018.
\newblock \doi{10.1017/S0962492918000016}.

\bibitem[Berlinet and Thomas-Agnan(2011)]{berlinet2011reproducing}
A.~Berlinet and C.~Thomas-Agnan.
\newblock \emph{Reproducing Kernel Hilbert Spaces in Probability and
  Statistics}.
\newblock Springer Science \& Business Media, 2011.

\bibitem[Berry and Sauer(2013)]{berry_adaptive_2013}
T.~Berry and T.~Sauer.
\newblock Adaptive ensemble {{Kalman}} filtering of non-linear systems.
\newblock \emph{Tellus A: Dynamic Meteorology and Oceanography}, 65\penalty0
  (1):\penalty0 20331, 2013.
\newblock \doi{10.3402/tellusa.v65i0.20331}.

\bibitem[Bi et~al.(2023)Bi, Xie, Zhang, Chen, Gu, and Tian]{Bi2023}
K.~Bi, L.~Xie, H.~Zhang, X.~Chen, X.~Gu, and Q.~Tian.
\newblock {Accurate medium-range global weather forecasting with 3D neural
  networks}.
\newblock \emph{Nature}, 619\penalty0 (7970):\penalty0 533--538, 2023.
\newblock \doi{10.1038/s41586-023-06185-3}.

\bibitem[Bickel et~al.(2008)Bickel, Li, and Bengtsson]{bickel2008sharp}
P.~Bickel, B.~Li, and T.~Bengtsson.
\newblock Sharp failure rates for the bootstrap particle filter in high
  dimensions.
\newblock In \emph{Pushing the Limits of Contemporary Statistics: Contributions
  in Honor of Jayanta K. Ghosh}, pages 318--329. Institute of Mathematical
  Statistics, 2008.
\newblock \doi{10.1214/074921708000000228}.

\bibitem[Bickel and Levina(2008)]{bickel2008regularized}
P.~J. Bickel and E.~Levina.
\newblock Regularized estimation of large covariance matrices.
\newblock \emph{The Annals of Statistics}, 36\penalty0 (1):\penalty0 199, 2008.
\newblock \doi{10.1214/009053607000000758}.

\bibitem[Bigoni et~al.(2020)Bigoni, Chen, Garcia~Trillos, Marzouk, and
  Sanz-Alonso]{bigoni2020data}
D.~Bigoni, Y.~Chen, N.~Garcia~Trillos, Y.~Marzouk, and D.~Sanz-Alonso.
\newblock {Data-driven forward discretizations for Bayesian inversion}.
\newblock \emph{Inverse Problems}, 36\penalty0 (10):\penalty0 105008, 2020.
\newblock \doi{10.1088/1361-6420/abb2fa}.

\bibitem[Bishop(2006)]{bishop}
C.~M. Bishop.
\newblock \emph{{Pattern Recognition and Machine Learning}}.
\newblock Springer, 2006.

\bibitem[Block et~al.(2020)Block, Mroueh, and Rakhlin]{block2020generative}
A.~Block, Y.~Mroueh, and A.~Rakhlin.
\newblock {Generative modeling with denoising auto-encoders and Langevin
  sampling}.
\newblock \emph{arXiv preprint arXiv:2002.00107}, 2020.

\bibitem[Bocquet(2023)]{bocquet_surrogate_2023}
M.~Bocquet.
\newblock Surrogate modeling for the climate sciences dynamics with machine
  learning and data assimilation.
\newblock \emph{Frontiers in Applied Mathematics and Statistics}, 9, 2023.
\newblock \doi{10.3389/fams.2023.1133226}.

\bibitem[Bocquet et~al.(2020)Bocquet, Brajard, Carrassi, and
  Bertino]{bocquet2020bayesian}
M.~Bocquet, J.~Brajard, A.~Carrassi, and L.~Bertino.
\newblock Bayesian inference of chaotic dynamics by merging data assimilation,
  machine learning and expectation-maximization.
\newblock \emph{Foundations of Data Science}, 2\penalty0 (1):\penalty0 55--80,
  2020.
\newblock \doi{10.3934/fods.2020004}.

\bibitem[Bocquet et~al.(2024)Bocquet, Farchi, Finn, Durand, Cheng, Chen,
  Pasmans, and Carrassi]{bocquet_accurate_2024}
M.~Bocquet, A.~Farchi, T.~S. Finn, C.~Durand, S.~Cheng, Y.~Chen, I.~Pasmans,
  and A.~Carrassi.
\newblock Accurate deep learning-based filtering for chaotic dynamics by
  identifying instabilities without an ensemble.
\newblock \emph{Chaos: An Interdisciplinary Journal of Nonlinear Science},
  34\penalty0 (9):\penalty0 091104, 2024.
\newblock \doi{10.1063/5.0230837}.

\bibitem[Bolton and Zanna(2019)]{bolton2019applications}
T.~Bolton and L.~Zanna.
\newblock Applications of deep learning to ocean data inference and subgrid
  parameterization.
\newblock \emph{Journal of Advances in Modeling Earth Systems}, 11\penalty0
  (1):\penalty0 376--399, 2019.
\newblock \doi{10.1029/2018MS001472}.

\bibitem[Bonavita(2024)]{bonavita2023limitations}
M.~Bonavita.
\newblock On some limitations of current machine learning weather prediction
  models.
\newblock \emph{Geophysical Research Letters}, 51\penalty0 (12):\penalty0
  e2023GL107377, 2024.
\newblock \doi{10.1029/2023GL107377}.

\bibitem[Bonavita and Laloyaux(2020)]{bonavita2020machine}
M.~Bonavita and P.~Laloyaux.
\newblock Machine learning for model error inference and correction.
\newblock \emph{Journal of Advances in Modeling Earth Systems}, 12\penalty0
  (12):\penalty0 e2020MS002232, 2020.
\newblock \doi{10.1029/2020MS002232}.

\bibitem[Boudier et~al.(2023)Boudier, Fillion, Gratton, G{\"u}rol, and
  Zhang]{boudier2023data}
P.~Boudier, A.~Fillion, S.~Gratton, S.~G{\"u}rol, and S.~Zhang.
\newblock Data assimilation networks.
\newblock \emph{Journal of Advances in Modeling Earth Systems}, 15\penalty0
  (4):\penalty0 e2022MS003353, 2023.
\newblock \doi{10.1029/2022MS003353}.

\bibitem[Boyd and Vandenberghe(2004)]{boyd_convex_2004}
S.~Boyd and L.~Vandenberghe.
\newblock \emph{Convex Optimization}.
\newblock {Cambridge University Press}, {Cambridge}, 2004.
\newblock ISBN 978-0-521-83378-3.
\newblock \doi{10.1017/CBO9780511804441}.

\bibitem[Brajard et~al.(2020)Brajard, Carrassi, Bocquet, and
  Bertino]{brajard2020combining}
J.~Brajard, A.~Carrassi, M.~Bocquet, and L.~Bertino.
\newblock Combining data assimilation and machine learning to emulate a
  dynamical model from sparse and noisy observations: A case study with the
  {Lorenz} 96 model.
\newblock \emph{Journal of Computational Science}, 44:\penalty0 101171, 2020.
\newblock \doi{10.1016/j.jocs.2020.101171}.

\bibitem[Br{\"o}cker and Szendro(2012)]{brocker_sensitivity_2012}
J.~Br{\"o}cker and I.~G. Szendro.
\newblock Sensitivity and out-of-sample error in continuous time data
  assimilation.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  138\penalty0 (664):\penalty0 785--801, 2012.
\newblock \doi{10.1002/qj.940}.

\bibitem[Br{\"o}cker et~al.(2009)Br{\"o}cker, Engster, and
  Parlitz]{brocker_probabilistic_2009}
J.~Br{\"o}cker, D.~Engster, and U.~Parlitz.
\newblock Probabilistic evaluation of time series models: {{A}} comparison of
  several approaches.
\newblock \emph{Chaos: An Interdisciplinary Journal of Nonlinear Science},
  19\penalty0 (4):\penalty0 043130, 2009.
\newblock \doi{10.1063/1.3271343}.

\bibitem[Brooks et~al.(2011)Brooks, Gelman, Jones, and
  Meng]{brooks2011handbook}
S.~Brooks, A.~Gelman, G.~Jones, and X.-L. Meng.
\newblock \emph{Handbook of {M}arkov {C}hain {M}onte {C}arlo}.
\newblock CRC Press, 2011.

\bibitem[Brown(1974)]{brown_admissible_1974}
T.~A. Brown.
\newblock Admissible scoring systems for continuous distributions.
\newblock The {{Rand Paper Series}} P-5235, {RAND Corporation}, {Santa Monica,
  CA}, 1974.

\bibitem[Brunton and Kutz(2019)]{brunton2019data}
S.~L. Brunton and J.~N. Kutz.
\newblock \emph{Data-driven Science and Engineering: Machine Learning,
  Dynamical Systems, and Control}.
\newblock Cambridge University Press, 2019.

\bibitem[Calvello et~al.(2024)Calvello, Reich, and Stuart]{calvello22}
E.~Calvello, S.~Reich, and A.~M. Stuart.
\newblock Ensemble {Kalman} methods: A mean field perspective.
\newblock \emph{arXiv preprint arXiv:2209.11371}, 2024.

\bibitem[Calvetti et~al.(2019)Calvetti, Somersalo, and
  Strang]{calvetti2019hierachical}
D.~Calvetti, E.~Somersalo, and A.~Strang.
\newblock Hierachical {Bayesian} models and sparsity: $l^2$-magic.
\newblock \emph{Inverse Problems}, 35\penalty0 (3):\penalty0 035003, 2019.
\newblock \doi{10.1088/1361-6420/aaf5ab}.

\bibitem[Carrassi and Vannitsem(2016)]{carrassi_deterministic_2016}
A.~Carrassi and S.~Vannitsem.
\newblock Deterministic treatment of model error in geophysical data
  assimilation.
\newblock In F.~Ancona, P.~Cannarsa, C.~Jones, and A.~Portaluri, editors,
  \emph{Mathematical {{Paradigms}} of {{Climate Science}}}, pages 175--213.
  Springer International Publishing, Cham, 2016.
\newblock ISBN 978-3-319-39092-5.
\newblock \doi{10.1007/978-3-319-39092-5_9}.

\bibitem[Carrassi et~al.(2017)Carrassi, Bocquet, Hannart, and
  Ghil]{carrassi2017estimating}
A.~Carrassi, M.~Bocquet, A.~Hannart, and M.~Ghil.
\newblock Estimating model evidence using data assimilation.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  143\penalty0 (703):\penalty0 866--880, 2017.
\newblock \doi{10.1002/qj.2972}.

\bibitem[Carrassi et~al.(2018)Carrassi, Bocquet, Bertino, and
  Evensen]{carrassi2018data}
A.~Carrassi, M.~Bocquet, L.~Bertino, and G.~Evensen.
\newblock Data assimilation in the geosciences: An overview of methods, issues,
  and perspectives.
\newblock \emph{{Wiley Interdisciplinary Reviews: Climate Change}}, 9\penalty0
  (5), 2018.
\newblock \doi{10.1002/wcc.535}.

\bibitem[Carrassi et~al.(2022)Carrassi, Bocquet, Demaeyer, Grudzien, Raanes,
  and Vannitsem]{carrassi_data_2022}
A.~Carrassi, M.~Bocquet, J.~Demaeyer, C.~Grudzien, P.~Raanes, and S.~Vannitsem.
\newblock Data {{assimilation}} for {{chaotic dynamics}}.
\newblock In S.~K. Park and L.~Xu, editors, \emph{Data {{Assimilation}} for
  {{Atmospheric}}, {{Oceanic}} and {{Hydrologic Applications}} ({{Vol}}.
  {{IV}})}, pages 1--42. {Springer International Publishing}, {Cham}, 2022.
\newblock ISBN 978-3-030-77722-7.
\newblock \doi{10.1007/978-3-030-77722-7_1}.

\bibitem[Carrillo et~al.(2022)Carrillo, Hoffmann, Stuart, and
  Vaes]{carrillo2022ensemble}
J.~Carrillo, F.~Hoffmann, A.~Stuart, and U.~Vaes.
\newblock {The ensemble Kalman filter in the near-Gaussian setting}.
\newblock \emph{arXiv preprint arXiv:2212.13239}, 2022.

\bibitem[Chada et~al.(2020)Chada, Stuart, and Tong]{chada2019tikhonov}
N.~K. Chada, A.~M. Stuart, and X.~T. Tong.
\newblock {Tikhonov regularization within ensemble Kalman inversion}.
\newblock \emph{SIAM Journal on Numerical Analysis}, 58\penalty0 (2):\penalty0
  1263--1294, 2020.

\bibitem[Chattopadhyay et~al.(2022)Chattopadhyay, Mustafa, Hassanzadeh, Bach,
  and Kashinath]{chattopadhyay2022towards}
A.~Chattopadhyay, M.~Mustafa, P.~Hassanzadeh, E.~Bach, and K.~Kashinath.
\newblock {Towards physics-inspired data-driven weather forecasting:
  integrating data assimilation with a deep spatial-transformer-based U-NET in
  a case study with ERA5}.
\newblock \emph{Geoscientific Model Development}, 15\penalty0 (5):\penalty0
  2221--2237, 2022.

\bibitem[Chattopadhyay et~al.(2023)Chattopadhyay, Nabizadeh, Bach, and
  Hassanzadeh]{chattopadhyay_deep_2023}
A.~Chattopadhyay, E.~Nabizadeh, E.~Bach, and P.~Hassanzadeh.
\newblock Deep learning-enhanced ensemble-based data assimilation for
  high-dimensional nonlinear dynamical systems.
\newblock \emph{Journal of Computational Physics}, 477:\penalty0 111918, 2023.
\newblock \doi{10.1016/j.jcp.2023.111918}.

\bibitem[Chemseddine et~al.(2024)Chemseddine, Hagemann, Wald, and
  Steidl]{chemseddine2024conditional}
J.~Chemseddine, P.~Hagemann, C.~Wald, and G.~Steidl.
\newblock Conditional wasserstein distances with applications in bayesian ot
  flow matching.
\newblock \emph{arXiv preprint arXiv:2403.18705}, 2024.

\bibitem[Chen and Wu(2024)]{chen_neural_2024}
C.~Chen and J.-L. Wu.
\newblock Neural dynamical operator: Continuous spatial-temporal model with
  gradient-based and derivative-free optimization methods.
\newblock \emph{Journal of Computational Physics}, page 113480, 2024.
\newblock \doi{10.1016/j.jcp.2024.113480}.

\bibitem[Chen et~al.(2023{\natexlab{a}})Chen, Han, Gong, Bai, Ling, Luo, Chen,
  Ma, Zhang, Su, et~al.]{chen2023fengwu}
K.~Chen, T.~Han, J.~Gong, L.~Bai, F.~Ling, J.-J. Luo, X.~Chen, L.~Ma, T.~Zhang,
  R.~Su, et~al.
\newblock {Fengwu: Pushing the skillful global medium-range weather forecast
  beyond 10 days lead}.
\newblock \emph{arXiv preprint arXiv:2304.02948}, 2023{\natexlab{a}}.

\bibitem[Chen et~al.(2023{\natexlab{b}})Chen, Zhong, Zhang, Cheng, Xu, Qi, and
  Li]{chen2023fuxi}
L.~Chen, X.~Zhong, F.~Zhang, Y.~Cheng, Y.~Xu, Y.~Qi, and H.~Li.
\newblock {FuXi: A cascade machine learning forecasting system for 15-day
  global weather forecast}.
\newblock \emph{npj Climate and Atmospheric Science}, 6\penalty0 (1):\penalty0
  190, 2023{\natexlab{b}}.

\bibitem[Chen(2023)]{chen_stochastic_2023}
N.~Chen.
\newblock \emph{Stochastic Methods for Modeling and Predicting Complex
  Dynamical Systems: Uncertainty Quantification, State Estimation, and
  Reduced-Order Models}.
\newblock Synthesis {{Lectures}} on {{Mathematics}} \& {{Statistics}}.
  {Springer International Publishing}, {Cham}, 2023.
\newblock ISBN 978-3-031-22248-1 978-3-031-22249-8.
\newblock \doi{10.1007/978-3-031-22249-8}.

\bibitem[Chen and Li(2021)]{chen_bamcafe_2021}
N.~Chen and Y.~Li.
\newblock {{BAMCAFE}}: {{A Bayesian}} machine learning advanced forecast
  ensemble method for complex turbulent systems with partial observations.
\newblock \emph{Chaos: An Interdisciplinary Journal of Nonlinear Science},
  31\penalty0 (11):\penalty0 113114, 2021.
\newblock \doi{10.1063/5.0062028}.

\bibitem[Chen et~al.(2018)Chen, Rubanova, Bettencourt, and
  Duvenaud]{chen2018neural}
R.~T. Chen, Y.~Rubanova, J.~Bettencourt, and D.~K. Duvenaud.
\newblock Neural ordinary differential equations.
\newblock \emph{Advances in Neural Information Processing Systems}, 31, 2018.

\bibitem[Chen et~al.(2022{\natexlab{a}})Chen, Penny, Whitaker, Frolov, Pincus,
  and Tulich]{chen_correcting_2022}
T.-C. Chen, S.~G. Penny, J.~S. Whitaker, S.~Frolov, R.~Pincus, and S.~Tulich.
\newblock Correcting systematic and state-dependent errors in the {{NOAA
  FV3-GFS}} using neural networks.
\newblock \emph{Journal of Advances in Modeling Earth Systems}, 14\penalty0
  (11):\penalty0 e2022MS003309, 2022{\natexlab{a}}.
\newblock \doi{10.1029/2022MS003309}.

\bibitem[Chen et~al.(2021)Chen, Hosseini, Owhadi, and Stuart]{chen2021solving}
Y.~Chen, B.~Hosseini, H.~Owhadi, and A.~M. Stuart.
\newblock {Solving and learning nonlinear PDEs with Gaussian processes}.
\newblock \emph{Journal of Computational Physics}, 447:\penalty0 110668, 2021.

\bibitem[Chen et~al.(2022{\natexlab{b}})Chen, Sanz-Alonso, and
  Willett]{chen2021auto}
Y.~Chen, D.~Sanz-Alonso, and R.~Willett.
\newblock {Auto-differentiable ensemble Kalman filters}.
\newblock \emph{SIAM Journal on Mathematics of Data Science}, 4\penalty0
  (2):\penalty0 801--833, 2022{\natexlab{b}}.

\bibitem[Chen et~al.(2023{\natexlab{c}})Chen, Huang, Huang, Reich, and
  Stuart]{chen2023gradient}
Y.~Chen, D.~Z. Huang, J.~Huang, S.~Reich, and A.~M. Stuart.
\newblock {Gradient flows for sampling: Mean-field models, Gaussian
  approximations and affine invariance}.
\newblock \emph{arXiv preprint arXiv:2302.11024}, 2023{\natexlab{c}}.

\bibitem[Chen et~al.(2023{\natexlab{d}})Chen, Sanz-Alonso, and
  Willett]{chen2023reduced}
Y.~Chen, D.~Sanz-Alonso, and R.~Willett.
\newblock {Reduced-order autodifferentiable ensemble Kalman filters}.
\newblock \emph{Inverse Problems}, 39\penalty0 (12):\penalty0 124001,
  2023{\natexlab{d}}.

\bibitem[Cheng et~al.(2021)Cheng, Argaud, Iooss, Pon{\c c}ot, and
  Lucor]{cheng_graph_2021}
S.~Cheng, J.-P. Argaud, B.~Iooss, A.~Pon{\c c}ot, and D.~Lucor.
\newblock A graph clustering approach to localization for adaptive covariance
  tuning in data assimilation based on state-observation mapping.
\newblock \emph{Mathematical Geosciences}, 53\penalty0 (8):\penalty0
  1751--1780, 2021.
\newblock \doi{10.1007/s11004-021-09951-z}.

\bibitem[Cheng et~al.(2023)Cheng, {Quilodr{\'a}n-Casas}, Ouala, Farchi, Liu,
  Tandeo, Fablet, Lucor, Iooss, Brajard, Xiao, Janjic, Ding, Guo, Carrassi,
  Bocquet, and Arcucci]{cheng_machine_2023}
S.~Cheng, C.~{Quilodr{\'a}n-Casas}, S.~Ouala, A.~Farchi, C.~Liu, P.~Tandeo,
  R.~Fablet, D.~Lucor, B.~Iooss, J.~Brajard, D.~Xiao, T.~Janjic, W.~Ding,
  Y.~Guo, A.~Carrassi, M.~Bocquet, and R.~Arcucci.
\newblock Machine learning with data assimilation and uncertainty
  quantification for dynamical systems: a review.
\newblock \emph{IEEE/CAA Journal of Automatica Sinica}, 10\penalty0
  (6):\penalty0 1361--1387, 2023.
\newblock \doi{10.1109/JAS.2023.123537}.

\bibitem[Chipilski(2023)]{chipilski2023exact}
H.~G. Chipilski.
\newblock Exact nonlinear state estimation.
\newblock \emph{arXiv preprint arXiv:2310.10976}, 2023.

\bibitem[Cleary et~al.(2021)Cleary, Garbuno-Inigo, Lan, Schneider, and
  Stuart]{cleary2021calibrate}
E.~Cleary, A.~Garbuno-Inigo, S.~Lan, T.~Schneider, and A.~M. Stuart.
\newblock Calibrate, emulate, sample.
\newblock \emph{Journal of Computational Physics}, 424:\penalty0 109716, 2021.

\bibitem[Cocucci et~al.(2021)Cocucci, Pulido, Lucini, and
  Tandeo]{cocucci2021model}
T.~J. Cocucci, M.~Pulido, M.~Lucini, and P.~Tandeo.
\newblock {Model error covariance estimation in particle and ensemble Kalman
  filters using an online expectation--maximization algorithm}.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  147\penalty0 (734):\penalty0 526--543, 2021.

\bibitem[Cotter et~al.(2012)Cotter, Dashti, and Stuart]{cotter2012variational}
S.~Cotter, M.~Dashti, and A.~Stuart.
\newblock Variational data assimilation using targetted random walks.
\newblock \emph{International Journal for Numerical Methods in Fluids},
  68\penalty0 (4):\penalty0 403--421, 2012.

\bibitem[Cranmer et~al.(2020)Cranmer, Brehmer, and Louppe]{cranmer2020frontier}
K.~Cranmer, J.~Brehmer, and G.~Louppe.
\newblock The frontier of simulation-based inference.
\newblock \emph{Proceedings of the National Academy of Sciences}, 117\penalty0
  (48):\penalty0 30055--30062, 2020.

\bibitem[Craven and Wahba(1978)]{craven1978smoothing}
P.~Craven and G.~Wahba.
\newblock Smoothing noisy data with spline functions.
\newblock \emph{Numerische Mathematik}, 31\penalty0 (4):\penalty0 377--403,
  1978.

\bibitem[Crisan and Rozovskii(2011)]{crisan2011oxford}
D.~Crisan and B.~Rozovskii.
\newblock \emph{{The Oxford Handbook of Nonlinear Filtering}}.
\newblock {Oxford University Press}, 2011.

\bibitem[Croci et~al.(2023)Croci, Willcox, and Wright]{croci_multi-output_2023}
M.~Croci, K.~E. Willcox, and S.~J. Wright.
\newblock Multi-output multilevel best linear unbiased estimators via
  semidefinite programming.
\newblock \emph{Computer Methods in Applied Mechanics and Engineering},
  413:\penalty0 116130, 2023.
\newblock \doi{10.1016/j.cma.2023.116130}.

\bibitem[Csato et~al.(2002)Csato, Cornford, and Opper]{csato2002data}
L.~Csato, D.~Cornford, and M.~Opper.
\newblock {Data assimilation with sequential Gaussian processes}.
\newblock \emph{Uncertainty in Geometric Computations}, pages 29--39, 2002.

\bibitem[Cybenko(1989)]{cybenko1989approximation}
G.~Cybenko.
\newblock Approximation by superpositions of a sigmoidal function.
\newblock \emph{Mathematics of Control, Signals and Systems}, 2\penalty0
  (4):\penalty0 303--314, 1989.

\bibitem[Danforth et~al.(2007)Danforth, Kalnay, and
  Miyoshi]{danforth_estimating_2007}
C.~M. Danforth, E.~Kalnay, and T.~Miyoshi.
\newblock Estimating and correcting global weather model error.
\newblock \emph{Monthly Weather Review}, 135\penalty0 (2):\penalty0 281--299,
  2007.
\newblock \doi{10.1175/MWR3289.1}.

\bibitem[Dashti and Stuart(2017)]{dashti2013bayesian}
M.~Dashti and A.~M. Stuart.
\newblock Bayesian approach to inverse problems.
\newblock \emph{Handbook of Uncertainty Quantification}, pages 311--428, 2017.

\bibitem[Dashti et~al.(2013)Dashti, Law, Stuart, and Voss]{dashti2013map}
M.~Dashti, K.~J.~H. Law, A.~M. Stuart, and J.~Voss.
\newblock {MAP estimators and their consistency in Bayesian nonparametric
  inverse problems}.
\newblock \emph{Inverse Problems}, 29\penalty0 (9):\penalty0 095017, 2013.

\bibitem[Dean et~al.(2020)Dean, Mania, Matni, Recht, and Tu]{dean2020sample}
S.~Dean, H.~Mania, N.~Matni, B.~Recht, and S.~Tu.
\newblock On the sample complexity of the linear quadratic regulator.
\newblock \emph{Foundations of Computational Mathematics}, 20\penalty0
  (4):\penalty0 633--679, 2020.

\bibitem[Dee and Da~Silva(1998)]{dee_data_1998}
D.~P. Dee and A.~M. Da~Silva.
\newblock Data assimilation in the presence of forecast bias.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  124\penalty0 (545):\penalty0 269--295, 1998.
\newblock \doi{10.1002/qj.49712454512}.

\bibitem[Del~Moral(2004)]{del2004feynman}
P.~Del~Moral.
\newblock \emph{{Feynman-Kac Formulae: Genealogical and Interacting Particle
  Systems with Applications}}.
\newblock Springer Science \& Business Media, 2004.

\bibitem[Del~Moral et~al.(2006)Del~Moral, Doucet, and Jasra]{del2006sequential}
P.~Del~Moral, A.~Doucet, and A.~Jasra.
\newblock {Sequential Monte Carlo samplers}.
\newblock \emph{Journal of the Royal Statistical Society: Series B (Statistical
  Methodology)}, 68\penalty0 (3):\penalty0 411--436, 2006.

\bibitem[DelSole and Yang(2010)]{delsole2010state}
T.~DelSole and X.~Yang.
\newblock State and parameter estimation in stochastic dynamical models.
\newblock \emph{Physica D: Nonlinear Phenomena}, 239\penalty0 (18):\penalty0
  1781--1788, 2010.

\bibitem[Dempster et~al.(1977)Dempster, Laird, and Rubin]{dempster1977maximum}
A.~P. Dempster, N.~M. Laird, and D.~B. Rubin.
\newblock {Maximum likelihood from incomplete data via the EM algorithm}.
\newblock \emph{Journal of the Royal Statistical Society: Series B
  (Methodological)}, 39\penalty0 (1):\penalty0 1--22, 1977.

\bibitem[Destouches et~al.(2023)Destouches, Mycek, and
  G{\"u}rol]{destouches_multivariate_2023}
M.~Destouches, P.~Mycek, and S.~G{\"u}rol.
\newblock {Multivariate extensions of the Multilevel Best Linear Unbiased
  Estimator for ensemble-variational data assimilation}.
\newblock \emph{arXiv preprint arXiv:2306.07017}, 2023.

\bibitem[DeVore et~al.(2021)DeVore, Hanin, and Petrova]{devore2021neural}
R.~DeVore, B.~Hanin, and G.~Petrova.
\newblock Neural network approximation.
\newblock \emph{Acta Numerica}, 30:\penalty0 327--444, 2021.

\bibitem[Doucet et~al.(2000)Doucet, Godsill, and Andrieu]{doucet2000sequential}
A.~Doucet, S.~Godsill, and C.~Andrieu.
\newblock {On sequential Monte Carlo sampling methods for Bayesian filtering}.
\newblock \emph{Statistics and Computing}, 10\penalty0 (3):\penalty0 197--208,
  2000.

\bibitem[Doucet et~al.(2001)Doucet, Freitas, and
  Gordon]{doucet2001introduction}
A.~Doucet, N.~d. Freitas, and N.~Gordon.
\newblock {An introduction to sequential Monte Carlo methods}.
\newblock In \emph{Sequential Monte Carlo Methods in Practice}, pages 3--14.
  Springer, 2001.

\bibitem[Dreano et~al.(2017)Dreano, Tandeo, Pulido, Ait-El-Fquih, Chonavel, and
  Hoteit]{dreano2017estimating}
D.~Dreano, P.~Tandeo, M.~Pulido, B.~Ait-El-Fquih, T.~Chonavel, and I.~Hoteit.
\newblock {Estimating model-error covariances in nonlinear state-space models
  using Kalman smoothing and the expectation--maximization algorithm}.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  143\penalty0 (705):\penalty0 1877--1885, 2017.

\bibitem[Drovandi et~al.(2021)Drovandi, Everitt, Golightly, Prangle,
  et~al.]{drovandi2021ensemble}
C.~Drovandi, R.~G. Everitt, A.~Golightly, D.~Prangle, et~al.
\newblock {Ensemble MCMC: accelerating pseudo-marginal MCMC for state space
  models using the ensemble Kalman filter}.
\newblock \emph{Bayesian Analysis}, 2021.

\bibitem[Du et~al.(2023)Du, Balim, Oymak, and Ozay]{du_can_2023}
Z.~Du, H.~Balim, S.~Oymak, and N.~Ozay.
\newblock Can transformers learn optimal filtering for unknown systems?
\newblock \emph{IEEE Control Systems Letters}, 7:\penalty0 3525--3530, 2023.
\newblock \doi{10.1109/LCSYS.2023.3335318}.

\bibitem[Dunbar et~al.(2021)Dunbar, Garbuno-Inigo, Schneider, and
  Stuart]{dunbar2021calibration}
O.~R. Dunbar, A.~Garbuno-Inigo, T.~Schneider, and A.~M. Stuart.
\newblock {Calibration and uncertainty quantification of convective parameters
  in an idealized GCM}.
\newblock \emph{Journal of Advances in Modeling Earth Systems}, 13\penalty0
  (9):\penalty0 e2020MS002454, 2021.

\bibitem[Dunlop et~al.(2020)Dunlop, Slep{\v{c}}ev, Stuart, and
  Thorpe]{dunlop2020large}
M.~M. Dunlop, D.~Slep{\v{c}}ev, A.~M. Stuart, and M.~Thorpe.
\newblock Large data and zero noise limits of graph-based semi-supervised
  learning algorithms.
\newblock \emph{Applied and Computational Harmonic Analysis}, 49\penalty0
  (2):\penalty0 655--697, 2020.

\bibitem[E(2017)]{weinan2017proposal}
W.~E.
\newblock A proposal on machine learning via dynamical systems.
\newblock \emph{Communications in Mathematics and Statistics}, 1\penalty0
  (5):\penalty0 1--11, 2017.

\bibitem[El~Moselhy and Marzouk(2012)]{el2012bayesian}
T.~A. El~Moselhy and Y.~M. Marzouk.
\newblock Bayesian inference with optimal maps.
\newblock \emph{Journal of Computational Physics}, 231\penalty0 (23):\penalty0
  7815--7850, 2012.

\bibitem[England et~al.(1996)England, Hanke, and
  Neubauer]{engl1996regularization}
H.~England, M.~Hanke, and A.~Neubauer.
\newblock \emph{{Regularization of Inverse Problems}}.
\newblock {Springer Science and Business Media}, 1996.

\bibitem[Evensen(1995)]{evensen1994sequential}
G.~Evensen.
\newblock {Sequential data assimilation with a nonlinear quasi-geostrophic
  model using Monte Carlo methods to forecast error statistics}.
\newblock \emph{{Journal of Geophysical Research: Oceans}}, 99\penalty0
  (c5):\penalty0 10143--10162, 1995.

\bibitem[Evensen et~al.(2022)Evensen, Vossepoel, and van
  Leeuwen]{evensen2022data}
G.~Evensen, F.~C. Vossepoel, and P.~J. van Leeuwen.
\newblock \emph{Data Assimilation Fundamentals: A Unified Formulation of the
  State and Parameter Estimation Problem}.
\newblock Springer, 2022.

\bibitem[Fakoor et~al.(2023)Fakoor, Kim, Mueller, Smola, and
  Tibshirani]{fakoor2023flexible}
R.~Fakoor, T.~Kim, J.~Mueller, A.~J. Smola, and R.~J. Tibshirani.
\newblock Flexible model aggregation for quantile regression.
\newblock \emph{Journal of Machine Learning Research}, 24\penalty0
  (162):\penalty0 1--45, 2023.

\bibitem[Farchi et~al.(2021)Farchi, Laloyaux, Bonavita, and
  Bocquet]{farchi2021using}
A.~Farchi, P.~Laloyaux, M.~Bonavita, and M.~Bocquet.
\newblock Using machine learning to correct model error in data assimilation
  and forecast applications.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  147\penalty0 (739):\penalty0 3067--3084, 2021.

\bibitem[Farmer and Sidorowich(1988)]{farmer_exploiting_1988}
J.~D. Farmer and J.~J. Sidorowich.
\newblock Exploiting chaos to predict the future and reduce noise.
\newblock In \emph{Evolution, {{Learning}} and {{Cognition}}}, pages 277--330.
  World Scientific, Singapore, 1988.
\newblock ISBN 978-9971-5-0529-5.
\newblock \doi{10.1142/9789814434102_0011}.

\bibitem[Ferro(2017)]{ferro_measuring_2017}
C.~A.~T. Ferro.
\newblock Measuring forecast performance in the presence of observation error.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  143\penalty0 (708):\penalty0 2665--2676, 2017.
\newblock \doi{10.1002/qj.3115}.

\bibitem[Fiechter(1997)]{fiechter1997pac}
C.-N. Fiechter.
\newblock {PAC adaptive control of linear systems}.
\newblock In \emph{Proceedings of the Tenth Annual Conference on Computational
  Learning Theory}, pages 72--80, 1997.

\bibitem[Filoche et~al.(2023)Filoche, Brajard, Charantonis, and
  B{\'e}r{\'e}ziat]{filoche2023learning}
A.~Filoche, J.~Brajard, A.~Charantonis, and D.~B{\'e}r{\'e}ziat.
\newblock {Learning 4DVAR inversion directly from observations}.
\newblock In \emph{International Conference on Computational Science}, pages
  414--421. Springer, 2023.

\bibitem[Fisher and Andersson(2001)]{fisher2001developments}
M.~Fisher and E.~Andersson.
\newblock Developments in {4D-Var} and {Kalman} filtering.
\newblock \emph{ECMWF Technical Memoranda}, \penalty0 (347):\penalty0 36, 2001.
\newblock \doi{10.21957/5ghofnp6c}.

\bibitem[Fraccaro et~al.(2017)Fraccaro, Kamronn, Paquet, and
  Winther]{fraccaro2017disentangled}
M.~Fraccaro, S.~Kamronn, U.~Paquet, and O.~Winther.
\newblock A disentangled recognition and nonlinear dynamics model for
  unsupervised learning.
\newblock \emph{Advances in neural information processing systems}, 30, 2017.

\bibitem[Fricker et~al.(2013)Fricker, Ferro, and
  Stephenson]{fricker_three_2013}
T.~E. Fricker, C.~A.~T. Ferro, and D.~B. Stephenson.
\newblock Three recommendations for evaluating climate predictions.
\newblock \emph{Meteorological Applications}, 20\penalty0 (2):\penalty0
  246--255, 2013.
\newblock \doi{10.1002/met.1409}.

\bibitem[Furrer and Bengtsson(2007)]{furrer2007estimation}
R.~Furrer and T.~Bengtsson.
\newblock {Estimation of high-dimensional prior and posterior covariance
  matrices in Kalman filter variants}.
\newblock \emph{Journal of Multivariate Analysis}, 98\penalty0 (2):\penalty0
  227--255, 2007.

\bibitem[Gabri{\'e} et~al.(2021)Gabri{\'e}, Rotskoff, and
  Vanden-Eijnden]{gabrie2021efficient}
M.~Gabri{\'e}, G.~M. Rotskoff, and E.~Vanden-Eijnden.
\newblock {Efficient Bayesian sampling using normalizing flows to assist Markov
  chain Monte Carlo methods}.
\newblock In \emph{ICML Workshop on Invertible Neural Networks, Normalizing
  Flows, and Explicit Likelihood Models}, 2021.

\bibitem[Gabri{\'e} et~al.(2022)Gabri{\'e}, Rotskoff, and
  Vanden-Eijnden]{gabrie2022adaptive}
M.~Gabri{\'e}, G.~M. Rotskoff, and E.~Vanden-Eijnden.
\newblock Adaptive monte carlo augmented with normalizing flows.
\newblock \emph{Proceedings of the National Academy of Sciences}, 119\penalty0
  (10):\penalty0 e2109420119, 2022.

\bibitem[Galy-Fajou et~al.(2021)Galy-Fajou, Perrone, and
  Opper]{galy2021flexible}
T.~Galy-Fajou, V.~Perrone, and M.~Opper.
\newblock {Flexible and efficient inference with particles for the variational
  Gaussian approximation}.
\newblock \emph{Entropy}, 23\penalty0 (8):\penalty0 990, 2021.

\bibitem[Gamerman and Lopes(2006)]{gamerman2006markov}
D.~Gamerman and H.~Lopes.
\newblock {Markov chain Monte Carlo: stochastic simulation for Bayesian
  inference}.
\newblock \emph{{CRC Press}}, 2006.

\bibitem[Gao et~al.(2023)Gao, Leong, Sun, and Bouman]{gao2023image}
A.~F. Gao, O.~Leong, H.~Sun, and K.~L. Bouman.
\newblock Image reconstruction without explicit priors.
\newblock In \emph{ICASSP 2023-2023 IEEE International Conference on Acoustics,
  Speech and Signal Processing (ICASSP)}, pages 1--5. IEEE, 2023.

\bibitem[Garbuno-Inigo et~al.(2023)Garbuno-Inigo, Helin, Hoffmann, and
  Hosseini]{garbuno2023bayesian}
A.~Garbuno-Inigo, T.~Helin, F.~Hoffmann, and B.~Hosseini.
\newblock Bayesian posterior perturbation analysis with integral probability
  metrics.
\newblock \emph{arXiv preprint arXiv:2303.01512}, 2023.

\bibitem[Garcia~Trillos and Sanz-Alonso(2018)]{garcia2018continuum}
N.~Garcia~Trillos and D.~Sanz-Alonso.
\newblock {Continuum limits of posteriors in graph Bayesian inverse problems}.
\newblock \emph{SIAM Journal on Mathematical Analysis}, 50\penalty0
  (4):\penalty0 4020--4040, 2018.

\bibitem[Garcia~Trillos and Sanz-Alonso(2020)]{trillos2018bayesian}
N.~Garcia~Trillos and D.~Sanz-Alonso.
\newblock {The Bayesian update: variational formulations and gradient flows}.
\newblock \emph{Bayesian Analysis}, 15\penalty0 (1):\penalty0 29--56, 2020.

\bibitem[Garcia~Trillos et~al.(2020)Garcia~Trillos, Kaplan, Samakhoana, and
  Sanz-Alonso]{trillos2017consistency}
N.~Garcia~Trillos, Z.~Kaplan, T.~Samakhoana, and D.~Sanz-Alonso.
\newblock {On the consistency of graph-based Bayesian semi-supervised learning
  and the scalability of sampling algorithms}.
\newblock \emph{Journal of Machine Learning Research}, 21\penalty0
  (28):\penalty0 1--47, 2020.

\bibitem[Genevay et~al.(2018)Genevay, Peyr{\'e}, and
  Cuturi]{genevay2018learning}
A.~Genevay, G.~Peyr{\'e}, and M.~Cuturi.
\newblock {Learning generative models with Sinkhorn divergences}.
\newblock In \emph{International Conference on Artificial Intelligence and
  Statistics}, pages 1608--1617. PMLR, 2018.

\bibitem[Ghil et~al.(1981)Ghil, Cohn, Tavantzis, Bube, and
  Isaacson]{ghil_applications_1981}
M.~Ghil, S.~Cohn, J.~Tavantzis, K.~Bube, and E.~Isaacson.
\newblock Applications of estimation theory to numerical weather prediction.
\newblock In \emph{Dynamic Meteorology: Data Assimilation Methods}, pages
  139--224. Springer, 1981.

\bibitem[Giannakis(2019)]{giannakis2019data}
D.~Giannakis.
\newblock Data-driven spectral decomposition and forecasting of ergodic
  dynamical systems.
\newblock \emph{Applied and Computational Harmonic Analysis}, 47\penalty0
  (2):\penalty0 338--396, 2019.

\bibitem[Gibbs and Su(2002)]{gibbs2002choosing}
A.~Gibbs and F.~Su.
\newblock On choosing and bounding probability metrics.
\newblock \emph{{International Statistical Review}}, 70\penalty0 (3):\penalty0
  419--435, 2002.

\bibitem[Gilton et~al.(2019)Gilton, Ongie, and Willett]{gilton2019neumann}
D.~Gilton, G.~Ongie, and R.~Willett.
\newblock Neumann networks for linear inverse problems in imaging.
\newblock \emph{IEEE Transactions on Computational Imaging}, 6:\penalty0
  328--343, 2019.

\bibitem[{Glyn-Davies} et~al.(2024){Glyn-Davies}, Duffin, Akyildiz, and
  Girolami]{glyn-davies_phi-dvae_2022}
A.~{Glyn-Davies}, C.~Duffin, {\"O}.~D. Akyildiz, and M.~Girolami.
\newblock {$\Phi$}-{{DVAE}}: Physics-informed dynamical variational
  autoencoders for unstructured data assimilation.
\newblock \emph{arXiv preprint arXiv:2209.15609v3}, 2024.

\bibitem[Gneiting and Raftery(2007)]{gneiting2007strictly}
T.~Gneiting and A.~E. Raftery.
\newblock Strictly proper scoring rules, prediction, and estimation.
\newblock \emph{Journal of the American Statistical Association}, 102\penalty0
  (477):\penalty0 359--378, 2007.

\bibitem[Gneiting and Ranjan(2011)]{gneiting_comparing_2011}
T.~Gneiting and R.~Ranjan.
\newblock Comparing density forecasts using threshold- and quantile-weighted
  scoring rules.
\newblock \emph{Journal of Business \& Economic Statistics}, 2011.
\newblock \doi{10.1198/jbes.2010.08110}.

\bibitem[Gneiting et~al.(2008)Gneiting, Stanberry, Grimit, Held, and
  Johnson]{gneiting_assessing_2008}
T.~Gneiting, L.~I. Stanberry, E.~P. Grimit, L.~Held, and N.~A. Johnson.
\newblock Assessing probabilistic forecasts of multivariate quantities, with an
  application to ensemble predictions of surface winds.
\newblock \emph{TEST}, 17\penalty0 (2):\penalty0 211--235, 2008.
\newblock \doi{10.1007/s11749-008-0114-x}.

\bibitem[Goodfellow et~al.(2014)Goodfellow, Pouget-Abadie, Mirza, Xu,
  Warde-Farley, Ozair, Courville, and Bengio]{goodfellow2014generative}
I.~Goodfellow, J.~Pouget-Abadie, M.~Mirza, B.~Xu, D.~Warde-Farley, S.~Ozair,
  A.~Courville, and Y.~Bengio.
\newblock Generative adversarial nets.
\newblock \emph{Advances in Neural Information Processing Systems}, 27, 2014.

\bibitem[Goodfellow et~al.(2016)Goodfellow, Bengio, and
  Courville]{goodfellow2016deep}
I.~Goodfellow, Y.~Bengio, and A.~Courville.
\newblock \emph{{Deep Learning}}.
\newblock MIT Press, 2016.

\bibitem[Gottwald and Reich(2021{\natexlab{a}})]{gottwald2021supervised}
G.~A. Gottwald and S.~Reich.
\newblock Supervised learning from noisy observations: Combining
  machine-learning techniques with data assimilation.
\newblock \emph{Physica D: Nonlinear Phenomena}, 423:\penalty0 132911,
  2021{\natexlab{a}}.
\newblock \doi{10.1016/j.physd.2021.132911}.

\bibitem[Gottwald and Reich(2021{\natexlab{b}})]{gottwald_combining_2021}
G.~A. Gottwald and S.~Reich.
\newblock Combining machine learning and data assimilation to forecast
  dynamical systems from noisy partial observations.
\newblock \emph{Chaos: An Interdisciplinary Journal of Nonlinear Science},
  31\penalty0 (10):\penalty0 101103, 2021{\natexlab{b}}.
\newblock \doi{10.1063/5.0066080}.

\bibitem[Gretton et~al.(2005)Gretton, Bousquet, Smola, and
  Sch{\"o}lkopf]{gretton2005measuring}
A.~Gretton, O.~Bousquet, A.~Smola, and B.~Sch{\"o}lkopf.
\newblock {Measuring statistical dependence with Hilbert-Schmidt norms}.
\newblock In \emph{International Conference on Algorithmic Learning Theory},
  pages 63--77. Springer, 2005.

\bibitem[Gretton et~al.(2012)Gretton, Borgwardt, Rasch, Sch{\"o}lkopf, and
  Smola]{gretton2012kernel}
A.~Gretton, K.~M. Borgwardt, M.~J. Rasch, B.~Sch{\"o}lkopf, and A.~Smola.
\newblock A kernel two-sample test.
\newblock \emph{The Journal of Machine Learning Research}, 13\penalty0
  (1):\penalty0 723--773, 2012.

\bibitem[Griewank and Walther(2008)]{griewank_evaluating_2008}
A.~Griewank and A.~Walther.
\newblock \emph{Evaluating {{Derivatives}}: {{Principles}} and {{Techniques}}
  of {{Algorithmic Differentiation}}}.
\newblock {Society for Industrial and Applied Mathematics}, 2 edition, 2008.
\newblock ISBN 978-0-89871-659-7.
\newblock \doi{10.1137/1.9780898717761}.

\bibitem[Grooms(2022)]{grooms2022comparison}
I.~Grooms.
\newblock {A comparison of nonlinear extensions to the ensemble Kalman filter:
  Gaussian anamorphosis and two-step ensemble filters}.
\newblock \emph{Computational Geosciences}, 26\penalty0 (3):\penalty0 633--650,
  2022.

\bibitem[Gupta and Nagar(2018)]{gupta2018matrix}
A.~K. Gupta and D.~K. Nagar.
\newblock \emph{Matrix Variate Distributions}.
\newblock Chapman and Hall/CRC, 2018.

\bibitem[Haber and Ruthotto(2017)]{haber2017stable}
E.~Haber and L.~Ruthotto.
\newblock Stable architectures for deep neural networks.
\newblock \emph{Inverse Problems}, 34\penalty0 (1):\penalty0 014004, 2017.

\bibitem[Hale(2010)]{hale}
J.~K. Hale.
\newblock \emph{Asymptotic behavior of dissipative systems}.
\newblock Number~25. American Mathematical Soc., 2010.

\bibitem[Hamilton et~al.(2016)Hamilton, Berry, and
  Sauer]{hamilton_ensemble_2016}
F.~Hamilton, T.~Berry, and T.~Sauer.
\newblock Ensemble {{Kalman filtering}} without a model.
\newblock \emph{Physical Review X}, 6\penalty0 (1):\penalty0 011021, 2016.
\newblock \doi{10.1103/PhysRevX.6.011021}.

\bibitem[Hammoud et~al.(2024)Hammoud, Raboudi, Titi, Knio, and
  Hoteit]{hammoud_data_2024}
M.~A. E.~R. Hammoud, N.~Raboudi, E.~S. Titi, O.~Knio, and I.~Hoteit.
\newblock Data assimilation in chaotic systems using deep reinforcement
  learning.
\newblock \emph{Journal of Advances in Modeling Earth Systems}, 16\penalty0
  (8):\penalty0 e2023MS004178, 2024.

\bibitem[Hannart et~al.(2016)Hannart, Carrassi, Bocquet, Ghil, Naveau, Pulido,
  Ruiz, and Tandeo]{hannart2016dada}
A.~Hannart, A.~Carrassi, M.~Bocquet, M.~Ghil, P.~Naveau, M.~Pulido, J.~Ruiz,
  and P.~Tandeo.
\newblock {DADA}: data assimilation for the detection and attribution of
  weather and climate-related events.
\newblock \emph{Climatic Change}, 136\penalty0 (2):\penalty0 155--174, 2016.
\newblock \doi{10.1007/s10584-016-1595-3}.

\bibitem[Hansen(2022)]{hansen_econometrics_2022}
B.~E. Hansen.
\newblock \emph{Econometrics}.
\newblock {Princeton University Press}, 2022.
\newblock ISBN 978-0-691-23589-9.

\bibitem[Harlim et~al.(2020)Harlim, Sanz-Alonso, and Yang]{harlim2019kernel}
J.~Harlim, D.~Sanz-Alonso, and R.~Yang.
\newblock {Kernel methods for Bayesian elliptic inverse problems on manifolds}.
\newblock \emph{SIAM/ASA Journal on Uncertainty Quantification}, 8\penalty0
  (4):\penalty0 1414--1445, 2020.

\bibitem[Harlim et~al.(2021)Harlim, Jiang, Liang, and Yang]{harlim2021machine}
J.~Harlim, S.~W. Jiang, S.~Liang, and H.~Yang.
\newblock Machine learning for prediction with missing dynamics.
\newblock \emph{Journal of Computational Physics}, 428:\penalty0 109922, 2021.

\bibitem[Harlim et~al.(2022)Harlim, Jiang, Kim, and
  Sanz-Alonso]{harlim2022graph}
J.~Harlim, S.~W. Jiang, H.~Kim, and D.~Sanz-Alonso.
\newblock Graph-based prior and forward models for inverse problems on
  manifolds with boundaries.
\newblock \emph{Inverse Problems}, 38\penalty0 (3):\penalty0 035006, 2022.

\bibitem[Harris et~al.(2023)Harris, Li, and Sriver]{harris_multimodel_2023}
T.~Harris, B.~Li, and R.~Sriver.
\newblock Multimodel ensemble analysis with neural network {{Gaussian}}
  processes.
\newblock \emph{The Annals of Applied Statistics}, 17\penalty0 (4):\penalty0
  3403--3425, 2023.
\newblock \doi{10.1214/23-AOAS1768}.

\bibitem[H{\"a}rter and {Fraga de Campos Velho}(2012)]{harter_data_2012}
F.~P. H{\"a}rter and H.~{Fraga de Campos Velho}.
\newblock Data {{assimilation procedure}} by {{recurrent neural network}}.
\newblock \emph{Engineering Applications of Computational Fluid Mechanics},
  6\penalty0 (2):\penalty0 224--233, 2012.
\newblock \doi{10.1080/19942060.2012.11015417}.

\bibitem[Hatfield et~al.(2021)Hatfield, Chantry, Dueben, Lopez, Geer, and
  Palmer]{hatfield_building_2021}
S.~Hatfield, M.~Chantry, P.~Dueben, P.~Lopez, A.~Geer, and T.~Palmer.
\newblock Building tangent-linear and adjoint models for data assimilation with
  neural networks.
\newblock \emph{Journal of Advances in Modeling Earth Systems}, 13\penalty0
  (9):\penalty0 e2021MS002521, 2021.
\newblock \doi{10.1029/2021MS002521}.

\bibitem[Helin and Burger(2015)]{helin2015maximum}
T.~Helin and M.~Burger.
\newblock {Maximum a posteriori probability estimates in infinite-dimensional
  Bayesian inverse problems}.
\newblock \emph{{Inverse Problems}}, 31\penalty0 (8):\penalty0 085009, 2015.

\bibitem[Helin et~al.(2022)Helin, Stuart, Teckentrup, and
  Zygalakis]{helin2023introduction}
T.~Helin, A.~M. Stuart, A.~L. Teckentrup, and K.~C. Zygalakis.
\newblock Introduction to {{Gaussian}} process regression in {{Bayesian}}
  inverse problems, with new results on experimental design for weighted error
  measures.
\newblock In \emph{International Conference on Monte Carlo and Quasi-Monte
  Carlo Methods in Scientific Computing}, pages 49--79. Springer, 2022.

\bibitem[Hernandez-Lobato et~al.(2016)Hernandez-Lobato, Li, Rowland, Bui,
  Hern{\'a}ndez-Lobato, and Turner]{hernandez2016black}
J.~Hernandez-Lobato, Y.~Li, M.~Rowland, T.~Bui, D.~Hern{\'a}ndez-Lobato, and
  R.~Turner.
\newblock Black-box alpha divergence minimization.
\newblock In \emph{International Conference on Machine Learning}, pages
  1511--1520. PMLR, 2016.

\bibitem[Hertrich et~al.(2024)Hertrich, Wald, Altekr{\"u}ger, and
  Hagemann]{hertrich_generative_2024}
J.~Hertrich, C.~Wald, F.~Altekr{\"u}ger, and P.~Hagemann.
\newblock Generative sliced {{MMD}} flows with {{Riesz}} kernels.
\newblock \emph{arXiv preprint arXiv:2305.11463}, 2024.
\newblock \doi{10.48550/arXiv.2305.11463}.

\bibitem[Heusel et~al.(2017)Heusel, Ramsauer, Unterthiner, Nessler, and
  Hochreiter]{heusel2017gans}
M.~Heusel, H.~Ramsauer, T.~Unterthiner, B.~Nessler, and S.~Hochreiter.
\newblock {GANs trained by a two time-scale update rule converge to a local
  Nash equilibrium}.
\newblock \emph{Advances in Neural Information Processing Systems}, 30, 2017.

\bibitem[Hinton and Zemel(1993)]{hinton1993autoencoders}
G.~E. Hinton and R.~Zemel.
\newblock {Autoencoders, minimum description length and Helmholtz free energy}.
\newblock \emph{Advances in Neural Information Processing Systems}, 6, 1993.

\bibitem[Hoang et~al.(1994)Hoang, De~Mey, and Talagrand]{hoang_simple_1994}
H.~Hoang, P.~De~Mey, and O.~Talagrand.
\newblock A simple adaptive algorithm of stochastic approximation type for
  system parameter and state estimation.
\newblock In \emph{Proceedings of 1994 33rd {{IEEE Conference}} on {{Decision}}
  and {{Control}}}, volume~1, pages 747--752 vol.1, 1994.
\newblock \doi{10.1109/CDC.1994.410863}.

\bibitem[Hoang et~al.(1998)Hoang, Baraille, Talagrand, Carton, and
  De~Mey]{hoang_adaptive_1998}
S.~Hoang, R.~Baraille, O.~Talagrand, X.~Carton, and P.~De~Mey.
\newblock Adaptive filtering: Application to satellite data assimilation in
  oceanography.
\newblock \emph{Dynamics of Atmospheres and Oceans}, 27\penalty0 (1):\penalty0
  257--281, 1998.
\newblock \doi{10.1016/S0377-0265(97)00014-6}.

\bibitem[Hoang et~al.(2023)Hoang, Krumscheid, Matthies, and
  Tempone]{hoang2021machine}
T.-V. Hoang, S.~Krumscheid, H.~G. Matthies, and R.~Tempone.
\newblock {Machine learning-based conditional mean filter: A generalization of
  the ensemble Kalman filter for nonlinear data assimilation}.
\newblock \emph{Foundations of Data Science}, 5\penalty0 (1):\penalty0 56--80,
  2023.

\bibitem[Hoel et~al.(2016)Hoel, Law, and Tempone]{hoel_multilevel_2016}
H.~Hoel, K.~J.~H. Law, and R.~Tempone.
\newblock Multilevel ensemble {{Kalman}} filtering.
\newblock \emph{SIAM Journal on Numerical Analysis}, 54\penalty0 (3):\penalty0
  1813--1839, 2016.
\newblock \doi{10.1137/15M100955X}.

\bibitem[Hoffman et~al.(2018)Hoffman, Sountsov, Dillon, Langmore, Tran, and
  Vasudevan]{hoffman2019neutra}
M.~Hoffman, P.~Sountsov, J.~V. Dillon, I.~Langmore, D.~Tran, and S.~Vasudevan.
\newblock Neutra-lizing bad geometry in hamiltonian monte carlo using neural
  transport.
\newblock In \emph{1st Symposium on Advances in Approximate Bayesian
  Inference}, 2018.

\bibitem[Hoffman et~al.(2013)Hoffman, Blei, Wang, and
  Paisley]{hoffman2013stochastic}
M.~D. Hoffman, D.~M. Blei, C.~Wang, and J.~Paisley.
\newblock Stochastic variational inference.
\newblock \emph{Journal of Machine Learning Research}, 14:\penalty0 1303--1347,
  2013.

\bibitem[Hoffmann et~al.(2022)Hoffmann, Hosseini, Oberai, and
  Stuart]{hoffmann2022spectral}
F.~Hoffmann, B.~Hosseini, A.~A. Oberai, and A.~M. Stuart.
\newblock {Spectral analysis of weighted Laplacians arising in data
  clustering}.
\newblock \emph{Applied and Computational Harmonic Analysis}, 56:\penalty0
  189--249, 2022.

\bibitem[H{\"o}hlein et~al.(2024)H{\"o}hlein, Schulz, Westermann, and
  Lerch]{hohlein_postprocessing_2024}
K.~H{\"o}hlein, B.~Schulz, R.~Westermann, and S.~Lerch.
\newblock Postprocessing of ensemble weather forecasts using
  permutation-invariant neural networks.
\newblock \emph{Artificial Intelligence for the Earth Systems}, 3\penalty0
  (1):\penalty0 e230070, 2024.
\newblock \doi{10.1175/AIES-D-23-0070.1}.

\bibitem[Holland and Melbourne(2007)]{holland2007central}
M.~Holland and I.~Melbourne.
\newblock {Central limit theorems and invariance principles for Lorenz
  attractors}.
\newblock \emph{Journal of the London Mathematical Society}, 76\penalty0
  (2):\penalty0 345--364, 2007.

\bibitem[Hosseini(2017)]{hosseini2017wellb}
B.~Hosseini.
\newblock {Well-posed Bayesian inverse problems with infinitely divisible and
  heavy-tailed prior measures}.
\newblock \emph{SIAM/ASA Journal on Uncertainty Quantification}, 5\penalty0
  (1):\penalty0 1024--1060, 2017.

\bibitem[Hosseini and Nigam(2017)]{hosseini2017well}
B.~Hosseini and N.~Nigam.
\newblock {Well-posed Bayesian inverse problems: Priors with exponential
  tails}.
\newblock \emph{SIAM/ASA Journal on Uncertainty Quantification}, 5\penalty0
  (1):\penalty0 436--465, 2017.

\bibitem[Hosseini et~al.(2023)Hosseini, Hsu, and
  Taghvaei]{hosseini2023conditional}
B.~Hosseini, A.~W. Hsu, and A.~Taghvaei.
\newblock Conditional optimal transport on function spaces.
\newblock \emph{arXiv preprint arXiv:2311.05672}, 2023.

\bibitem[Huang and Huang(2021)]{huang2021unscented2}
D.~Z. Huang and J.~Huang.
\newblock {Unscented Kalman inversion: Efficient Gaussian approximation to the
  posterior distribution}.
\newblock \emph{arXiv preprint arXiv:2103.00277}, 2021.

\bibitem[Huang et~al.(2022)Huang, Schneider, and Stuart]{huang2022iterated}
D.~Z. Huang, T.~Schneider, and A.~M. Stuart.
\newblock {Iterated Kalman methodology for inverse problems}.
\newblock \emph{Journal of Computational Physics}, 463:\penalty0 111262, 2022.
\newblock \doi{10.1016/j.jcp.2022.111262}.

\bibitem[Hunt et~al.(2007)Hunt, Kostelich, and Szunyogh]{hunt_efficient_2007}
B.~R. Hunt, E.~J. Kostelich, and I.~Szunyogh.
\newblock Efficient data assimilation for spatiotemporal chaos: {{A}} local
  ensemble transform {{Kalman}} filter.
\newblock \emph{Physica D: Nonlinear Phenomena}, 230\penalty0 (1):\penalty0
  112--126, 2007.
\newblock \doi{10.1016/j.physd.2006.11.008}.

\bibitem[Hyv{\"a}rinen(2005)]{hyvarinen2005estimation}
A.~Hyv{\"a}rinen.
\newblock Estimation of non-normalized statistical models by score matching.
\newblock \emph{Journal of Machine Learning Research}, 6:\penalty0 695--709,
  2005.

\bibitem[Iglesias(2015)]{iglesias2015iterative}
M.~A. Iglesias.
\newblock Iterative regularization for ensemble data assimilation in reservoir
  models.
\newblock \emph{{Computational Geosciences}}, 19\penalty0 (1):\penalty0
  177--212, 2015.

\bibitem[Iglesias(2016)]{iglesias2016regularizing}
M.~A. Iglesias.
\newblock {A regularizing iterative ensemble Kalman method for PDE-constrained
  inverse problems}.
\newblock \emph{Inverse Problems}, 32\penalty0 (2):\penalty0 025002, 2016.

\bibitem[Iglesias and Yang(2021)]{iglesias2021adaptive}
M.~A. Iglesias and Y.~Yang.
\newblock {Adaptive regularisation for ensemble Kalman inversion}.
\newblock \emph{Inverse Problems}, 37\penalty0 (2):\penalty0 025008, 2021.

\bibitem[Iglesias et~al.(2014)Iglesias, Law, and Stuart]{iglesias2013ensemble}
M.~A. Iglesias, K.~J.~H. Law, and A.~M. Stuart.
\newblock {Ensemble Kalman methods for inverse problems}.
\newblock \emph{{Inverse Problems}}, 29\penalty0 (4):\penalty0 045001, 2014.

\bibitem[Ishizone et~al.(2020)Ishizone, Higuchi, and
  Nakamura]{ishizone2020ensemble}
T.~Ishizone, T.~Higuchi, and K.~Nakamura.
\newblock {Ensemble Kalman variational objectives: nonlinear latent trajectory
  inference with a hybrid of variational inference and ensemble Kalman filter}.
\newblock \emph{arXiv preprint arXiv:2010.08729}, 2020.

\bibitem[Jacot et~al.(2018)Jacot, Gabriel, and Hongler]{jacot2018neural}
A.~Jacot, F.~Gabriel, and C.~Hongler.
\newblock Neural tangent kernel: Convergence and generalization in neural
  networks.
\newblock \emph{Advances in Neural Information Processing Systems}, 31, 2018.

\bibitem[Jazwinski(1970)]{jazwinski_stochastic_1970}
A.~H. Jazwinski.
\newblock \emph{Stochastic {{Processes}} and {{Filtering Theory}}}.
\newblock Number~64 in Mathematics in {{Science}} and {{Engineering}}.
  {Academic Press, Inc.}, {New York}, 1970.

\bibitem[Jordan et~al.(2019)Jordan, Kr{\"u}ger, and
  Lerch]{jordan_evaluating_2019}
A.~Jordan, F.~Kr{\"u}ger, and S.~Lerch.
\newblock Evaluating probabilistic forecasts with scoring rules.
\newblock \emph{Journal of Statistical Software}, 90:\penalty0 1--37, 2019.
\newblock \doi{10.18637/jss.v090.i12}.

\bibitem[Jordan et~al.(1999)Jordan, Ghahramani, Jaakkola, and
  Saul]{jordan1999introduction}
M.~I. Jordan, Z.~Ghahramani, T.~S. Jaakkola, and L.~K. Saul.
\newblock An introduction to variational methods for graphical models.
\newblock \emph{Machine Learning}, 37:\penalty0 183--233, 1999.

\bibitem[Kaelbling et~al.(1996)Kaelbling, Littman, and
  Moore]{kaelbling1996reinforcement}
L.~P. Kaelbling, M.~L. Littman, and A.~W. Moore.
\newblock Reinforcement learning: A survey.
\newblock \emph{Journal of Artificial Intelligence Research}, 4:\penalty0
  237--285, 1996.

\bibitem[Kaipio and Somersalo(2006)]{kaipio2006statistical}
J.~Kaipio and E.~Somersalo.
\newblock {Statistical and Computational Inverse Problems}.
\newblock \emph{{Springer Science \& Business Media}}, 160, 2006.

\bibitem[Kalman(1960)]{kalman1960new}
R.~Kalman.
\newblock A new approach to linear filtering and prediction problems.
\newblock \emph{{Journal of Basic Engineering}}, 82\penalty0 (1):\penalty0
  35--45, 1960.

\bibitem[Kalnay(2002)]{kalnay2003atmospheric}
E.~Kalnay.
\newblock \emph{Atmospheric {{Modeling}}, {{Data Assimilation}} and
  {{Predictability}}}.
\newblock {Cambridge University Press}, {New York}, 2002.
\newblock ISBN 978-0-521-79629-3.

\bibitem[Kalnay et~al.(1996)Kalnay, Kanamitsu, Kistler, Collins, Deaven,
  Gandin, Iredell, Saha, White, Woollen, Zhu, Chelliah, Ebisuzaki, Higgins,
  Janowiak, Mo, Ropelewski, Wang, Leetmaa, Reynolds, Jenne, and
  Joseph]{kalnay_ncepncar_1996}
E.~Kalnay, M.~Kanamitsu, R.~Kistler, W.~Collins, D.~Deaven, L.~Gandin,
  M.~Iredell, S.~Saha, G.~White, J.~Woollen, Y.~Zhu, M.~Chelliah, W.~Ebisuzaki,
  W.~Higgins, J.~Janowiak, K.~C. Mo, C.~Ropelewski, J.~Wang, A.~Leetmaa,
  R.~Reynolds, R.~Jenne, and D.~Joseph.
\newblock The {{NCEP}}/{{NCAR}} 40-{{Year Reanalysis Project}}.
\newblock \emph{Bulletin of the American Meteorological Society}, 77\penalty0
  (3):\penalty0 437--472, 1996.
\newblock \doi{10.1175/1520-0477(1996)077<0437:TNYRP>2.0.CO;2}.

\bibitem[Kalnay et~al.(2023)Kalnay, Sluka, Yoshida, Da, and
  Mote]{kalnay_review_2023}
E.~Kalnay, T.~Sluka, T.~Yoshida, C.~Da, and S.~Mote.
\newblock Review article: Towards strongly coupled ensemble data assimilation
  with additional improvements from machine learning.
\newblock \emph{Nonlinear Processes in Geophysics}, 30\penalty0 (2):\penalty0
  217--236, 2023.
\newblock \doi{10.5194/npg-30-217-2023}.

\bibitem[Keisler(2022)]{keisler2022forecasting}
R.~Keisler.
\newblock Forecasting global weather with graph neural networks.
\newblock \emph{arXiv preprint arXiv:2202.07575}, 2022.

\bibitem[Kennedy and O'Hagan(2001)]{kennedy2001bayesian}
M.~C. Kennedy and A.~O'Hagan.
\newblock Bayesian calibration of computer models.
\newblock \emph{Journal of the Royal Statistical Society: Series B (Statistical
  Methodology)}, 63\penalty0 (3):\penalty0 425--464, 2001.

\bibitem[Kerrigan et~al.(2024)Kerrigan, Migliorini, and
  Smyth]{kerrigan2024dynamic}
G.~Kerrigan, G.~Migliorini, and P.~Smyth.
\newblock Dynamic conditional optimal transport through simulation-free flows.
\newblock \emph{arXiv preprint arXiv:2404.04240}, 2024.

\bibitem[Kingma and Dhariwal(2018)]{kingma2018glow}
D.~P. Kingma and P.~Dhariwal.
\newblock Glow: Generative flow with invertible 1x1 convolutions.
\newblock \emph{Advances in Neural Information Processing Systems}, 31, 2018.

\bibitem[Kingma and Welling(2014)]{kingma2013auto}
D.~P. Kingma and M.~Welling.
\newblock {Auto-encoding variational Bayes}.
\newblock In \emph{2nd International Conference on Learning Representations},
  2014.

\bibitem[Kingma and Welling(2019)]{kingma2019introduction}
D.~P. Kingma and M.~Welling.
\newblock An introduction to variational autoencoders.
\newblock \emph{Foundations and Trends{\textregistered} in Machine Learning},
  12\penalty0 (4):\penalty0 307--392, 2019.

\bibitem[Kotsuki et~al.(2024)Kotsuki, Shiraishi, and
  Okazaki]{kotsuki_integrating_2024}
S.~Kotsuki, K.~Shiraishi, and A.~Okazaki.
\newblock Integrating ensemble {Kalman} filter with {AI}-based weather
  prediction model {ClimaX}.
\newblock \emph{arXiv preprint arXiv:2407.17781}, 2024.
\newblock \doi{10.48550/arXiv.2407.17781}.

\bibitem[Kovachki et~al.(2023)Kovachki, Li, Liu, Azizzadenesheli, Bhattacharya,
  Stuart, and Anandkumar]{kovachki2021neural}
N.~Kovachki, Z.~Li, B.~Liu, K.~Azizzadenesheli, K.~Bhattacharya, A.~Stuart, and
  A.~Anandkumar.
\newblock {Neural operator: Learning maps between function spaces with
  applications to PDEs}.
\newblock \emph{Journal of Machine Learning Research}, 24\penalty0
  (89):\penalty0 1--97, 2023.

\bibitem[Kovachki and Stuart(2019)]{kovachki2019ensemble}
N.~B. Kovachki and A.~M. Stuart.
\newblock {Ensemble Kalman inversion: A derivative-free technique for machine
  learning tasks}.
\newblock \emph{Inverse Problems}, 35\penalty0 (9):\penalty0 095005, 2019.

\bibitem[Krishnan et~al.(2017)Krishnan, Shalit, and
  Sontag]{krishnan2017structured}
R.~Krishnan, U.~Shalit, and D.~Sontag.
\newblock Structured inference networks for nonlinear state space models.
\newblock In \emph{Proceedings of the AAAI Conference on Artificial
  Intelligence}, volume~31, 2017.

\bibitem[Laio and Tamea(2007)]{laio2007verification}
F.~Laio and S.~Tamea.
\newblock Verification tools for probabilistic forecasts of continuous
  hydrological variables.
\newblock \emph{Hydrology and Earth System Sciences}, 11\penalty0 (4):\penalty0
  1267--1277, 2007.

\bibitem[Lam et~al.(2022)Lam, Sanchez-Gonzalez, Willson, Wirnsberger,
  Fortunato, Alet, Ravuri, Ewalds, Eaton-Rosen, Hu, et~al.]{lam2022graphcast}
R.~Lam, A.~Sanchez-Gonzalez, M.~Willson, P.~Wirnsberger, M.~Fortunato, F.~Alet,
  S.~Ravuri, T.~Ewalds, Z.~Eaton-Rosen, W.~Hu, et~al.
\newblock {GraphCast: Learning skillful medium-range global weather
  forecasting}.
\newblock \emph{arXiv preprint arXiv:2212.12794}, 2022.

\bibitem[Lambert et~al.(2022)Lambert, Chewi, Bach, Bonnabel, and
  Rigollet]{lambert2022variational}
M.~Lambert, S.~Chewi, F.~Bach, S.~Bonnabel, and P.~Rigollet.
\newblock {Variational inference via Wasserstein gradient flows}.
\newblock \emph{Advances in Neural Information Processing Systems},
  35:\penalty0 14434--14447, 2022.

\bibitem[Lambert et~al.(2023)Lambert, Bonnabel, and
  Bach]{lambert_variational_2023}
M.~Lambert, S.~Bonnabel, and F.~Bach.
\newblock Variational {{Gaussian approximation}} of the {{Kushner optimal
  filter}}.
\newblock In F.~Nielsen and F.~Barbaresco, editors, \emph{Geometric {{Science}}
  of {{Information}}}, Lecture {{Notes}} in {{Computer Science}}, pages
  395--404, {Cham}, 2023. {Springer Nature Switzerland}.
\newblock ISBN 978-3-031-38271-0.
\newblock \doi{10.1007/978-3-031-38271-0_39}.

\bibitem[Lambley and Sullivan(2023)]{lambley2023order}
H.~Lambley and T.~Sullivan.
\newblock {An order-theoretic perspective on modes and maximum a posteriori
  estimation in Bayesian inverse problems}.
\newblock \emph{SIAM/ASA Journal on Uncertainty Quantification}, 11\penalty0
  (4):\penalty0 1195--1224, 2023.

\bibitem[Lancaster and Rodman(1995)]{lancaster1995algebraic}
P.~Lancaster and L.~Rodman.
\newblock \emph{Algebraic Riccati Equations}.
\newblock Clarendon Press, 1995.

\bibitem[Lange(2016)]{lange2016mm}
K.~Lange.
\newblock \emph{MM Optimization Algorithms}.
\newblock SIAM, 2016.

\bibitem[Lasanen(2012{\natexlab{a}})]{lasanen2012non}
S.~Lasanen.
\newblock {Non-Gaussian statistical inverse problems. Part I: Posterior
  distributions}.
\newblock \emph{Inverse Problems \& Imaging}, 6\penalty0 (2):\penalty0
  215--266, 2012{\natexlab{a}}.

\bibitem[Lasanen(2012{\natexlab{b}})]{lasanen2012nonb}
S.~Lasanen.
\newblock {Non-Gaussian statistical inverse problems. Part II: Posterior
  convergence for approximated unknowns}.
\newblock \emph{Inverse Problems \& Imaging}, 6\penalty0 (2):\penalty0 267,
  2012{\natexlab{b}}.

\bibitem[Latz(2020)]{latz2020well}
J.~Latz.
\newblock {On the well-posedness of Bayesian inverse problems}.
\newblock \emph{SIAM/ASA Journal on Uncertainty Quantification}, 8\penalty0
  (1):\penalty0 451--482, 2020.

\bibitem[Laugesen et~al.(2015)Laugesen, Mehta, Meyn, and
  Raginsky]{laugesen_poissons_2015}
R.~S. Laugesen, P.~G. Mehta, S.~P. Meyn, and M.~Raginsky.
\newblock Poisson's equation in nonlinear filtering.
\newblock \emph{SIAM Journal on Control and Optimization}, 53\penalty0
  (1):\penalty0 501--525, 2015.
\newblock \doi{10.1137/13094743X}.

\bibitem[Law and Zankin(2022)]{law2022sparse}
K.~J. Law and V.~Zankin.
\newblock Sparse online variational bayesian regression.
\newblock \emph{SIAM/ASA Journal on Uncertainty Quantification}, 10\penalty0
  (3):\penalty0 1070--1100, 2022.

\bibitem[Law et~al.(2014)Law, Shukla, and Stuart]{law2012analysis}
K.~J.~H. Law, A.~Shukla, and A.~M. Stuart.
\newblock {Analysis of the 3DVAR filter for the partially observed Lorenz'63
  model}.
\newblock \emph{{Discrete and Continuous Dynamical Systems}}, 34\penalty0
  (3):\penalty0 1061--1078, 2014.

\bibitem[Law et~al.(2015)Law, Stuart, and Zygalakis]{law2015data}
K.~J.~H. Law, A.~M. Stuart, and K.~Zygalakis.
\newblock \emph{{Data Assimilation}}.
\newblock Springer, 2015.

\bibitem[Le et~al.(2018)Le, Igl, Rainforth, Jin, and Wood]{le2017auto}
T.~Le, M.~Igl, T.~Rainforth, T.~Jin, and F.~Wood.
\newblock {Auto-encoding sequential Monte Carlo}.
\newblock In \emph{International Conference on Learning Representations
  (ICLR)}, 2018.

\bibitem[Le~Gland et~al.(2009)Le~Gland, Monbet, and Tran]{le2009large}
F.~Le~Gland, V.~Monbet, and V.~Tran.
\newblock { Large sample asymptotics for the ensemble Kalman filter}.
\newblock \emph{{PhD Thesis}}, 2009.

\bibitem[Lee et~al.(2023)Lee, Lu, and Tan]{lee2023convergence}
H.~Lee, J.~Lu, and Y.~Tan.
\newblock Convergence of score-based generative modeling for general data
  distributions.
\newblock In \emph{International Conference on Algorithmic Learning Theory},
  pages 946--985. PMLR, 2023.

\bibitem[Lei and Bickel(2011)]{lei2011moment}
J.~Lei and P.~Bickel.
\newblock {A moment matching ensemble filter for nonlinear non-Gaussian data
  assimilation}.
\newblock \emph{Monthly Weather Review}, 139\penalty0 (12):\penalty0
  3964--3973, 2011.

\bibitem[Leutbecher and Haiden(2021)]{leutbecher_understanding_2021}
M.~Leutbecher and T.~Haiden.
\newblock Understanding changes of the continuous ranked probability score
  using a homogeneous {{Gaussian}} approximation.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  147\penalty0 (734):\penalty0 425--442, 2021.
\newblock \doi{10.1002/qj.3926}.

\bibitem[Levine and Stuart(2022)]{levine_framework_2022}
M.~Levine and A.~Stuart.
\newblock A framework for machine learning of model error in dynamical systems.
\newblock \emph{Communications of the American Mathematical Society},
  2\penalty0 (07):\penalty0 283--344, 2022.
\newblock ISSN 2692-3688.
\newblock \doi{10.1090/cams/10}.

\bibitem[Lguensat et~al.(2017)Lguensat, Tandeo, Ailliot, Pulido, and
  Fablet]{lguensat_analog_2017}
R.~Lguensat, P.~Tandeo, P.~Ailliot, M.~Pulido, and R.~Fablet.
\newblock The analog data assimilation.
\newblock \emph{Monthly Weather Review}, 145\penalty0 (10):\penalty0
  4093--4107, 2017.
\newblock \doi{10.1175/MWR-D-16-0441.1}.

\bibitem[Li et~al.(2024)Li, Carver, {Lopez-Gomez}, Sha, and
  Anderson]{li_seeds_2023}
L.~Li, R.~Carver, I.~{Lopez-Gomez}, F.~Sha, and J.~Anderson.
\newblock Generative emulation of weather forecast ensembles with diffusion
  models.
\newblock \emph{Science Advances}, 10\penalty0 (13):\penalty0 eadk4489, 2024.
\newblock \doi{10.1126/sciadv.adk4489}.

\bibitem[Li and Turner(2016)]{li2016renyi}
Y.~Li and R.~E. Turner.
\newblock R{\'e}nyi divergence variational inference.
\newblock \emph{Advances in Neural Information Processing Systems}, 29, 2016.

\bibitem[Liang et~al.(2022)Liang, Mahoney, and Hodgkinson]{liang2022fat}
F.~Liang, M.~Mahoney, and L.~Hodgkinson.
\newblock Fat--tailed variational inference with anisotropic tail adaptive
  flows.
\newblock In \emph{International Conference on Machine Learning}, pages
  13257--13270. PMLR, 2022.

\bibitem[Liu(2008)]{liu2008monte}
J.~S. Liu.
\newblock \emph{{Monte Carlo Strategies in Scientific Computing}}.
\newblock Springer Science \& Business Media, 2008.

\bibitem[Liu and Wang(2016)]{liu2016stein}
Q.~Liu and D.~Wang.
\newblock {Stein variational gradient descent: A general purpose Bayesian
  inference algorithm}.
\newblock \emph{Advances in Neural Information Processing Systems}, 29, 2016.

\bibitem[Lopez-Gomez et~al.(2022)Lopez-Gomez, Christopoulos, Langeland~Ervik,
  Dunbar, Cohen, and Schneider]{lopez2022training}
I.~Lopez-Gomez, C.~Christopoulos, H.~L. Langeland~Ervik, O.~R. Dunbar,
  Y.~Cohen, and T.~Schneider.
\newblock {Training physics-based machine-learning parameterizations with
  gradient-free ensemble Kalman methods}.
\newblock \emph{Journal of Advances in Modeling Earth Systems}, 14\penalty0
  (8):\penalty0 e2022MS003105, 2022.

\bibitem[Lorenc(1986)]{lorenc1986analysis}
A.~Lorenc.
\newblock Analysis methods for numerical weather prediction.
\newblock \emph{{Quarterly Journal of the Royal Meteorological Society}},
  112\penalty0 (474):\penalty0 1177--1194, 1986.

\bibitem[Lorenz(1969)]{lorenz_atmospheric_1969}
E.~N. Lorenz.
\newblock Atmospheric predictability as revealed by naturally occurring
  analogues.
\newblock \emph{Journal of the Atmospheric Sciences}, 26\penalty0 (4):\penalty0
  636--646, 1969.
\newblock \doi{10.1175/1520-0469(1969)26<636:APARBN>2.0.CO;2}.

\bibitem[Luk et~al.(2024)Luk, Bach, Baptista, and Stuart]{luk_learning_2024}
E.~Luk, E.~Bach, R.~Baptista, and A.~Stuart.
\newblock Learning optimal filters using variational inference.
\newblock \emph{arXiv preprint arXiv:2406.18066}, 2024.

\bibitem[Lunz et~al.(2018)Lunz, {\"O}ktem, and
  Sch{\"o}nlieb]{lunz2018adversarial}
S.~Lunz, O.~{\"O}ktem, and C.-B. Sch{\"o}nlieb.
\newblock Adversarial regularizers in inverse problems.
\newblock \emph{Advances in Neural Information Processing Systems}, 31, 2018.

\bibitem[Maddison et~al.(2017)Maddison, Lawson, Tucker, Heess, Norouzi, Mnih,
  Doucet, and Teh]{maddison2017filtering}
C.~J. Maddison, J.~Lawson, G.~Tucker, N.~Heess, M.~Norouzi, A.~Mnih, A.~Doucet,
  and Y.~Teh.
\newblock Filtering variational objectives.
\newblock \emph{Advances in Neural Information Processing Systems}, 30, 2017.

\bibitem[Majda and Harlim(2012)]{majda2012filtering}
A.~J. Majda and J.~Harlim.
\newblock \emph{{Filtering Complex Turbulent Systems}}.
\newblock {Cambridge University Press}, 2012.

\bibitem[{Mallia-Parfitt} and Br{\"o}cker(2016)]{mallia-parfitt_assessing_2016}
N.~{Mallia-Parfitt} and J.~Br{\"o}cker.
\newblock Assessing the performance of data assimilation algorithms which
  employ linear error feedback.
\newblock \emph{Chaos: An Interdisciplinary Journal of Nonlinear Science},
  26\penalty0 (10):\penalty0 103109, 2016.
\newblock \doi{10.1063/1.4965029}.

\bibitem[Mandel et~al.(2011)Mandel, Cobb, and Beezley]{mandel2011convergence}
J.~Mandel, L.~Cobb, and J.~D. Beezley.
\newblock {On the convergence of the ensemble Kalman filter}.
\newblock \emph{Applications of Mathematics}, 56\penalty0 (6):\penalty0
  533--541, 2011.

\bibitem[Marino et~al.(2018{\natexlab{a}})Marino, Cvitkovic, and
  Yue]{marino_general_2018}
J.~Marino, M.~Cvitkovic, and Y.~Yue.
\newblock A general method for amortizing variational filtering.
\newblock In \emph{Advances in {{Neural Information Processing Systems}}},
  volume~31, 2018{\natexlab{a}}.

\bibitem[Marino et~al.(2018{\natexlab{b}})Marino, Yue, and
  Mandt]{marino2018iterative}
J.~Marino, Y.~Yue, and S.~Mandt.
\newblock Iterative amortized inference.
\newblock In \emph{International Conference on Machine Learning}, pages
  3403--3412. PMLR, 2018{\natexlab{b}}.

\bibitem[Marzouk and Xiu(2009)]{marzouk2009stochastic}
Y.~Marzouk and D.~Xiu.
\newblock {A stochastic collocation approach to Bayesian inference in inverse
  problems}.
\newblock \emph{{Communications in Computational Physics}}, 6\penalty0
  (4):\penalty0 826--847, 2009.

\bibitem[Marzouk et~al.(2016)Marzouk, Moselhy, Parno, and
  Spantini]{marzouk2016sampling}
Y.~Marzouk, T.~Moselhy, M.~Parno, and A.~Spantini.
\newblock Sampling via measure transport: An introduction.
\newblock \emph{Handbook of Uncertainty Quantification}, pages 1--41, 2016.

\bibitem[Matheson and Winkler(1976)]{matheson_scoring_1976}
J.~E. Matheson and R.~L. Winkler.
\newblock Scoring rules for continuous probability distributions.
\newblock \emph{Management Science}, 22\penalty0 (10):\penalty0 1087--1096,
  1976.

\bibitem[Maurais et~al.(2023{\natexlab{a}})Maurais, Alsup, Peherstorfer, and
  Marzouk]{maurais_multi-fidelity_2023}
A.~Maurais, T.~Alsup, B.~Peherstorfer, and Y.~Marzouk.
\newblock Multi-fidelity covariance estimation in the log-euclidean geometry.
\newblock In \emph{International Conference on Machine Learning}, pages
  24214--24235. PMLR, 2023{\natexlab{a}}.

\bibitem[Maurais et~al.(2023{\natexlab{b}})Maurais, Alsup, Peherstorfer, and
  Marzouk]{maurais_multifidelity_2023}
A.~Maurais, T.~Alsup, B.~Peherstorfer, and Y.~Marzouk.
\newblock Multifidelity covariance estimation via regression on the manifold of
  symmetric positive definite matrices.
\newblock \emph{arXiv preprint arXiv:2307.12438}, 2023{\natexlab{b}}.

\bibitem[Maybeck(1982)]{maybeck_stochastic_1982}
P.~S. Maybeck.
\newblock \emph{Stochastic Models, Estimation, and Control}, volume~3.
\newblock {Academic Press}, {New York}, 1982.
\newblock ISBN 0-12-480703-8.

\bibitem[McCabe and Brown(2021)]{mccabe_learning_2021}
M.~McCabe and J.~Brown.
\newblock Learning to assimilate in chaotic dynamical systems.
\newblock In \emph{Advances in Neural Information Processing Systems},
  volume~34, pages 12237--12250, 2021.

\bibitem[Mehra(1970)]{mehra_identification_1970}
R.~Mehra.
\newblock On the identification of variances and adaptive {{Kalman}} filtering.
\newblock \emph{IEEE Transactions on Automatic Control}, 15\penalty0
  (2):\penalty0 175--184, 1970.
\newblock \doi{10.1109/TAC.1970.1099422}.

\bibitem[Melinc and Zaplotnik(2024)]{melinc_3d-var_2024}
B.~Melinc and {\v Z}.~Zaplotnik.
\newblock {{3D-Var}} data assimilation using a variational autoencoder.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  150\penalty0 (761):\penalty0 2273--2295, 2024.
\newblock \doi{10.1002/qj.4708}.

\bibitem[M{\'e}nard(2016)]{menard_error_2016}
R.~M{\'e}nard.
\newblock Error covariance estimation methods based on analysis residuals:
  Theoretical foundation and convergence properties derived from simplified
  observation networks.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  142\penalty0 (694):\penalty0 257--273, 2016.
\newblock \doi{10.1002/qj.2650}.

\bibitem[Meng and Van~Dyk(1997)]{meng1997algorithm}
X.-L. Meng and D.~Van~Dyk.
\newblock {The EM algorithm—an old folk-song sung to a fast new tune}.
\newblock \emph{Journal of the Royal Statistical Society Series B: Statistical
  Methodology}, 59\penalty0 (3):\penalty0 511--567, 1997.

\bibitem[Metref et~al.(2019)Metref, Hannart, Ruiz, Bocquet, Carrassi, and
  Ghil]{metref2019estimating}
S.~Metref, A.~Hannart, J.~Ruiz, M.~Bocquet, A.~Carrassi, and M.~Ghil.
\newblock {Estimating model evidence using ensemble-based data assimilation
  with localization--The model selection problem}.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  145\penalty0 (721):\penalty0 1571--1588, 2019.

\bibitem[Meyn and Tweedie(2012)]{meyn2012markov}
S.~Meyn and R.~Tweedie.
\newblock \emph{{Markov Chains and Stochastic Stability}}.
\newblock { Springer Science and Business Media}, 2012.

\bibitem[Miller and Karl(2003)]{miller2003fundamentals}
E.~L. Miller and W.~C. Karl.
\newblock \emph{{Fundamentals of Inverse Problems}}.
\newblock Unpublished, 2003.
\newblock URL
  \url{https://ece.northeastern.edu/fac-ece/elmiller/eceg398f03/notes.pdf}.

\bibitem[Miyoshi(2011)]{miyoshi_gaussian_2011}
T.~Miyoshi.
\newblock The {{Gaussian}} approach to adaptive covariance inflation and its
  implementation with the local ensemble transform {{Kalman}} filter.
\newblock \emph{Monthly Weather Review}, 139\penalty0 (5):\penalty0 1519--1535,
  2011.
\newblock \doi{10.1175/2010MWR3570.1}.

\bibitem[Moodey et~al.(2013)Moodey, Lawless, Potthast, and
  Van~Leeuwen]{moodey2013nonlinear}
A.~J. Moodey, A.~S. Lawless, R.~W. Potthast, and P.~J. Van~Leeuwen.
\newblock Nonlinear error dynamics for cycled data assimilation methods.
\newblock \emph{Inverse Problems}, 29\penalty0 (2):\penalty0 025002, 2013.

\bibitem[Moosavi et~al.(2019)Moosavi, Attia, and Sandu]{moosavi_tuning_2019}
A.~Moosavi, A.~Attia, and A.~Sandu.
\newblock Tuning covariance localization using machine learning.
\newblock In J.~M.~F. Rodrigues, P.~J.~S. Cardoso, J.~Monteiro, R.~Lam, V.~V.
  Krzhizhanovskaya, M.~H. Lees, J.~J. Dongarra, and P.~M. Sloot, editors,
  \emph{Computational {{Science}} {\textendash} {{ICCS}} 2019}, Lecture
  {{Notes}} in {{Computer Science}}, pages 199--212, {Cham}, 2019. {Springer
  International Publishing}.
\newblock ISBN 978-3-030-22747-0.
\newblock \doi{10.1007/978-3-030-22747-0_16}.

\bibitem[Mowlavi and Benosman(2024)]{mowlavi2024reinforcement}
S.~Mowlavi and M.~Benosman.
\newblock Reinforcement learning-based estimation for spatio-temporal systems.
\newblock \emph{Scientific Reports}, 14\penalty0 (1):\penalty0 22464, 2024.

\bibitem[Muandet et~al.(2017)Muandet, Fukumizu, Sriperumbudur, Sch{\"o}lkopf,
  et~al.]{muandet2017kernel}
K.~Muandet, K.~Fukumizu, B.~Sriperumbudur, B.~Sch{\"o}lkopf, et~al.
\newblock {Kernel mean embedding of distributions: A review and beyond}.
\newblock \emph{Foundations and Trends{\textregistered} in Machine Learning},
  10\penalty0 (1-2):\penalty0 1--141, 2017.

\bibitem[M{\"u}ller et~al.(2019)M{\"u}ller, McWilliams, Rousselle, Gross, and
  Nov{\'a}k]{muller2019neural}
T.~M{\"u}ller, B.~McWilliams, F.~Rousselle, M.~Gross, and J.~Nov{\'a}k.
\newblock Neural importance sampling.
\newblock \emph{ACM Transactions on Graphics (ToG)}, 38\penalty0 (5):\penalty0
  1--19, 2019.

\bibitem[Mure{\c s}an(2009)]{muresan_concrete_2009}
M.~Mure{\c s}an.
\newblock \emph{A {{Concrete Approach}} to {{Classical Analysis}}}.
\newblock {{CMS Books}} in {{Mathematics}}. Springer, New York, NY, 2009.
\newblock ISBN 978-0-387-78932-3 978-0-387-78933-0.
\newblock \doi{10.1007/978-0-387-78933-0}.

\bibitem[Murphy and Epstein(1989)]{murphy1989skill}
A.~H. Murphy and E.~S. Epstein.
\newblock Skill scores and correlation coefficients in model verification.
\newblock \emph{Monthly Weather Review}, 117\penalty0 (3):\penalty0 572--582,
  1989.
\newblock \doi{10.1175/1520-0493(1989)117<0572:SSACCI>2.0.CO;2}.

\bibitem[Naesseth et~al.(2018)Naesseth, Linderman, Ranganath, and
  Blei]{naesseth2018variational}
C.~Naesseth, S.~Linderman, R.~Ranganath, and D.~Blei.
\newblock {Variational sequential Monte Carlo}.
\newblock In \emph{International Conference on Artificial Intelligence and
  Statistics}, pages 968--977. PMLR, 2018.

\bibitem[Narayan et~al.(2012)Narayan, Marzouk, and
  Xiu]{narayan_sequential_2012}
A.~Narayan, Y.~Marzouk, and D.~Xiu.
\newblock Sequential data assimilation with multiple models.
\newblock \emph{Journal of Computational Physics}, 231\penalty0 (19):\penalty0
  6401--6418, 2012.
\newblock \doi{10.1016/j.jcp.2012.06.002}.

\bibitem[Nel(1978)]{nel_symmetric_1978}
D.~G. Nel.
\newblock On the symmetric multivariate normal distribution and the asymptotic
  expansion of a {{Wishart}} matrix.
\newblock \emph{South African Statistical Journal}, 12\penalty0 (2):\penalty0
  145--159, 1978.
\newblock \doi{10.10520/AJA0038271X_302}.

\bibitem[Nelsen and Stuart(2021)]{nelsen2021random}
N.~H. Nelsen and A.~M. Stuart.
\newblock {The random feature model for input-output maps between Banach
  spaces}.
\newblock \emph{SIAM Journal on Scientific Computing}, 43\penalty0
  (5):\penalty0 A3212--A3243, 2021.

\bibitem[Nesterov(2004)]{nesterov_introductory_2004}
Y.~Nesterov.
\newblock \emph{Introductory {{Lectures}} on {{Convex Optimization}}},
  volume~87 of \emph{Applied {{Optimization}}}.
\newblock Springer US, Boston, MA, 2004.
\newblock ISBN 978-1-4613-4691-3 978-1-4419-8853-9.
\newblock \doi{10.1007/978-1-4419-8853-9}.

\bibitem[Ng et~al.(2001)Ng, Jordan, and Weiss]{ng2001spectral}
A.~Ng, M.~Jordan, and Y.~Weiss.
\newblock On spectral clustering: Analysis and an algorithm.
\newblock \emph{Advances in Neural Information Processing Systems}, 14, 2001.

\bibitem[Nguyen et~al.(2019)Nguyen, Ouala, Drumetz, and Fablet]{nguyen2019like}
D.~Nguyen, S.~Ouala, L.~Drumetz, and R.~Fablet.
\newblock {EM}-like learning chaotic dynamics from noisy and partial
  observations.
\newblock \emph{arXiv preprint arXiv:1903.10335}, 2019.

\bibitem[Nickl(2022)]{nickl}
R.~Nickl.
\newblock \emph{Bayesian Non-linear Statistical Inverse Problems}.
\newblock Zurich Lectures in Advanced Mathematics. EMS Press, 2022.
\newblock URL
  \url{http://www.statslab.cam.ac.uk/~nickl/Site/__files/lecturenotes.pdf}.

\bibitem[Nocedal and Wright(2006)]{nocedal_numerical_2006}
J.~Nocedal and S.~J. Wright.
\newblock \emph{Numerical Optimization}.
\newblock Springer {{Series}} in {{Operations Research}} and {{Financial
  Engineering}}. {Springer New York}, {New York}, 2006.
\newblock ISBN 978-0-387-30303-1.
\newblock \doi{10.1007/978-0-387-40065-5}.

\bibitem[Oczkowski et~al.(2005)Oczkowski, Szunyogh, and
  Patil]{oczkowski_mechanisms_2005}
M.~Oczkowski, I.~Szunyogh, and D.~J. Patil.
\newblock Mechanisms for the {{development}} of {{locally low-dimensional
  atmospheric dynamics}}.
\newblock \emph{Journal of the Atmospheric Sciences}, 62\penalty0 (4):\penalty0
  1135--1156, 2005.
\newblock \doi{10.1175/JAS3403.1}.

\bibitem[Oliva et~al.(2018)Oliva, Dubey, Zaheer, Poczos, Salakhutdinov, Xing,
  and Schneider]{oliva2018transformation}
J.~Oliva, A.~Dubey, M.~Zaheer, B.~Poczos, R.~Salakhutdinov, E.~Xing, and
  J.~Schneider.
\newblock Transformation autoregressive networks.
\newblock In \emph{International Conference on Machine Learning}, pages
  3898--3907. PMLR, 2018.

\bibitem[Ongie et~al.(2020)Ongie, Jalal, Metzler, Baraniuk, Dimakis, and
  Willett]{ongie2020deep}
G.~Ongie, A.~Jalal, C.~A. Metzler, R.~G. Baraniuk, A.~G. Dimakis, and
  R.~Willett.
\newblock Deep learning techniques for inverse problems in imaging.
\newblock \emph{IEEE Journal on Selected Areas in Information Theory},
  1\penalty0 (1):\penalty0 39--56, 2020.

\bibitem[Opper and Archambeau(2009)]{opper2009variational}
M.~Opper and C.~Archambeau.
\newblock {The variational Gaussian approximation revisited}.
\newblock \emph{Neural Computation}, 21\penalty0 (3):\penalty0 786--792, 2009.

\bibitem[Owhadi and Scovel(2019)]{owhadi2019operator}
H.~Owhadi and C.~Scovel.
\newblock \emph{{Operator-Adapted Wavelets, Fast Solvers, and Numerical
  Homogenization: From a Game Theoretic Approach to Numerical Approximation and
  Algorithm Design}}, volume~35.
\newblock Cambridge University Press, 2019.

\bibitem[Panofsky(1949)]{panofsky_objective_1949}
H.~A. Panofsky.
\newblock Objective weather-map analysis.
\newblock \emph{Journal of Meteorology}, 6\penalty0 (6):\penalty0 386--392,
  1949.
\newblock \doi{10.1175/1520-0469(1949)006<0386:OWMA>2.0.CO;2}.

\bibitem[Papamakarios et~al.(2019)Papamakarios, Sterratt, and
  Murray]{papamakarios2019sequential}
G.~Papamakarios, D.~Sterratt, and I.~Murray.
\newblock {Sequential neural likelihood: Fast likelihood-free inference with
  autoregressive flows}.
\newblock In \emph{The 22nd International Conference on Artificial Intelligence
  and Statistics}, pages 837--848. PMLR, 2019.

\bibitem[Parno and Marzouk(2018)]{parno2018transport}
M.~D. Parno and Y.~M. Marzouk.
\newblock Transport map accelerated markov chain monte carlo.
\newblock \emph{SIAM/ASA Journal on Uncertainty Quantification}, 6\penalty0
  (2):\penalty0 645--682, 2018.

\bibitem[Patel and Oberai(2021)]{patel2021gan}
D.~V. Patel and A.~A. Oberai.
\newblock {GAN-based priors for quantifying uncertainty in supervised
  learning}.
\newblock \emph{SIAM/ASA Journal on Uncertainty Quantification}, 9\penalty0
  (3):\penalty0 1314--1343, 2021.

\bibitem[Pathak et~al.(2022)Pathak, Subramanian, Harrington, Raja,
  Chattopadhyay, Mardani, Kurth, Hall, Li, Azizzadenesheli,
  et~al.]{pathak2022fourcastnet}
J.~Pathak, S.~Subramanian, P.~Harrington, S.~Raja, A.~Chattopadhyay,
  M.~Mardani, T.~Kurth, D.~Hall, Z.~Li, K.~Azizzadenesheli, et~al.
\newblock Fourcastnet: A global data-driven high-resolution weather model using
  adaptive fourier neural operators.
\newblock \emph{arXiv preprint arXiv:2202.11214}, 2022.

\bibitem[Patil et~al.(2001)Patil, Hunt, Kalnay, Yorke, and
  Ott]{patil_local_2001}
D.~J. Patil, B.~R. Hunt, E.~Kalnay, J.~A. Yorke, and E.~Ott.
\newblock Local {{low dimensionality}} of {{atmospheric dynamics}}.
\newblock \emph{Physical Review Letters}, 86\penalty0 (26):\penalty0
  5878--5881, 2001.
\newblock \doi{10.1103/PhysRevLett.86.5878}.

\bibitem[Peherstorfer et~al.(2016)Peherstorfer, Willcox, and
  Gunzburger]{peherstorfer_optimal_2016}
B.~Peherstorfer, K.~Willcox, and M.~Gunzburger.
\newblock {Optimal model management for multifidelity Monte Carlo estimation}.
\newblock \emph{SIAM Journal on Scientific Computing}, 38\penalty0
  (5):\penalty0 A3163--A3194, 2016.
\newblock \doi{10.1137/15M1046472}.

\bibitem[Peherstorfer et~al.(2018)Peherstorfer, Willcox, and
  Gunzburger]{peherstorfer_survey_2018}
B.~Peherstorfer, K.~Willcox, and M.~Gunzburger.
\newblock Survey of multifidelity methods in uncertainty propagation,
  inference, and optimization.
\newblock \emph{SIAM Review}, 60\penalty0 (3):\penalty0 550--591, 2018.
\newblock \doi{10.1137/16M1082469}.

\bibitem[Penny et~al.(2022)Penny, Smith, Chen, Platt, Lin, Goodliff, and
  Abarbanel]{penny_integrating_2022}
S.~G. Penny, T.~A. Smith, T.-C. Chen, J.~A. Platt, H.-Y. Lin, M.~Goodliff, and
  H.~D.~I. Abarbanel.
\newblock Integrating recurrent neural networks with data assimilation for
  scalable data-driven state estimation.
\newblock \emph{Journal of Advances in Modeling Earth Systems}, 14\penalty0
  (3):\penalty0 e2021MS002843, 2022.
\newblock \doi{10.1029/2021MS002843}.

\bibitem[Peyr{\'e} et~al.(2019)Peyr{\'e}, Cuturi,
  et~al.]{peyre2017computational}
G.~Peyr{\'e}, M.~Cuturi, et~al.
\newblock Computational optimal transport: with applications to data science.
\newblock \emph{Foundations and Trends{\textregistered} in Machine Learning},
  11\penalty0 (5-6):\penalty0 355--607, 2019.

\bibitem[Peyron et~al.(2021)Peyron, Fillion, G{\"u}rol, Marchais, Gratton,
  Boudier, and Goret]{peyron_latent_2021}
M.~Peyron, A.~Fillion, S.~G{\"u}rol, V.~Marchais, S.~Gratton, P.~Boudier, and
  G.~Goret.
\newblock Latent space data assimilation by using deep learning.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  147\penalty0 (740):\penalty0 3759--3777, 2021.
\newblock \doi{10.1002/qj.4153}.

\bibitem[Pinkus(1999)]{pinkus1999approximation}
A.~Pinkus.
\newblock {Approximation theory of the MLP model in neural networks}.
\newblock \emph{Acta Numerica}, 8:\penalty0 143--195, 1999.

\bibitem[Platt et~al.(2023)Platt, Penny, Smith, Chen, and
  Abarbanel]{platt_constraining_2023}
J.~A. Platt, S.~G. Penny, T.~A. Smith, T.-C. Chen, and H.~D.~I. Abarbanel.
\newblock Constraining chaos: {{Enforcing}} dynamical invariants in the
  training of reservoir computers.
\newblock \emph{Chaos: An Interdisciplinary Journal of Nonlinear Science},
  33\penalty0 (10):\penalty0 103107, 2023.
\newblock \doi{10.1063/5.0156999}.

\bibitem[Popov and Sandu(2019)]{popov_bayesian_2019}
A.~A. Popov and A.~Sandu.
\newblock A {{Bayesian}} approach to multivariate adaptive localization in
  ensemble-based data assimilation with time-dependent extensions.
\newblock \emph{Nonlinear Processes in Geophysics}, 26\penalty0 (2):\penalty0
  109--122, 2019.
\newblock \doi{10.5194/npg-26-109-2019}.

\bibitem[Popov et~al.(2021)Popov, Mou, Sandu, and
  Iliescu]{popov_multifidelity_2021}
A.~A. Popov, C.~Mou, A.~Sandu, and T.~Iliescu.
\newblock {A multifidelity ensemble Kalman filter with reduced order control
  variates}.
\newblock \emph{SIAM Journal on Scientific Computing}, 43\penalty0
  (2):\penalty0 A1134--A1162, 2021.
\newblock \doi{10.1137/20M1349965}.

\bibitem[Price et~al.(2023)Price, {Sanchez-Gonzalez}, Alet, Ewalds, {El-Kadi},
  Stott, Mohamed, Battaglia, Lam, and Willson]{price_gencast_2023}
I.~Price, A.~{Sanchez-Gonzalez}, F.~Alet, T.~Ewalds, A.~{El-Kadi}, J.~Stott,
  S.~Mohamed, P.~Battaglia, R.~Lam, and M.~Willson.
\newblock {{GenCast}}: {{Diffusion-based}} ensemble forecasting for
  medium-range weather.
\newblock \emph{arXiv preprint arXiv:2312.15796}, 2023.

\bibitem[Provost et~al.(2023)Provost, Baptista, Eldredge, and
  Marzouk]{le_provost_adaptive_2023}
M.~L. Provost, R.~Baptista, J.~D. Eldredge, and Y.~Marzouk.
\newblock An adaptive ensemble filter for heavy-tailed distributions:
  tuning-free inflation and localization.
\newblock \emph{arXiv preprint arXiv:2310.08741}, 2023.

\bibitem[Pulido and van Leeuwen(2019)]{pulido2019sequential}
M.~Pulido and P.~J. van Leeuwen.
\newblock {Sequential Monte Carlo with kernel embedded mappings: The mapping
  particle filter}.
\newblock \emph{Journal of Computational Physics}, 396:\penalty0 400--415,
  2019.
\newblock \doi{10.1016/j.jcp.2019.06.060}.

\bibitem[Pulido et~al.(2018)Pulido, Tandeo, Bocquet, Carrassi, and
  Lucini]{pulido2018stochastic}
M.~Pulido, P.~Tandeo, M.~Bocquet, A.~Carrassi, and M.~Lucini.
\newblock {Stochastic parameterization identification using ensemble Kalman
  filtering combined with maximum likelihood methods}.
\newblock \emph{Tellus A: Dynamic Meteorology and Oceanography}, 70\penalty0
  (1):\penalty0 1--17, 2018.

\bibitem[Rahimi and Recht(2007)]{rahimi2007random}
A.~Rahimi and B.~Recht.
\newblock Random features for large-scale kernel machines.
\newblock \emph{Advances in Neural Information Processing Systems}, 20, 2007.

\bibitem[Rahimi and Recht(2008{\natexlab{a}})]{rahimi2008uniform}
A.~Rahimi and B.~Recht.
\newblock Uniform approximation of functions with random bases.
\newblock In \emph{2008 46th Annual Allerton Conference on Communication,
  Control, and Computing}, pages 555--561. IEEE, 2008{\natexlab{a}}.

\bibitem[Rahimi and Recht(2008{\natexlab{b}})]{rahimi2008weighted}
A.~Rahimi and B.~Recht.
\newblock {Weighted sums of random kitchen sinks: Replacing minimization with
  randomization in learning}.
\newblock \emph{Advances in Neural Information Processing Systems}, 21,
  2008{\natexlab{b}}.

\bibitem[Raissi et~al.(2018)Raissi, Perdikaris, and
  Karniadakis]{raissi2018multistep}
M.~Raissi, P.~Perdikaris, and G.~E. Karniadakis.
\newblock Multistep neural networks for data-driven discovery of nonlinear
  dynamical systems.
\newblock \emph{arXiv preprint arXiv:1801.01236}, 2018.

\bibitem[Raissi et~al.(2019)Raissi, Perdikaris, and
  Karniadakis]{raissi2019physics}
M.~Raissi, P.~Perdikaris, and G.~E. Karniadakis.
\newblock {Physics-informed neural networks: A deep learning framework for
  solving forward and inverse problems involving nonlinear partial differential
  equations}.
\newblock \emph{Journal of Computational physics}, 378:\penalty0 686--707,
  2019.

\bibitem[Ranganath et~al.(2014)Ranganath, Gerrish, and
  Blei]{ranganath2014black}
R.~Ranganath, S.~Gerrish, and D.~Blei.
\newblock Black box variational inference.
\newblock In \emph{Artificial Intelligence and Statistics}, pages 814--822.
  PMLR, 2014.

\bibitem[Rangapuram et~al.(2018)Rangapuram, Seeger, Gasthaus, Stella, Wang, and
  Januschowski]{rangapuram2018deep}
S.~S. Rangapuram, M.~Seeger, J.~Gasthaus, L.~Stella, Y.~Wang, and
  T.~Januschowski.
\newblock Deep state space models for time series forecasting.
\newblock In \emph{Proceedings of the 32nd International Conference on Neural
  Information Processing Systems}, pages 7796--7805, 2018.

\bibitem[Rasp et~al.(2018)Rasp, Pritchard, and Gentine]{rasp2018deep}
S.~Rasp, M.~S. Pritchard, and P.~Gentine.
\newblock Deep learning to represent subgrid processes in climate models.
\newblock \emph{Proceedings of the National Academy of Sciences}, 115\penalty0
  (39):\penalty0 9684--9689, 2018.

\bibitem[Rasul et~al.(2021)Rasul, Sheikh, Schuster, Bergmann, and
  Vollgraf]{rasul2020multivariate}
K.~Rasul, A.-S. Sheikh, I.~Schuster, U.~Bergmann, and R.~Vollgraf.
\newblock Multivariate probabilistic time series forecasting via conditioned
  normalizing flows.
\newblock \emph{International Conference on Learning Representations}, 2021.

\bibitem[Ray et~al.(2023)Ray, {Murgoitio-Esandi}, Dasgupta, and
  Oberai]{ray2023solution}
D.~Ray, J.~{Murgoitio-Esandi}, A.~Dasgupta, and A.~A. Oberai.
\newblock Solution of physics-based inverse problems using conditional
  generative adversarial networks with full gradient penalty.
\newblock \emph{Computer Methods in Applied Mechanics and Engineering},
  417:\penalty0 116338, 2023.
\newblock \doi{10.1016/j.cma.2023.116338}.

\bibitem[Reich(2019)]{reich2019data}
S.~Reich.
\newblock {Data assimilation: the Schr{\"o}dinger perspective}.
\newblock \emph{Acta Numerica}, 28:\penalty0 635--711, 2019.
\newblock \doi{10.1017/S0962492919000011}.

\bibitem[Reich and Cotter(2015)]{reich2015probabilistic}
S.~Reich and C.~Cotter.
\newblock \emph{Probabilistic Forecasting and Bayesian Data Assimilation}.
\newblock {Cambridge University Press}, 2015.

\bibitem[Rezende and Mohamed(2015)]{rezende2015variational}
D.~Rezende and S.~Mohamed.
\newblock Variational inference with normalizing flows.
\newblock In \emph{International Conference on Machine Learning}, pages
  1530--1538. PMLR, 2015.

\bibitem[Rezende et~al.(2014)Rezende, Mohamed, and
  Wierstra]{rezende2014stochastic}
D.~J. Rezende, S.~Mohamed, and D.~Wierstra.
\newblock Stochastic backpropagation and approximate inference in deep
  generative models.
\newblock In \emph{International Conference on Machine Learning}, pages
  1278--1286. PMLR, 2014.

\bibitem[Robert and Casella(2013)]{robert2013monte}
C.~Robert and G.~Casella.
\newblock \emph{{Monte Carlo Statistical Methods}}.
\newblock Springer Science \& Business Media, 2013.

\bibitem[Rozet and Louppe(2023)]{rozet_score-based_2023}
F.~Rozet and G.~Louppe.
\newblock Score-based data assimilation.
\newblock \emph{Advances in Neural Information Processing Systems},
  36:\penalty0 40521--40541, 2023.

\bibitem[Sacher and Bartello(2008)]{sacher_sampling_2008}
W.~Sacher and P.~Bartello.
\newblock Sampling {{errors}} in {{ensemble Kalman filtering}}. {{Part I}}:
  {{Theory}}.
\newblock \emph{Monthly Weather Review}, 136\penalty0 (8):\penalty0 3035--3049,
  2008.
\newblock \doi{10.1175/2007MWR2323.1}.

\bibitem[Sacks et~al.(1989)Sacks, Welch, Mitchell, and Wynn]{sacks1989design}
J.~Sacks, W.~J. Welch, T.~J. Mitchell, and H.~P. Wynn.
\newblock Design and analysis of computer experiments.
\newblock \emph{Statistical Science}, 4\penalty0 (4):\penalty0 409--423, 1989.

\bibitem[Sahu and Roberts(1999)]{sahu1999convergence}
S.~K. Sahu and G.~O. Roberts.
\newblock {On convergence of the EM algorithmand the Gibbs sampler}.
\newblock \emph{Statistics and Computing}, 9\penalty0 (1):\penalty0 55--64,
  1999.

\bibitem[Sanz-Alonso(2018)]{sanz2018importance}
D.~Sanz-Alonso.
\newblock Importance sampling and necessary sample size: An information theory
  approach.
\newblock \emph{SIAM/ASA Journal on Uncertainty Quantification}, 6\penalty0
  (2):\penalty0 867--879, 2018.

\bibitem[Sanz-Alonso and Wang(2021)]{sanz2020bayesian}
D.~Sanz-Alonso and Z.~Wang.
\newblock Bayesian update with importance sampling: Required sample size.
\newblock \emph{Entropy}, 23\penalty0 (1):\penalty0 22, 2021.

\bibitem[{Sanz-Alonso} and Yang(2022)]{sanz2020spde}
D.~{Sanz-Alonso} and R.~Yang.
\newblock The {{SPDE}} approach to {{Mat{\'e}rn}} fields: Graph
  representations.
\newblock \emph{Statistical Science}, 37\penalty0 (4):\penalty0 519--540, 2022.
\newblock \doi{10.1214/21-STS838}.

\bibitem[{Sanz-Alonso} et~al.(2023){Sanz-Alonso}, Stuart, and
  Taeb]{sanz-alonso_inverse_2023}
D.~{Sanz-Alonso}, A.~Stuart, and A.~Taeb.
\newblock \emph{Inverse {{Problems}} and {{Data Assimilation}}}.
\newblock London {{Mathematical Society Student Texts}}. {Cambridge University
  Press}, {Cambridge}, 2023.
\newblock ISBN 978-1-00-941432-6.
\newblock \doi{10.1017/9781009414319}.

\bibitem[Sargsyan et~al.(2019)Sargsyan, Huan, and Najm]{sargsyan2019embedded}
K.~Sargsyan, X.~Huan, and H.~N. Najm.
\newblock {Embedded model error representation for Bayesian model calibration}.
\newblock \emph{International Journal for Uncertainty Quantification},
  9\penalty0 (4), 2019.

\bibitem[S{\"a}rkk{\"a}(2013)]{sarkka2013bayesian}
S.~S{\"a}rkk{\"a}.
\newblock \emph{{Bayesian Filtering and Smoothing}}, volume~3.
\newblock {Cambridge University Press}, 2013.

\bibitem[Sauer et~al.(1991)Sauer, Yorke, and Casdagli]{sauer_embedology_1991}
T.~Sauer, J.~A. Yorke, and M.~Casdagli.
\newblock Embedology.
\newblock \emph{Journal of Statistical Physics}, 65\penalty0 (3):\penalty0
  579--616, 1991.
\newblock \doi{10.1007/BF01053745}.

\bibitem[Schaden and Ullmann(2020)]{schaden_multilevel_2020}
D.~Schaden and E.~Ullmann.
\newblock On multilevel best linear unbiased estimators.
\newblock \emph{SIAM/ASA Journal on Uncertainty Quantification}, 8\penalty0
  (2):\penalty0 601--635, 2020.
\newblock \doi{10.1137/19M1263534}.

\bibitem[Scher and Messori(2021)]{scher_ensemble_2021}
S.~Scher and G.~Messori.
\newblock Ensemble methods for neural network-based weather forecasts.
\newblock \emph{Journal of Advances in Modeling Earth Systems}, 13\penalty0
  (2), 2021.
\newblock \doi{10.1029/2020MS002331}.

\bibitem[Schillings and Stuart(2017)]{schillings2017analysis}
C.~Schillings and A.~M. Stuart.
\newblock {Analysis of the ensemble Kalman filter for inverse problems}.
\newblock \emph{{SIAM Journal on Numerical Analysis}}, 55\penalty0
  (3):\penalty0 1264--1290, 2017.

\bibitem[Schillings and Stuart(2018)]{schillings2018convergence}
C.~Schillings and A.~M. Stuart.
\newblock {Convergence analysis of ensemble Kalman inversion: the linear, noisy
  case}.
\newblock \emph{Applicable Analysis}, 97\penalty0 (1):\penalty0 107--123, 2018.

\bibitem[Schmidhuber(2015)]{schmidhuber2015deep}
J.~Schmidhuber.
\newblock Deep learning in neural networks: An overview.
\newblock \emph{Neural Networks}, 61:\penalty0 85--117, 2015.

\bibitem[Sejdinovic et~al.(2013)Sejdinovic, Sriperumbudur, Gretton, and
  Fukumizu]{sejdinovic2013equivalence}
D.~Sejdinovic, B.~Sriperumbudur, A.~Gretton, and K.~Fukumizu.
\newblock {Equivalence of distance-based and RKHS-based statistics in
  hypothesis testing}.
\newblock \emph{The Annals of Statistics}, pages 2263--2291, 2013.

\bibitem[Silverman(2018)]{silverman2018density}
B.~W. Silverman.
\newblock \emph{Density Estimation for Statistics and Data Analysis}.
\newblock Routledge, 2018.

\bibitem[Sisson et~al.(2018)Sisson, Fan, and Beaumont]{sisson2018handbook}
S.~A. Sisson, Y.~Fan, and M.~Beaumont.
\newblock \emph{{Handbook of Approximate Bayesian Computation}}.
\newblock CRC Press, 2018.

\bibitem[Smola and Sch{\"o}lkopf(1998)]{smola1998learning}
A.~J. Smola and B.~Sch{\"o}lkopf.
\newblock \emph{Learning with Kernels}, volume~4.
\newblock Citeseer, 1998.

\bibitem[Snyder et~al.(2016)Snyder, Bengtsson, Bickel, and
  Anderson]{snyder2008obstacles}
C.~Snyder, T.~Bengtsson, P.~Bickel, and J.~L. Anderson.
\newblock Obstacles to high-dimensional particle filtering.
\newblock \emph{{Monthly Weather Review}}, 136\penalty0 (12):\penalty0
  4629--4640, 2016.

\bibitem[Soh and Chandrasekaran(2019)]{soh2019learning}
Y.~S. Soh and V.~Chandrasekaran.
\newblock Learning semidefinite regularizers.
\newblock \emph{Foundations of Computational Mathematics}, 19\penalty0
  (2):\penalty0 375--434, 2019.

\bibitem[Song et~al.(2021)Song, Sohl-Dickstein, Kingma, Kumar, Ermon, and
  Poole]{song2020score}
Y.~Song, J.~Sohl-Dickstein, D.~P. Kingma, A.~Kumar, S.~Ermon, and B.~Poole.
\newblock Score-based generative modeling through stochastic differential
  equations.
\newblock In \emph{International Conference on Learning Representations}, 2021.

\bibitem[Spantini et~al.(2022)Spantini, Baptista, and
  Marzouk]{spantini2022coupling}
A.~Spantini, R.~Baptista, and Y.~Marzouk.
\newblock Coupling techniques for nonlinear ensemble filtering.
\newblock \emph{SIAM Review}, 64\penalty0 (4):\penalty0 921--953, 2022.

\bibitem[Sprungk(2020)]{sprungk2020local}
B.~Sprungk.
\newblock {On the local Lipschitz stability of Bayesian inverse problems}.
\newblock \emph{Inverse Problems}, 36\penalty0 (5):\penalty0 055015, 2020.

\bibitem[Sriperumbudur et~al.(2011)Sriperumbudur, Fukumizu, and
  Lanckriet]{sriperumbudur2011universality}
B.~K. Sriperumbudur, K.~Fukumizu, and G.~R. Lanckriet.
\newblock {Universality, characteristic kernels and RKHS embedding of
  measures}.
\newblock \emph{Journal of Machine Learning Research}, 12\penalty0 (7), 2011.

\bibitem[Stroud and Bengtsson(2007)]{stroud2007sequential}
J.~R. Stroud and T.~Bengtsson.
\newblock {Sequential state and variance estimation within the ensemble Kalman
  filter}.
\newblock \emph{Monthly Weather Review}, 135\penalty0 (9):\penalty0 3194--3208,
  2007.

\bibitem[Stroud et~al.(2010)Stroud, Stein, Lesht, Schwab, and
  Beletsky]{stroud2010ensemble}
J.~R. Stroud, M.~L. Stein, B.~M. Lesht, D.~J. Schwab, and D.~Beletsky.
\newblock {An ensemble Kalman filter and smoother for satellite data
  assimilation}.
\newblock \emph{Journal of the American Statistical Association}, 105\penalty0
  (491):\penalty0 978--990, 2010.

\bibitem[Stroud et~al.(2018)Stroud, Katzfuss, and Wikle]{stroud2018bayesian}
J.~R. Stroud, M.~Katzfuss, and C.~K. Wikle.
\newblock {A Bayesian adaptive ensemble Kalman filter for sequential state and
  parameter estimation}.
\newblock \emph{Monthly Weather Review}, 146\penalty0 (1):\penalty0 373--386,
  2018.

\bibitem[Stuart and Teckentrup(2018)]{stuart2018posterior}
A.~Stuart and A.~Teckentrup.
\newblock {Posterior consistency for Gaussian process approximations of
  Bayesian posterior distributions}.
\newblock \emph{Mathematics of Computation}, 87\penalty0 (310):\penalty0
  721--753, 2018.

\bibitem[Stuart(2010)]{stuart2010inverse}
A.~M. Stuart.
\newblock {Inverse problems: a Bayesian perspective}.
\newblock \emph{{Acta Numerica}}, 19:\penalty0 451--559, 2010.

\bibitem[Sun and Bouman(2021)]{sun2020deep}
H.~Sun and K.~L. Bouman.
\newblock Deep probabilistic imaging: Uncertainty quantification and
  multi-modal solution characterization for computational imaging.
\newblock In \emph{Proceedings of the AAAI Conference on Artificial
  Intelligence}, volume~35, pages 2628--2637, 2021.

\bibitem[Sutter et~al.(2016)Sutter, Ganguly, and
  Koeppl]{sutter_variational_2016}
T.~Sutter, A.~Ganguly, and H.~Koeppl.
\newblock A variational approach to path estimation and parameter inference of
  hidden diffusion processes.
\newblock \emph{Journal of Machine Learning Research}, 17\penalty0
  (190):\penalty0 1--37, 2016.

\bibitem[Sutton et~al.(1999)Sutton, Barto, et~al.]{sutton1999reinforcement}
R.~S. Sutton, A.~G. Barto, et~al.
\newblock Reinforcement learning.
\newblock \emph{Journal of Cognitive Neuroscience}, 11\penalty0 (1):\penalty0
  126--134, 1999.

\bibitem[Sz{\'e}kely and Rizzo(2013)]{szekely_energy_2013}
G.~J. Sz{\'e}kely and M.~L. Rizzo.
\newblock Energy statistics: {{A}} class of statistics based on distances.
\newblock \emph{Journal of Statistical Planning and Inference}, 143\penalty0
  (8):\penalty0 1249--1272, 2013.
\newblock \doi{10.1016/j.jspi.2013.03.018}.

\bibitem[Tabak and Vanden-Eijnden(2010)]{tabak2010density}
E.~G. Tabak and E.~Vanden-Eijnden.
\newblock Density estimation by dual ascent of the log-likelihood.
\newblock \emph{Communications in Mathematical Sciences}, 8\penalty0
  (1):\penalty0 217--233, 2010.

\bibitem[Taghvaei and Hosseini(2022)]{taghvaei2022optimal}
A.~Taghvaei and B.~Hosseini.
\newblock {An optimal transport formulation of Bayes’ law for nonlinear
  filtering algorithms}.
\newblock In \emph{2022 IEEE 61st Conference on Decision and Control (CDC)},
  pages 6608--6613. IEEE, 2022.

\bibitem[Tandeo et~al.(2015)Tandeo, Pulido, and Lott]{tandeo2015offline}
P.~Tandeo, M.~Pulido, and F.~Lott.
\newblock {Offline parameter estimation using EnKF and maximum likelihood error
  covariance estimates: Application to a subgrid-scale orography
  parametrization}.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  141\penalty0 (687):\penalty0 383--395, 2015.

\bibitem[Tandeo et~al.(2020)Tandeo, Ailliot, Bocquet, Carrassi, Miyoshi,
  Pulido, and Zhen]{tandeo_review_2020}
P.~Tandeo, P.~Ailliot, M.~Bocquet, A.~Carrassi, T.~Miyoshi, M.~Pulido, and
  Y.~Zhen.
\newblock A review of innovation-based methods to jointly estimate model and
  observation error covariance matrices in ensemble data assimilation.
\newblock \emph{Monthly Weather Review}, 148\penalty0 (10):\penalty0
  3973--3994, 2020.
\newblock \doi{10.1175/MWR-D-19-0240.1}.

\bibitem[Tarantola(2015)]{tarantola2005inverse}
A.~Tarantola.
\newblock \emph{Inverse Problem Theory and Methods for Model Parameter
  Estimation}.
\newblock {SIAM}, 2015.

\bibitem[Thorey et~al.(2017)Thorey, Mallet, and Baudin]{thorey_online_2017}
J.~Thorey, V.~Mallet, and P.~Baudin.
\newblock Online learning with the continuous ranked probability score for
  ensemble forecasting.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  143\penalty0 (702):\penalty0 521--529, 2017.
\newblock \doi{10.1002/qj.2940}.

\bibitem[Tikhonov and Arsenin(1977)]{tikhonov1977solutions}
A.~N. Tikhonov and V.~Y. Arsenin.
\newblock \emph{{Solutions of Ill-posed Problems}}.
\newblock Washington, Winston \& Sons, 1977.

\bibitem[Tippett et~al.(2003)Tippett, Anderson, Bishop, Hamill, and
  Whitaker]{tippett2003ensemble}
M.~K. Tippett, J.~L. Anderson, C.~H. Bishop, T.~M. Hamill, and J.~S. Whitaker.
\newblock Ensemble square root filters.
\newblock \emph{Monthly Weather Review}, 131\penalty0 (7):\penalty0 1485--1490,
  2003.
\newblock \doi{10.1175/1520-0493(2003)131<1485:ESRF>2.0.CO;2}.

\bibitem[Trevisan and Uboldi(2004)]{trevisan_assimilation_2004}
A.~Trevisan and F.~Uboldi.
\newblock Assimilation of standard and targeted observations within the
  unstable subspace of the observation--analysis--forecast cycle system.
\newblock \emph{Journal of the Atmospheric Sciences}, 61\penalty0 (1):\penalty0
  103--113, 2004.
\newblock \doi{10.1175/1520-0469(2004)061<0103:AOSATO>2.0.CO;2}.

\bibitem[Tsiamis and Pappas(2023)]{tsiamis_online_2023}
A.~Tsiamis and G.~J. Pappas.
\newblock Online learning of the {{Kalman}} filter with logarithmic regret.
\newblock \emph{IEEE Transactions on Automatic Control}, 68\penalty0
  (5):\penalty0 2774--2789, 2023.
\newblock \doi{10.1109/TAC.2022.3207670}.

\bibitem[Tucker(1999)]{tucker1999lorenz}
W.~Tucker.
\newblock {The Lorenz attractor exists}.
\newblock \emph{Comptes Rendus de l'Acad{\'e}mie des Sciences - Series I -
  Mathematics}, 328\penalty0 (12):\penalty0 1197--1202, 1999.
\newblock \doi{10.1016/S0764-4442(99)80439-X}.

\bibitem[Tucker(2002)]{tucker2002rigorous}
W.~Tucker.
\newblock {A rigorous ODE solver and Smale’s 14th problem}.
\newblock \emph{Foundations of Computational Mathematics}, 2:\penalty0 53--117,
  2002.

\bibitem[Ueno and Nakamura(2014)]{ueno2014iterative}
G.~Ueno and N.~Nakamura.
\newblock Iterative algorithm for maximum-likelihood estimation of the
  observation-error covariance matrix for ensemble-based filters.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  140\penalty0 (678):\penalty0 295--315, 2014.

\bibitem[Ueno and Nakamura(2016)]{ueno2016bayesian}
G.~Ueno and N.~Nakamura.
\newblock Bayesian estimation of the observation-error covariance matrix in
  ensemble-based filters.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  142\penalty0 (698):\penalty0 2055--2080, 2016.

\bibitem[Uppala et~al.(2005)Uppala, K{\aa}llberg, Simmons, Andrae, Bechtold,
  Fiorino, Gibson, Haseler, Hernandez, Kelly, et~al.]{uppala2005era}
S.~M. Uppala, P.~K{\aa}llberg, A.~J. Simmons, U.~Andrae, V.~D.~C. Bechtold,
  M.~Fiorino, J.~Gibson, J.~Haseler, A.~Hernandez, G.~Kelly, et~al.
\newblock {The ERA-40 re-analysis}.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  131\penalty0 (612):\penalty0 2961--3012, 2005.
\newblock \doi{10.1256/qj.04.176}.

\bibitem[Vadeboncoeur et~al.(2023)Vadeboncoeur, Akyildiz, Kazlauskaite,
  Girolami, and Cirak]{vadeboncoeur2023fully}
A.~Vadeboncoeur, {\"O}.~D. Akyildiz, I.~Kazlauskaite, M.~Girolami, and
  F.~Cirak.
\newblock {Fully probabilistic deep models for forward and inverse problems in
  parametric PDEs}.
\newblock \emph{Journal of Computational Physics}, 491:\penalty0 112369, 2023.
\newblock \doi{10.1016/j.jcp.2023.112369}.

\bibitem[Vaughan et~al.(2024)Vaughan, Markou, Tebbutt, Requeima, Bruinsma,
  Andersson, Herzog, Lane, Hosking, and Turner]{vaughan_aardvark_2024}
A.~Vaughan, S.~Markou, W.~Tebbutt, J.~Requeima, W.~P. Bruinsma, T.~R.
  Andersson, M.~Herzog, N.~D. Lane, J.~S. Hosking, and R.~E. Turner.
\newblock Aardvark {{Weather}}: End-to-end data-driven weather forecasting.
\newblock \emph{arXiv preprint arXiv:2404.00411}, 2024.
\newblock \doi{10.48550/arXiv.2404.00411}.

\bibitem[Villani(2009)]{villani2009optimal}
C.~Villani.
\newblock \emph{Optimal Transport: Old and New}, volume 338.
\newblock Springer, 2009.

\bibitem[Vincent(2011)]{vincent2011connection}
P.~Vincent.
\newblock A connection between score matching and denoising autoencoders.
\newblock \emph{Neural Computation}, 23\penalty0 (7):\penalty0 1661--1674,
  2011.

\bibitem[Vishny et~al.(2024)Vishny, Morzfeld, Gwirtz, Bach, Dunbar, and
  Hodyss]{vishny_high-dimensional_2024}
D.~Vishny, M.~Morzfeld, K.~Gwirtz, E.~Bach, O.~R.~A. Dunbar, and D.~Hodyss.
\newblock High-dimensional covariance estimation from a small number of
  samples.
\newblock \emph{Journal of Advances in Modeling Earth Systems}, 16\penalty0
  (9):\penalty0 e2024MS004417, 2024.
\newblock \doi{10.1029/2024MS004417}.

\bibitem[Vogel(2002)]{vogel2002computational}
C.~R. Vogel.
\newblock \emph{{Computational Methods for Inverse Problems}}.
\newblock SIAM, 2002.

\bibitem[Von~Luxburg(2007)]{von2007tutorial}
U.~Von~Luxburg.
\newblock A tutorial on spectral clustering.
\newblock \emph{Statistics and Computing}, 17\penalty0 (4):\penalty0 395--416,
  2007.

\bibitem[Von~Luxburg et~al.(2008)Von~Luxburg, Belkin, and
  Bousquet]{von2008consistency}
U.~Von~Luxburg, M.~Belkin, and O.~Bousquet.
\newblock Consistency of spectral clustering.
\newblock \emph{The Annals of Statistics}, pages 555--586, 2008.

\bibitem[Vrettas et~al.(2011)Vrettas, Cornford, and
  Opper]{vrettas2011estimating}
M.~D. Vrettas, D.~Cornford, and M.~Opper.
\newblock {Estimating parameters in stochastic systems: A variational Bayesian
  approach}.
\newblock \emph{Physica D: Nonlinear Phenomena}, 240\penalty0 (23):\penalty0
  1877--1900, 2011.

\bibitem[Vrettas et~al.(2015)Vrettas, Opper, and
  Cornford]{vrettas2015variational}
M.~D. Vrettas, M.~Opper, and D.~Cornford.
\newblock Variational mean-field algorithm for efficient inference in large
  systems of stochastic differential equations.
\newblock \emph{Physical Review E}, 91\penalty0 (1):\penalty0 012148, 2015.

\bibitem[Wahba(1990)]{wahba1990spline}
G.~Wahba.
\newblock \emph{Spline Models for Observational Data}.
\newblock SIAM, 1990.

\bibitem[Wainwright et~al.(2008)Wainwright, Jordan,
  et~al.]{wainwright2008graphical}
M.~J. Wainwright, M.~I. Jordan, et~al.
\newblock Graphical models, exponential families, and variational inference.
\newblock \emph{Foundations and Trends{\textregistered} in Machine Learning},
  1\penalty0 (1--2):\penalty0 1--305, 2008.
\newblock \doi{10.1561/2200000001}.

\bibitem[Waller et~al.(2016)Waller, Dance, and
  Nichols]{waller_theoretical_2016}
J.~A. Waller, S.~L. Dance, and N.~K. Nichols.
\newblock Theoretical insight into diagnosing observation error correlations
  using observation-minus-background and observation-minus-analysis statistics.
\newblock \emph{Quarterly Journal of the Royal Meteorological Society},
  142\penalty0 (694):\penalty0 418--431, 2016.
\newblock \doi{10.1002/qj.2661}.

\bibitem[Wang et~al.(2023)Wang, Lei, Anderson, Tan, and
  Zhang]{wang_convolutional_2023}
Z.~Wang, L.~Lei, J.~L. Anderson, Z.-M. Tan, and Y.~Zhang.
\newblock Convolutional neural network-based adaptive localization for an
  ensemble {{Kalman}} filter.
\newblock \emph{Journal of Advances in Modeling Earth Systems}, 15\penalty0
  (10):\penalty0 e2023MS003642, 2023.
\newblock \doi{10.1029/2023MS003642}.

\bibitem[Wei and Tanner(1990)]{wei1990monte}
G.~C. Wei and M.~A. Tanner.
\newblock {A Monte Carlo implementation of the EM algorithm and the poor man's
  data augmentation algorithms}.
\newblock \emph{Journal of the American Statistical Association}, 85\penalty0
  (411):\penalty0 699--704, 1990.
\newblock \doi{10.2307/2290005}.

\bibitem[Wendland(2004)]{wendland2004scattered}
H.~Wendland.
\newblock \emph{Scattered Data Approximation}, volume~17.
\newblock Cambridge University Press, 2004.

\bibitem[Wiering and Van~Otterlo(2012)]{wiering2012reinforcement}
M.~A. Wiering and M.~Van~Otterlo.
\newblock Reinforcement learning.
\newblock \emph{Adaptation, Learning, and Optimization}, 12\penalty0
  (3):\penalty0 729, 2012.

\bibitem[Wikner et~al.(2021)Wikner, Pathak, Hunt, Szunyogh, Girvan, and
  Ott]{wikner_using_2021}
A.~Wikner, J.~Pathak, B.~R. Hunt, I.~Szunyogh, M.~Girvan, and E.~Ott.
\newblock Using data assimilation to train a hybrid forecast system that
  combines machine-learning and knowledge-based components.
\newblock \emph{Chaos: An Interdisciplinary Journal of Nonlinear Science},
  31\penalty0 (5):\penalty0 053114, 2021.
\newblock \doi{10.1063/5.0048050}.

\bibitem[Wilks(2019)]{wilks_statistical_2019}
D.~S. Wilks.
\newblock \emph{Statistical Methods in the Atmospheric Sciences}.
\newblock {Elsevier}, 4 edition, 2019.
\newblock ISBN 978-0-12-815823-4.
\newblock \doi{10.1016/C2017-0-03921-6}.

\bibitem[Williams and Rasmussen(2006)]{williams2006gaussian}
C.~K. Williams and C.~E. Rasmussen.
\newblock \emph{Gaussian Processes for Machine Learning}, volume~2.
\newblock MIT Press, Cambridge, MA, 2006.

\bibitem[Winkler et~al.(2019)Winkler, Worrall, Hoogeboom, and
  Welling]{winkler2019learning}
C.~Winkler, D.~Worrall, E.~Hoogeboom, and M.~Welling.
\newblock Learning likelihoods with conditional normalizing flows.
\newblock \emph{arXiv preprint arXiv:1912.00042}, 2019.

\bibitem[Wu et~al.(2024)Wu, Levine, Schneider, and Stuart]{wu2023learning}
J.-L. Wu, M.~E. Levine, T.~Schneider, and A.~Stuart.
\newblock Learning about structural errors in models of complex dynamical
  systems.
\newblock \emph{Journal of Computational Physics}, page 113157, 2024.
\newblock \doi{10.1016/j.jcp.2024.113157}.

\bibitem[Xiao et~al.(2023)Xiao, Bai, Xue, Chen, Han, and
  Ouyang]{xiao_fengwu-4dvar_2023}
Y.~Xiao, L.~Bai, W.~Xue, K.~Chen, T.~Han, and W.~Ouyang.
\newblock {{FengWu-4DVar}}: {{Coupling}} the data-driven weather forecasting
  model with {{4D}} variational assimilation.
\newblock \emph{arXiv preprint arXiv:2312.12455}, 2023.

\bibitem[Zellner(1988)]{zellner1988optimal}
A.~Zellner.
\newblock Optimal information processing and {Bayes's} theorem.
\newblock \emph{The American Statistician}, 42\penalty0 (4):\penalty0 278--280,
  1988.
\newblock \doi{10.2307/2685143}.

\bibitem[Zhang et~al.(2018)Zhang, B{\"u}tepage, Kjellstr{\"o}m, and
  Mandt]{zhang2018advances}
C.~Zhang, J.~B{\"u}tepage, H.~Kjellstr{\"o}m, and S.~Mandt.
\newblock Advances in variational inference.
\newblock \emph{IEEE Transactions on Pattern Analysis and Machine
  Intelligence}, 41\penalty0 (8):\penalty0 2008--2026, 2018.

\end{thebibliography}