gemlib.abc.abc_rejection_sampler#
- gemlib.abc.abc_rejection_sampler(accept_fn, num_samples, model, key)#
Approximate Bayesian Computation rejection sampler
- Parameters:
accept_fn (Callable[[PyTree], Array]) – Python callable which takes a batch of samples from model and returns a boolean array of shape num_samples to keep. Any tolerance/threshold logic is responsibility of accept_fn.
num_samples (int) – total number of samples
model (JointDistribution) – a tfd.JointDistribution to draw proposal from
key (Array) – a PRNG key
- Returns:
A tuple of (posterior, acceptance_rate).
- Return type:
tuple[PyTree, float]