Skip to main content

UltraNest

Fit and compare complex models reliably and rapidly with advanced sampling techniques.

https://img.shields.io/pypi/v/ultranest.svg https://circleci.com/gh/JohannesBuchner/UltraNest/tree/master.svg?style=shield Documentation Status Github repository Software paper

Correctness. Speed. Ease of use. 🦔

About

When scientific models are compared to data, two tasks are important: 1) contraining the model parameters and 2) comparing the model to other models. Different techniques have been developed to explore model parameter spaces. This package implements a Monte Carlo technique called nested sampling.

Nested sampling allows Bayesian inference on arbitrary user-defined likelihoods. In particular, posterior probability distributions on model parameters are constructed, and the marginal likelihood (“evidence”) Z is computed. The former can be used to describe the parameter constraints of the data, the latter can be used for model comparison (via Bayes factors) as a measure of the prediction parsimony of a model.

In the last decade, multiple variants of nested sampling have been developed. These differ in how nested sampling finds better and better fits while respecting the priors (constrained likelihood prior sampling techniques), and whether it is allowed to go back to worse fits and explore the parameter space more.

This package develops novel, advanced techniques for both (See How it works). They are especially remarkable for being free of tuning parameters and theoretically justified. Beyond that, UltraNest has support for Big Data sets and high-performance computing applications.

UltraNest is intended for fitting complex physical models with slow likelihood evaluations, with one to hundreds of parameters. UltraNest intends to replace heuristic methods like multi-ellipsoid nested sampling and dynamic nested sampling with more rigorous methods. UltraNest also attempts to provide feature parity compared to other packages (such as MultiNest).

You can help by testing UltraNest and reporting issues. Code contributions are welcome. See the Contributing page.

Features

  • Pythonic

    • pip and conda installable

    • Easy to program for: Sanity checks with meaningful errors

    • Can control the run programmatically and check status

    • Reasonable defaults, but customizable

    • Thoroughly tested with many unit and integration tests

    • NEW: supports likelihood functions written in Python, C, C++, Fortran, Julia and R

  • Robust exploration easily handles:

    • Degenerate parameter spaces such as bananas or tight correlations

    • Multiple modes/solutions in the parameter space

    • Robust, parameter-free MLFriends algorithm (metric learning RadFriends, Buchner+14,+19), with new improvements (region follows new live points, clustering improves metric iteratively, NEW in v4.0: refined local metric).

    • High-dimensional problems with hit-and-run sampling

    • Wrapped/circular parameters, derived parameters

    • Fast-slow parameters

  • Lightweight and fast

  • Advanced visualisation and crash recovery:

    • Live view of the exploration for Jupyter notebooks and terminals

    • Publication-ready visualisations

    • Corner plots, run and parameter exploration diagnostic plots

    • Checkpointing and resuming, even with different number of live points

    • Warm-start: resume from modified data / model

  • strategic nested sampling

    • can vary (increase) number of live points (akin to dynamic nested sampling, but with different targets)

    • can sample clusters optimally (e.g., at least 50 points per cluster/mode/solution)

    • can target minimizing parameter estimation uncertainties

    • can target a desired evidence uncertainty threshold

    • can target a desired number of effective samples

    • or any combination of the above

    • Robust ln(Z) uncertainties by bootstrapping live points.

Usage

Licence

How to cite UltraNest.

GPLv3 (see LICENCE file). If you require another license, please contact me.

The cute hedgehog icon was made by Freepik. It symbolises UltraNest’s approach of carefully walking up a likelihood, ready to defend against any encountered danger.

Contributors

Release Notes

4.4.0 (2024-12-13)

  • Compatible with numpy version 2 and above. Any remaining errors like “ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject” are due to ultranest and numpy being installed with different versions. Reinstall numpy and ultranest in that case.

4.3.0 (2024-04-12)

  • added ultranest.popstepsampler.PopulationSimpleSliceSampler: Vectorized, fixed-batch size slice sampler. (PR by Benjamin Beauchesne)

  • validation of passed parameter names (PR by svaverbe)

  • documentation improvements, including documenting results dictionary (PR by Jacopo Tissino)

  • make scipy actually optional (PR by Matthew Kirk)

  • linting

4.2.0 (2024-02-15)

  • new ultranest.mlfriends.LocalAffineLayer for metric learning, set as default (see issue 124)

  • add Highest Density Interval function (ultranest.plot.highest_density_interval_from_samples)

  • corner plot style with higher signal-to-ink ratio.

  • bug fixes in popstepsampler

