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
aand interceptb -
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7ddeae97c97a56de380eb23462a5f99fe797d1a490fdebcd76092aeb6c53130
|
|
| MD5 |
c3fcf3ea4ac6bbed4509fa89223add8c
|
|
| BLAKE2b-256 |
5f8665f231778e29cf9a849c48764beb9d57497c6ccbd0884f62b893cbe63a2c
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3a9c4251afec06e49c9824d481e995ac8ef74833b2decbc1bd6a535bc8bc4c0
|
|
| MD5 |
5bb108127e5f1cbd7cfb7fc75ef79735
|
|
| BLAKE2b-256 |
1afddf65f513cd7944dc9c1f05db4646bc01ffb062c928dd70b8d61dd0ec9d8a
|