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 multimodal and non-Gaussian posteriors. It includes both naive rejection sampling and ellipsoidal constrained sampling (inspired by MultiNest), and computes both posterior samples and Bayesian model evidence.


Features

  • Log-space evidence computation (numerically stable)
  • Posterior sampling with log-weights
  • Support for multimodal inference via ellipsoidal sampling
  • Corner plot visualization of posteriors
  • Convergence diagnostics for log-evidence
  • Simple, extensible Python codebase

Installation

From PyPI (after publishing):

pip install bayesnest

Example: Linear Gaussian Model

Once installed, you can run the examples found in the github repo

python examples/linear_gaussian_example.py

This will:

  • Simulate data from a linear Gaussian model

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

  • Print the posterior mean and log evidence

  • Generate a 2D corner plot of the posterior

  • Show the evolution of the log-evidence estimate over iterations

Example: Multimodal Posterior

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

python examples/multimodal_example.py

This example will:

  • Define a 2D likelihood with two disjoint Gaussian peaks

  • Sample using ellipsoidal decomposition

  • Reveal both modes in the posterior

  • Demonstrate ellpisoid 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 being integrated

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-0.1.3.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

bayesnest-0.1.3-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bayesnest-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7e50d126fc7ce4589b3e8d3a9806239495b938ba09680c3ef9c51f0532278958
MD5 7fae63fd53aa8700a12d469ed045bc7b
BLAKE2b-256 aec5b742be0012a888998eaad38be90fe0e36b5c59b97bc6602fd0e6bd736f7a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for bayesnest-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f00833d7372d45a009d7aed4f7b09ad282ea533d9ef4066c760d83ecc9d9bd5e
MD5 549dc9647bd00c6639ef3033586b61b3
BLAKE2b-256 9dd9c4a198f93b5d69b35e53c02a42818cb1ae19944c39909ba8c4852ddfd4f0

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