Multivariate control variates (source code)

= Multivariate control variates
{title2=$\beta_*=\Sigma^{-1}\operatorname{Cov}(C,Y)$}

If $Y$ is an unbiased estimator and a vector $C$ has known mean, then $Y-\beta^T(C-\mathbb EC)$ remains unbiased for a deterministic coefficient vector. Its variance is $\operatorname{Var}Y-2\beta^T c+\beta^T\Sigma\beta$, where $c=\operatorname{Cov}(C,Y)$ and $\Sigma=\operatorname{Cov}(C)$. For invertible $\Sigma$, completing the square gives the displayed optimum and minimum variance $\operatorname{Var}Y-c^T\Sigma^{-1}c$. With singular $\Sigma$, use a generalized inverse on its range. Estimating coefficients from the same simulation can introduce finite-sample bias; fixed pilot coefficients or independent training preserve the elementary unbiasedness assertion.