
Get (or build and cache) the surrogate potential behind an MCMC posterior
Source:R/nle_posterior.R
cached_surrogate_potential.Rdsurrogate_potential() standardizes x_obs and lets the estimator
precompute whatever it can from the observation alone (see its own docs) –
work meant to be paid once per observation, not once per evaluation.
slice_sample_surrogate() already gets this for free because it builds the
closure once and calls it for every MCMC step of a whole chain, but
mcmc_log_prob() used to rebuild the closure on every single log_prob()
call. That is expensive on its own, and ruinous for map_estimate(), whose
optimizer calls log_prob() once per evaluation against the same x_obs
(#272). The closure is cached here on the posterior's cache environment and
only rebuilt when x_obs or max_batch changes.
Arguments
- post
An
nsbi_mcmc_posteriorobject.- x_obs
The (already resolved) observation to condition on.
- max_batch
Largest batch size to pass to
surrogate_potential().