Skip to content

A set of interfaces to use discovery with different samplers. The package works on a common framework for setting priors by defining them in a dictionary. This is designed to eventually be added to discovery in the "samplers" submodule.

Notifications You must be signed in to change notification settings

jonaselgammal/discoverysamplers

Repository files navigation

discoverysamplers

Bridge interfaces connecting Discovery models to various sampling algorithms.

Documentation Status License: MIT Tests

Author Jonas El Gammal
Source Source code on GitHub
Documentation Documentation on Read the Docs
License MIT
Support For questions, use GitHub Issues or drop me an email
Installation Clone from GitHub

Overview

discoverysamplers provides lightweight wrappers that adapt Discovery-style models to the APIs expected by different sampling backends.

Supported Samplers

Sampler Type Description
Eryn MCMC Ensemble MCMC with parallel tempering and reversible-jump support
Nessai Nested Sampling Flow-based nested sampling with importance sampling
JAX-NS Nested Sampling Pure JAX nested sampling with GPU support
GPry GP Emulation Gaussian process surrogate model via Cobaya framework

Installation

git clone https://github.com/jonaselgammal/discoverysamplers.git
cd discoverysamplers
pip install .

Quick Example

from discoverysamplers import DiscoveryNessaiBridge

# Define model and priors
def model(params):
    return -0.5 * (params['x']**2 + params['y']**2)

priors = {
    'x': ('uniform', -5.0, 5.0),
    'y': ('uniform', -5.0, 5.0),
}

# Run sampler
bridge = DiscoveryNessaiBridge(model, priors)
results = bridge.run_sampler(nlive=1000, output='output/')

Usage

MCMC with Eryn

from discoverysamplers import DiscoveryErynBridge

bridge = DiscoveryErynBridge(model, priors)
bridge.create_sampler(nwalkers=32)
bridge.run_sampler(nsteps=10000)
samples = bridge.return_all_samples()

Nested Sampling with JAX-NS

from discoverysamplers import DiscoveryJAXNSBridge

bridge = DiscoveryJAXNSBridge(model, priors)
results = bridge.run_sampler(nlive=1000, rng_seed=42)

Prior Specification

priors = {
    'mass': ('uniform', 1.0, 3.0),
    'distance': ('loguniform', 0.1, 100.0),
    'phase': ('normal', 0.0, 1.0),
    'fixed_param': ('fixed', 1.0),
}

Citation

@software{discoverysamplers,
  author = {El Gammal, Jonas},
  title = {discoverysamplers: Tools for Bayesian inference with Discovery},
  year = {2025},
  url = {https://github.com/jonaselgammal/discoverysamplers}
}

License

MIT License - see LICENSE for details.

About

A set of interfaces to use discovery with different samplers. The package works on a common framework for setting priors by defining them in a dictionary. This is designed to eventually be added to discovery in the "samplers" submodule.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published