4.1.0 (2024-02-15)

  • add number of steps calibrator ultranest.calibrator.ReactiveNestedCalibrator

  • add relative jump distance diagnostic for step samplers

  • make population step samplers more consistent with other step samplers

4.0.0 (2024-02-15)

  • new ultranest.mlfriends.MaxPrincipleGapAffineLayer for metric learning, set as default

3.6.5 (2023-07-18)

3.6.0 (2023-06-22)

  • add PopulationRandomWalkSampler: vectorized Gaussian random walks for GPU/JAX-powered likelihoods

  • limit initial widening to escape plateau (issue #81)

3.5.0 (2022-09-05)

  • add hot-resume: resume from a similar fit (with different data)

  • fix post_summary.csv column order

  • fix build handling for non-pip systems (pyproject.toml)

  • more efficient handling of categorical variables

3.4.0 (2022-04-05)

  • add differential evolution proposal for slice sampling, recommend it

  • fix revert of step sampler when run out of constraint, in MPI

  • add SimpleRegion: axis-aligned ellipsoidal for very high-d.

3.3.3 (2021-09-17)

  • pretty marginal posterior plot to stdout

  • avoid non-terminations when logzerr cannot be reached

  • add RobustEllipsoidRegion: ellipsoidal without MLFriends for high-d.

  • add WrappingEllipsoid: for additional rejection.

  • bug fixes on rank order test

  • add resume-similar

  • modular step samplers

3.0.0 (2020-10-03)

  • Accelerated Hit-and-Run Sampler added

  • Support for other languages (C, C++, Julia, Fortran) added

  • Insertion order test added

  • Warm-start added

  • Rejection sampling with transformed ellipsoid added

2.2.0 (2020-02-07)

  • allow reading UltraNest outputs without ReactiveNestedSampler instance

2.1.0 (2020-02-07)

  • adaptive number of steps for slice and hit-and-run samplers.

2.0.0 (2019-10-03)

  • First release.

1.0.0 (2014)

  • A simpler version referenced in Buchner et al. (2014), combining RadFriends with an optional Metropolis-Hastings proposal.

Release files for ultranest 4.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ultranest 4.5.2
File Size Uploaded
ultranest-4.5.2.tar.gz 2.7 MB Details

Release files / ultranest-4.5.2.tar.gz

Download URL ultranest-4.5.2.tar.gz
Size 2.7 MB
Tags Source
SHA-256 checksum
How to use checksums
07f2205a41af8577d4560bfba3284dc3593b4f722f8d581cd9f13873a272d032
BLAKE2b-256 checksum
How to use checksums
5d0b549f7f1b77674de2f4e665c29eb1409a06e10d5a752c4db5cf7827934ecb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

4.5.2 This release

1 release file

4.5.0

1 release file

4.4.0

1 release file

4.3.3

1 release file

4.3.2

1 release file

4.3.1

1 release file

4.2.0

1 release file

4.1.7

1 release file

4.1.6

1 release file

4.1.5

1 release file

4.1.4

1 release file

4.1.3

1 release file

4.1.2

1 release file

4.1.1

1 release file

4.1.0

1 release file

4.0.0

1 release file

3.6.5

1 release file

3.6.4

1 release file

3.6.3

1 release file

3.6.2

1 release file

3.6.1

1 release file

3.6.0

1 release file

3.5.7

1 release file

3.5.6

1 release file

3.5.5

1 release file

3.5.4

1 release file

3.5.2

1 release file

3.5.1

1 release file

3.4.6

1 release file

3.4.4

1 release file

3.4.3

1 release file

3.4.2

1 release file

3.3.3

1 release file

3.3.2

1 release file

3.3.0

1 release file

3.2.1

1 release file

3.2.0

1 release file

3.1.5

1 release file

3.1.4

1 release file

3.1.3

1 release file

3.1.2

1 release file

3.1.1

1 release file

3.1.0

1 release file

3.0.3

1 release file

3.0.2

1 release file

3.0.1

1 release file

2.2.2

1 release file

2.2.1

1 release file

2.1.2

1 release file

2.1.1

1 release file

2.1.0

1 release file

2.0.4

1 release file

2.0.3

1 release file

2.0.2

1 release file

2.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page