{"id":27710,"library":"dynesty","title":"dynesty","description":"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.","status":"active","version":"3.0.0","language":"python","source_language":"en","source_url":"https://github.com/joshspeagle/dynesty","tags":["nested sampling","bayesian inference","evidence calculation","MCMC","astronomy"],"install":[{"cmd":"pip install dynesty","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for numerical arrays and random sampling","package":"numpy","optional":false},{"reason":"Optional: used for some bounding methods (e.g., ellipsoid)","package":"scipy","optional":true}],"imports":[{"note":"","wrong":"","symbol":"NestedSampler","correct":"from dynesty import NestedSampler"},{"note":"","wrong":"","symbol":"DynamicNestedSampler","correct":"from dynesty import DynamicNestedSampler"},{"note":"","wrong":"","symbol":"results","correct":"from dynesty import results"},{"note":"","wrong":"","symbol":"utils","correct":"from dynesty import utils"},{"note":"","wrong":"","symbol":"pool","correct":"from dynesty import pool"}],"quickstart":{"code":"import numpy as np\nfrom dynesty import NestedSampler, utils\n\n# Define a simple prior transform (uniform in [0,1]^2)\ndef prior_transform(u):\n    return 10 * u - 5  # shift to [-5, 5]\n\n# Define a simple Gaussian log-likelihood\ndef loglikelihood(x):\n    return -0.5 * np.sum(x**2)\n\n# Run nested sampling\nsampler = NestedSampler(loglikelihood, prior_transform, ndim=2)\nsampler.run_nested(dlogz=0.5)\nresults = sampler.results\n\n# Compute evidence and posterior samples\nlog_z = results.logz[-1]\nweights = np.exp(results.logwt - results.logz[-1])\nsamples = utils.resample_equal(results.samples, weights)\nprint(f\"log Z = {log_z:.2f}\")","lang":"python","description":"Basic nested sampling run with Gaussian likelihood and uniform prior."},"warnings":[{"fix":"Use sampler classes: from dynesty.sampling import RWalkSampler; NestedSampler(..., sample=RWalkSampler(walks=44))","message":"v3.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.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Remove npdim parameter; ensure prior_transform returns array of length ndim.","message":"The 'npdim' option has been removed since v2.1.4. Prior transforms must return vectors of same dimension as input.","severity":"deprecated","affected_versions":">=2.1.4"},{"fix":"If you need to resume, finish the run with an older version or restart from scratch.","message":"Resuming a run from a checkpoint created with dynesty <2.1.3 is not possible after v2.1.4. The checkpoint format changed.","severity":"gotcha","affected_versions":">=2.1.4"},{"fix":"Provide all four entries when specifying live_points with blobs.","message":"When using blob=True, live_points must be a tuple of 4 elements (u, v, logl, blobs). Omitting blobs will cause an error.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use correct import: from dynesty import NestedSampler","cause":"Import path incorrect or old dynesty version (<1.0).","error":"AttributeError: module 'dynesty' has no attribute 'NestedSampler'"},{"fix":"Ensure prior_transform returns a 1D array of length ndim.","cause":"Prior transform returns wrong shape (e.g., scalar or higher dimension).","error":"ValueError: The prior transform must return an array of shape (ndim,) or (npoints, ndim)"},{"fix":"Use sampler.run_nested(dlogz=0.5) or other kwargs.","cause":"In dynesty v2+, dlogz must be passed as keyword argument (not positional).","error":"TypeError: run_nested() missing 1 required positional argument: 'dlogz'"},{"fix":"Use multiprocessing.Pool directly: pool = multiprocessing.Pool(); sampler = NestedSampler(..., pool=pool)","cause":"The dynesty.pool module was removed in v3.0.0.","error":"dynesty.pool.Pool is deprecated"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}