Registry / ai-ml / dynesty

dynesty

JSON →
library3.0.0pypypi✓ verified 85d ago

A dynamic nested sampling package for computing Bayesian posteriors and evidences. Current version 3.0.0 (released 2024-06-10). Requires Python >=3.8. Active development with major refactoring in v3.0.0 for extensibility and speed.

pip install dynesty
INSTALL
IMPORT
SIG · DYNESTY
D
dynesty
ai-mlpythonv3.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NestedSampler
from dynesty import NestedSampler
DynamicNestedSampler
from dynesty import DynamicNestedSampler
results
from dynesty import results
utils
from dynesty import utils
pool
from dynesty import pool

Basic nested sampling run with Gaussian likelihood and uniform prior.

import numpy as np from dynesty import NestedSampler, utils # Define a simple prior transform (uniform in [0,1]^2) def prior_transform(u): return 10 * u - 5 # shift to [-5, 5] # Define a simple Gaussian log-likelihood def loglikelihood(x): return -0.5 * np.sum(x**2) # Run nested sampling sampler = NestedSampler(loglikelihood, prior_transform, ndim=2) sampler.run_nested(dlogz=0.5) results = sampler.results # Compute evidence and posterior samples log_z = results.logz[-1] weights = np.exp(results.logwt - results.logz[-1]) samples = utils.resample_equal(results.samples, weights) print(f"log Z = {log_z:.2f}")
Debug
Known issues
breakingv3.0.0 refactored the sampler API: custom samplers now need to be provided as class instances (e.g., NestedSampler(sample=RWalkSampler(walks=44))). The previous string-based specification (sample='rwalk') is deprecated.
fix
Use sampler classes: from dynesty.sampling import RWalkSampler; NestedSampler(..., sample=RWalkSampler(walks=44))
affects: >=3.0.0
deprecatedThe 'npdim' option has been removed since v2.1.4. Prior transforms must return vectors of same dimension as input.
fix
Remove npdim parameter; ensure prior_transform returns array of length ndim.
affects: >=2.1.4
gotchaResuming a run from a checkpoint created with dynesty <2.1.3 is not possible after v2.1.4. The checkpoint format changed.
fix
If you need to resume, finish the run with an older version or restart from scratch.
affects: >=2.1.4
gotchaWhen using blob=True, live_points must be a tuple of 4 elements (u, v, logl, blobs). Omitting blobs will cause an error.
fix
Provide all four entries when specifying live_points with blobs.
affects: >=2.0.0
Errors
Common errors & fixes
AttributeError: module 'dynesty' has no attribute 'NestedSampler'
Import path incorrect or old dynesty version (<1.0).
fix
Use correct import: from dynesty import NestedSampler
ValueError: The prior transform must return an array of shape (ndim,) or (npoints, ndim)
Prior transform returns wrong shape (e.g., scalar or higher dimension).
fix
Ensure prior_transform returns a 1D array of length ndim.
TypeError: run_nested() missing 1 required positional argument: 'dlogz'
In dynesty v2+, dlogz must be passed as keyword argument (not positional).
fix
Use sampler.run_nested(dlogz=0.5) or other kwargs.
dynesty.pool.Pool is deprecated
The dynesty.pool module was removed in v3.0.0.
fix
Use multiprocessing.Pool directly: pool = multiprocessing.Pool(); sampler = NestedSampler(..., pool=pool)
Upgrade
Version history
3.0.0latest on PyPI · released Oct 4, 2025
Audit
Dependencies
numpyrequiredCore dependency for numerical arrays and random sampling
scipyoptionalOptional: used for some bounding methods (e.g., ellipsoid)
Agent activity
14 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
dynesty — pip install dynesty · libregistry