Note
Go to the end to download the full example code
Approximate Control Variate Monte Carlo
This tutorial builds upon Two model Approximate Control Variate Monte Carlo, Multi-level Monte Carlo, and Multi-fidelity Monte Carlo. MLMC and MFMC are two approaches which can utilize an ensemble of models of vary cost and accuracy to efficiently estimate the expectation of the highest fidelity model. In this tutorial we introduce a general framework for ACVMC when using two or more models to estimate vector-valued statistics.
The approximate control variate estimator of a vector-valued statistic
or in more compact notation
where the entries of
Here
This estimator is constructed by evaluating each model at two sets of samples
For any
The control variate weights that minimize the determinant of the ACV estimator covariance are
The ACV estimator covariance using the optimal control variate weights is
Computing the ACV estimator covariance requires computing
First
and second
where
When estimating the statistics in Monte Carlo Quadrature: Beyond Mean Estimation the above coavariances involving
The variance of an ACV estimator is dependent on how samples are allocated to the sets
Here,
is smaller than a user-specified computational budget
Unfortunately, to date, no method has been devised to solve the above optimization problem for all possible allocations
An entry of one indicates in the ith row of the jth column indicates that the ith independent partition
Once an allocation matrix is specified, the optimal sample allocation can be obtained by optimizing the number of samples in each partition
The following tutorials introduce different ACV methods and their allocation matrices that have been introduced in the literature.
The following compares the estimator variances of three different ACV estimators. No one estimator type is best for all problems. Consequently for any given problem all possible estimators should be constructed. This requires estimates of the model covariance using a pilot study see Pilot Studies
import numpy as np
import matplotlib.pyplot as plt
from pyapprox.util.visualization import mathrm_labels
from pyapprox.benchmarks import setup_benchmark
from pyapprox.multifidelity.factory import (
get_estimator, compare_estimator_variances, multioutput_stats)
from pyapprox.multifidelity.visualize import (
plot_estimator_variance_reductions)
np.random.seed(1)
benchmark = setup_benchmark("polynomial_ensemble")
model = benchmark.fun
cov = model.get_covariance_matrix()
nmodels = cov.shape[0]
target_costs = np.array([1e2], dtype=int)
costs = np.asarray([10**-ii for ii in range(nmodels)])
model_labels = [r'$f_0$', r'$f_1$', r'$f_2$', r'$f_3$', r'$f_4$']
stat = multioutput_stats["mean"](benchmark.nqoi)
stat.set_pilot_quantities(cov)
estimators = [
get_estimator("mlmc", stat, costs),
get_estimator("mfmc", stat, costs),
get_estimator("gmf", stat, costs,
recursion_index=np.zeros(nmodels-1, dtype=int))]
est_labels = mathrm_labels(["MLMC", "MFMC", "ACVMF"])
optimized_estimators = compare_estimator_variances(
target_costs, estimators)
axs = [plt.subplots(1, 1, figsize=(8, 6))[1]]
# get estimators for target cost = 100
ests_100 = [ests[0] for ests in optimized_estimators]
_ = plot_estimator_variance_reductions(
ests_100, est_labels, axs[0])

Video
Click on the image below to view a video tutorial on approximate control variate Monte Carlo quadrature

Total running time of the script: ( 0 minutes 0.345 seconds)