Acquisition Functions#
- class pyvbmc.acquisition_functions.AbstractAcqFcn[source]#
Bases:
ABC
Abstract acquisition function for VBMC.
- __call__(Xs: ndarray, gp: GP, vp: VariationalPosterior, function_logger: FunctionLogger, optim_state: dict)[source]#
Calculate the acquisition function for the given inputs.
- Parameters:
- Xsnp.ndarray
Input points.
- gpgpr.GP
The GaussianProcess of the VBMC instance this function is called from.
- vpVariationalPosterior
The VariationalPosterior of the VBMC instance this function is called from.
- function_loggerFunctionLogger
The FunctionLogger of the VBMC instance this function is called from.
- optim_statedict
The optim_state of the VBMC instance this function is called from.
- Returns:
- acqnp.ndarray
The output of the acquisition function, shape
(N,)
whereN
is the number of input points.
- class pyvbmc.acquisition_functions.AcqFcn[source]#
Bases:
AbstractAcqFcn
Acquisition function for prospective uncertainty search.
- class pyvbmc.acquisition_functions.AcqFcnIMIQR(quantile=0.75)[source]#
Bases:
AbstractAcqFcn
Integrated Median Interquantile Range (IMIQR) acquisition function.
Approximates the Integrated Median Interquantile Range (IMIQR) via importance samples from the GP surrogate.
- is_log_added(**kwargs)[source]#
Importance sampling proposal log density, added part.
The added term in the importance sampling proposal log density: The full proposal log density is
is_log_full = is_log_base + is_log_added
. Added part for VIQR/IMIQR is :math: \log [\sinh(u * f_s)]`, wheref_s
is the GP predictive variance at the input points.- Parameters:
- f_s2np.ndarray
The predicted posterior variance at the points of interest.
- Returns:
- ynp.ndarray
The added log density term at the points of interest.
- is_log_base(x, **kwargs)[source]#
Importance sampling proposal log density, base part.
The base density of the importance sampling proposal distribution, used for computing i.s. weights (in addition to the full proposal density). The full proposal log density is
is_log_full = is_log_base + is_log_added
. IMIQR approximates an expectation w.r.t. to the (exponentiated) GP using importance sampling, so this base log density is the GP mean,f_mu
.- Parameters:
- f_munp.ndarray
The gp posterior mean at the points of interest.
- Returns:
- f_munp.ndarray
The log density of the target against which the i.s. expectation is taken. Here, just the log density as modeled by the GP.
- is_log_full(x, **kwargs)[source]#
Importance sampling full proposal log density.
The full proposal log density, used for MCMC sampling:
is_log_full = is_log_base + is_log_added
.- Parameters:
- f_munp.ndarray
The gp posterior mean at the points of interest. Either [
f_s2
andf_mu
] orgp
must be provided.- f_s2np.ndarray, optional
The predicted posterior variance at the points of interest. Either [
f_s2
andf_mu
] orgp
must be provided.- gpgpyreg.GaussianProcess, optional
The GP modeling the log-density. Either [
f_s2
andf_mu
] orgp
must be provided.
- Returns:
- ynp.ndarray
The full log density of the importance sampling proposal distribution at the points of interest. Of the same shape as
f_s2
.
- Raises:
- ValueError
If [
f_s2
orf_mu
] are not provided, andgp
is not provided.
- class pyvbmc.acquisition_functions.AcqFcnLog[source]#
Bases:
AbstractAcqFcn
Acquisition function for prospective uncertainty search (log-valued).
- class pyvbmc.acquisition_functions.AcqFcnNoisy[source]#
Bases:
AbstractAcqFcn
Acquisition function for noisy prospective uncertainty search.
- class pyvbmc.acquisition_functions.AcqFcnVIQR(quantile=0.75)[source]#
Bases:
AbstractAcqFcn
Variational Interquantile Range (VIQR) acquisition function.
Approximates the Integrated Median Interquantile Range (IMIQR) by simple Monte Carlo using samples from the Variational Posterior.
- is_log_added(**kwargs)[source]#
Importance sampling proposal log density, added part.
The added term in the importance sampling proposal log density: The full proposal log density is
is_log_full = is_log_base + is_log_added
. Added part for VIQR/IMIQR is :math: \log [\sinh(u * f_s)]`, wheref_s
is the GP predictive variance at the input points.- Parameters:
- f_s2np.ndarray
The predicted posterior variance at the points of interest.
- Returns:
- ynp.ndarray
The added log density term at the points of interest. Of the same shape as
f_s2
.
- is_log_base(x, **kwargs)[source]#
Importance sampling proposal log density, base part.
The base density of the importance sampling proposal distribution, used for computing i.s. weights (in addition to the full proposal density). The full proposal log density is
is_log_full = is_log_base + is_log_added
. VIQR approximates an expectation w.r.t. to the VP using simple Monte Carlo, so this base density is constant (log=0).- Parameters:
- xnp.ndarray
The input points, shape
(N, D)
whereN
is the number of points andD
is the dimension.- f_s2np.ndarray
The predicted posterior variance at the points of interest.
- Returns:
- znp.ndarray
The log base part of the importance sampling weights (zeros), shape
f_s2
.
- is_log_full(x, **kwargs)[source]#
Importance sampling full proposal log density.
The full proposal log density, used for MCMC sampling:
is_log_full = is_log_base + is_log_added
.- Parameters:
- f_s2np.ndarray, optional
The predicted posterior variance at the points of interest. Either
f_s2
orgp
must be provided.- gpgpyreg.GaussianProcess, optional
The GP modeling the log-density. Either
f_s2
orgp
must be provided.
- Returns:
- ynp.ndarray
The full log density of the importance sampling proposal distribution at the points of interest. Of the same shape as
f_s2
.
- Raises:
- ValueError
If neither
f_s2
norgp
are provided.
- class pyvbmc.acquisition_functions.AcqFcnVanilla[source]#
Bases:
AbstractAcqFcn
Acquisition function via vanilla uncertainty sampling.