Sampling the likelihood surrogate

BOBE provides interfaces for nested sampling via Dynesty and HMC using NUTS from NumPyro. These are used for sampling the Gaussian Process surrogate of the likelihood function to calculate the evidence or generate posterior samples.

Nested Sampling

Nested sampling using Dynesty for evidence computation and posterior sampling.

BOBE.samplers.nested_sampling_Dy(gp, mode='acq', ndim=1, dlogz=0.1, dynamic=False, maxcall=5000000, print_progress=True, equal_weights=False, sample_method='rwalk', rng=None)[source]

Nested Sampling using Dynesty

Parameters:
  • gp (GP) – Gaussian Process model

  • ndim (int) – Number of dimensions

  • dlogz (float) – Log evidence goal

  • dynamic (bool) – Use dynamic nested sampling, see Dynesty documentation for more details

  • logz_std (bool) – Compute the upper and lower bounds on logZ using the GP uncertainty

  • maxcall (Optional[int]) – Maximum number of function calls

  • boost_maxcall (int) – Boost the maximum number of function calls

  • print_progress (Optional[bool]) – Print progress of the nested sampling run. If None, automatically disables progress printing in cluster environments and enables it otherwise.

  • equal_weights (bool) – Resample to obtain equal weights

  • sample_method (str) – Sampling method for dynesty

  • rng (random number generator) – Random number generator

Return type:

tuple[ndarray, Dict, bool]

Returns:

  • samples (ndarray) – Equally weighted samples from the nested sampler

  • logz_dict (dict) – Dictionary containing the mean, upper and lower bounds on logZ and the logZ error from the nested sampler

  • success (bool) – Whether the nested sampling run was successful

HMC/NUTS Sampling

Hamiltonian Monte Carlo sampling using NumPyro’s NUTS sampler.

BOBE.samplers.sample_GP_NUTS(gp, np_rng=None, rng_key=None, num_chains=4, temp=1.0, **kwargs)[source]

Obtain samples from the posterior represented by the GP mean as the logprob. This is a unified function that works for both GP and GPwithClassifier.

Parameters:
  • gp (Union[GP, GPwithClassifier]) – The Gaussian Process model to sample from.

  • np_rng (np.random.Generator, optional) – NumPy random number generator. Default is None.

  • rng_key (jax.random.PRNGKey, optional) – JAX random key. Default is None.

  • num_chains (int, optional) – Number of parallel HMC chains. Default is 4.

  • temp (float, optional) – Temperature parameter for tempering. Default is 1.0.

  • **kwargs (dict) –

    Additional keyword arguments. Can include: - warmup_steps : int, optional

    Number of warmup steps for HMC. If not provided, defaults based on dimensionality.

    • num_samplesint, optional

      Number of samples to draw from each chain. If not provided, defaults based on dimensionality.

    • thinningint, optional

      Thinning factor for samples. If not provided, defaults to 4.

    • dense_massbool, optional

      Whether to use dense mass matrix in NUTS. Default is True.

    • max_tree_depthint, optional

      Maximum tree depth for NUTS. Default is 6.

Returns:

samples_dict – Dictionary containing: - ‘x’: samples array of shape (num_chains * num_samples / thinning, ndim) - ‘logp’: log probabilities for each sample - ‘best’: best sample found - ‘method’: ‘MCMC’

Return type:

dict

Utility Functions

BOBE.samplers.compute_integrals(logl=None, logvol=None, reweight=None, squared=False)[source]
BOBE.samplers.prior_transform(x)[source]