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
Metadata
Release files for bayesnest 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bayesnest-1.0.0.tar.gz | 7.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bayesnest-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.1 kB
Release files / bayesnest-1.0.0.tar.gz
| Download URL | bayesnest-1.0.0.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7ddeae97c97a56de380eb23462a5f99fe797d1a490fdebcd76092aeb6c53130
|
|
BLAKE2b-256 checksum How to use checksums |
5f8665f231778e29cf9a849c48764beb9d57497c6ccbd0884f62b893cbe63a2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Release files / bayesnest-1.0.0-py3-none-any.whl
| Download URL | bayesnest-1.0.0-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f3a9c4251afec06e49c9824d481e995ac8ef74833b2decbc1bd6a535bc8bc4c0
|
|
BLAKE2b-256 checksum How to use checksums |
1afddf65f513cd7944dc9c1f05db4646bc01ffb062c928dd70b8d61dd0ec9d8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|