###### tags: `one-offs` `monte carlo` `variance reduction` `markov chains`
# Fitting Control Variates in MCMC
**Overview**: In this note, I describe two of the approaches to fitting control variates in Markov Chain Monte Carlo (MCMC), discussing the relative merits of the two. I also comment briefly on the analogous problem for Sequential Monte Carlo.
## The Options
When computing integrals using Markov Chain Monte Carlo (MCMC), it is often possible to reduce the variance of an estimator by the use of control variates. Perhaps surprisingly, the procedure of fitting the control variates for a given expectand can be done in a couple of ways, and this is not often discussed.
Suppose that the task is to estimate $\int\pi\left(\mathrm{d}x\right)f\left(x\right)$ by simulating a $\pi$-reversible Markov chain $P$, and one knows a priori that $\int\pi\left(\mathrm{d}x\right)h\left(x\right)=0$. One then fits a scalar $\beta$ such that $\tilde{f}:=f-\beta\cdot h$ is less variable than $f$ in a suitable sense. The setting of vector-valued $h$ and $\beta$ is a relatively straightforward extension, which for simplicity, I will not discuss here.
Two main strategies for fitting $\beta$ are:
1. Minimising the empirical variance of $\tilde{f}$, i.e. defining
\begin{align}
m\left(\beta\right) &=\frac{1}{T}\sum_{t\in\left[T\right]}\left\{ f\left(x_{t}\right)-\beta\cdot h\left(x_{t}\right)\right\} \\
s^{2}\left(\beta\right) &=\frac{1}{T-1}\sum_{t\in\left[T\right]}\left(f\left(x_{t}\right)-\beta\cdot h\left(x_{t}\right)-m\left(\beta\right)\right)^{2},
\end{align}
find the value of $\beta$ which minimises $s^{2}\left(\beta\right)$. This is a simple least-squares problem, but ignores the Markovian structure of the algorithm.
2. Minimising an estimate of the *asymptotic* variance of $\tilde{f}$, e.g.
\begin{align}
\pi\left(\tilde{f}\right)\approx\hat{m} &= \frac{1}{T}\sum_{t\in\left[T\right]}\tilde{f}\left(x_{t}\right) \\
\pi\left(\left(\tilde{f}-\pi\left(\tilde{f}\right)\right)\cdot P^{s}\left(\tilde{f}-\pi\left(\tilde{f}\right)\right)\right)\approx\hat{\rho}\left(s\right) &:= \frac{1}{T}\sum_{0<t\leqslant T-s}\left(\tilde{f}\left(x_{t}\right)-\hat{m}\right)\cdot\left(\tilde{f}\left(x_{t+s}\right)-\hat{m}\right) \\
\sigma^{2}\left(\tilde{f}\right)\approx\hat{\sigma^{2}}\left(\tilde{f}\right) &:= \hat{\rho}\left(0\right)+2\cdot\sum_{0<s\leqslant s_{*}}w\left(s\right)\cdot\hat{\rho}\left(s\right),
\end{align}
where $w$ is some 'windowing' or 'weight' function, typically taking values in $\left[0,1\right]$. This is again a least-squares problem for $\beta$, albeit a slightly more complicated one to form. Still, it has the benefit of acknowledging the autocorrelation structure of the underlying MCMC algorithm, and thus should asymptotically find more accurate solutions.
The papers which I have seen indicate that the second strategy is preferable, sometimes substantially. So, there is something to be gained from harnessing the structure of the sampler.
A parting comment: it seems to be rare to use control variates in Sequential Monte Carlo (SMC). It is clear that the first strategy adapts to SMC reasonably easily, but an analog of the second (i.e. a structured variance estimator) is more complex; until recently, it was not actually known how to form efficient 'internal' variance estimators for SMC. It would be interesting to see how much benefit there is to these refined estimators in this context.

Overview: In this note, I log some basic observations about diffusion-based generative models.

8/14/2023Overview: In this note, I describe some aspects of hierarchical structure in MCMC algorithms, and how they can be of theoretical and practical relevance.

8/9/2023Overview: In this note, I discuss a recurrent question which can be used to generate research questions about methods of all sorts. I then discuss a specific instance of how this question has proved fruitful in the theory of optimisation algorithms. Methods and Approximations A nice story is that when Brad Efron derived the bootstrap, it was done in service of the question “What is the jackknife an approximation to?”. I can't help but agree that there's something quite exciting about research questions which have this same character of ''What is (this existing thing) an approximation to?''. One bonus tilt on this which I appreciate is that there can be multiple levels of approximation, and hence many answers to the same question. One well-known example is gradient descent, which can be viewed as an approximation to the proximal point method, which can then itself be viewed as an approximation to a gradient flow. There are probably even more stops along the way here. In this case, there is even the perspective that from the perspective of mathematical theory, there may be at least as much to be gained by stopping off at the proximal point interpretation, as there is from the gradient flow perspective. My experience is that generalist applied mathematicians get to grips with the gradient flow quickly, but optimisation theorists can squeeze more out of the PPM formulation. There is thus some hint that using this 'intermediate' approximation can be particularly insightful in its own right. It would be interesting to collect more examples with this character.

5/22/2023Overview: In this note, I prove Hoeffding's inequality from the perspectives of martingales and convex ordering. The Basic Construction Let $-\infty<a<x<b<\infty$, and define a random variable $M$ with law $M\left(x;a,b\right)$ by \begin{align} M=\begin{cases} a & \text{w.p. }\frac{b-x}{b-a}\ b & \text{w.p. }\frac{x-a}{b-a}. \end{cases}

5/22/2023
Published on ** HackMD**

or

By clicking below, you agree to our terms of service.

Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet

Wallet
(
)

Connect another wallet
New to HackMD? Sign up