Skip to main content

Lightweight log-space nested sampling for Bayesian inference

Project description

BayesNest

BayesNest is a lightweight, log-space nested sampler for Bayesian inference, supporting complex posterior structures including multimodal, curved, and non-Gaussian distributions. It supports multiple constrained sampling strategies including:

  • Naive rejection sampling
  • Ellipsoidal sampling (MultiNest-style)
  • MCMC-constrained sampling
  • Slice sampling
  • Diffusive sampling (tempered MCMC)

BayesNest computes both posterior samples and Bayesian model evidence


Features

  • Log evidence computation
  • Posterior sampling with log-weights
  • Support for multimodal and curved posteriors
  • Corner plot visualization of parameter distributions
  • Multiple constrained samplers (uniform, ellipsoid, mcmc, slice, diffusive)
  • Convergence diagnostics via log-evidence trace plots
  • Minimal, dependency-light design

Installation

pip install bayesnest

Examples

All examples are located in the examples/ directory of the repo.

1: Linear Gaussian Model

python examples/linear_gaussian_example.py

This example:

  • Simulates data from a linear Gaussian model y = ax + b + noise

  • Use nested sampling to estimate the posterior distribution over slope a and intercept b

  • Print the posterior mean and log evidence

  • Generate a 2D corner plot of the posterior distribution plot

  • Plots the convergence of the log-evidence estimate

2: Multimodal Posterior

A synthetic example with two separated Gaussian modes is also found in the github repo

python examples/multimodal_example.py

This synthetic example defines a 2D likelihood with two well-separated Gaussian peaks and:

  • Sample using ellipsoidal decomposition

  • Reveal both modes clearly in the posterior distribution plot

  • Demonstrate ellipsoid nested sampling’s strength in handling multimodal distributions

Expected output:

  • A bimodal posterior in the corner plot

  • A log-evidence trace that reflects both modes properly being integrated

3: Rosenbrock

python examples/rosenbrock_example.py

This classic benchmark stresses the sampler with a narrow, curved valley in 5D.

  • Uses slice sampling to effectively explore curved likelihood regions
  • Computes posterior samples and log-evidence
  • Generates a pairwise corner plot

Expected output:

  • The expected 2D plot between theta_0 and theta_1 should show a tight, curved valley, starting from -1 to 1
  • Posterior mean near theta_i = 1 for all i

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bayesnest-1.0.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bayesnest-1.0.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file bayesnest-1.0.0.tar.gz.

File metadata

  • Download URL: bayesnest-1.0.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for bayesnest-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b7ddeae97c97a56de380eb23462a5f99fe797d1a490fdebcd76092aeb6c53130
MD5 c3fcf3ea4ac6bbed4509fa89223add8c
BLAKE2b-256 5f8665f231778e29cf9a849c48764beb9d57497c6ccbd0884f62b893cbe63a2c

See more details on using hashes here.

File details

Details for the file bayesnest-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: bayesnest-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for bayesnest-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3a9c4251afec06e49c9824d481e995ac8ef74833b2decbc1bd6a535bc8bc4c0
MD5 5bb108127e5f1cbd7cfb7fc75ef79735
BLAKE2b-256 1afddf65f513cd7944dc9c1f05db4646bc01ffb062c928dd70b8d61dd0ec9d8a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page