# Control Variates

Control variates offer a method to reduce the variance of Monte Carlo approximations under certain situations. Suppose we want to estimate \(\mu = \mathbb{E}[\varphi(x)] = \int \varphi(x)\pi(x) \: dx\) and we have some unbiased estimator \(\hat{\mu}(\mathcal{X}) = \frac{1}{N}\sum_{x_s \in \mathcal{X}} f(x_s)\), i.e. \(\mathbb{E}[\hat{\mu}]=\mu\) and \(x_n \sim \pi(x)\), with \(\mathcal{X} = \{x_1,\cdots,x_N\}\).

The estimator \(\hat{\mu}^*(\mathcal{X}) = \hat{\mu}(\mathcal{X}) + c(b(\mathcal{X}) - \mathcal{E}[b(\mathcal{X})])\) is called a **control variate**, and \(b\) is called a baseline. Note that \(\mathbb{E}[\hat{\mu}^*] = \mu\) as well, but can have lower variance if the baseline \(b\) is correlated with the original estimator \(\hat{\mu}\). To see this, apply the variance operator to \(\hat{\mu}^*\):
\[
\mathbb{V}[\hat{\mu}^*(\mathcal{X})] = \mathbb{V}[\hat{\mu}(\mathcal{X})] + c^2\mathbb{V}[\hat{\mu}^*(\mathcal{X})] + 2c\text{Cov}[\hat{\mu}(\mathcal{X}),\hat{\mu}^*(\mathcal{X})]\].

As a function of \(c\), the right hand side is minimized when \(c = -\frac{\text{Cov}[\hat{\mu}(\mathcal{X}),\hat{\mu}^*(\mathcal{X})]}{\mathbb{V}[\hat{\mu}^*(\mathcal{X})]}\). Plugging this gives the variance of the control variate as \(\mathbb{V}[\hat{\mu}^*(\mathcal{X})] = (1 - \rho_{\hat{\mu}, b}^2)\mathbb{V}[\hat{\mu}(\mathcal{X})]\) where \(\rho_{\hat{\mu},b} \in [-1,1]\) is the correlation between \(\hat{\mu}\) and \(b\), showing that the more \(b\) is correlated with \(\hat{\mu}\), the better the variance reduction.