- Notifications
You must be signed in to change notification settings - Fork9
Implementations of single and multi-ellipsoid nested sampling
License
TuringLang/NestedSamplers.jl
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Implementations of single- and multi-ellipsoidal nested sampling algorithms in pure Julia. We implement theAbstractMCMC.jl interface, allowing straightforward sampling from a variety of statistical models.
This package was heavily influenced bynestle,dynesty, andNestedSampling.jl.
If you use this library, or a derivative of it, in your work, please consider citing it. This code is built off a multitude of academic works, which have been noted in the docstrings where appropriate. These references, along with references for the more general calculations, can all be found inCITATION.bib
To use the nested samplers first install this library
julia> ]add NestedSamplers
For in-depth usage, see theonline documentation. In general, you'll need to write a log-likelihood function and a prior transform function. These are supplied to aNestedModel
, defining the statistical model
using NestedSamplersusing Distributionsusing LinearAlgebralogl(X)=logpdf(MvNormal([1,-1], I), X)prior(X)=4.* (X.-0.5)# or equivalentlypriors= [Uniform(-2,2),Uniform(-2,2)]model=NestedModel(logl, priors)
after defining the model, set up the nested sampler. This will involve choosing the bounding space and proposal scheme, or you can rely on the defaults. In addition, we need to define the dimensionality of the problem and the number of live points. More points results in a more precise evidence estimate at the cost of runtime. For more information, see the docs.
bounds= Bounds.MultiEllipsoidprop= Proposals.Slice(slices=10)# 1000 live pointssampler=Nested(2,1000; bounds=bounds, proposal=prop)
once the sampler is set up, we can leverage all of theAbstractMCMC.jl interface, including the step iterator, transducer, and a conveniencesample
method. Thesample
method takes keyword arguments for the convergence criteria.
Note: both the samplesand the sampler state will be returned bysample
using StatsBasechain, state=sample(model, sampler; dlogz=0.2)
you can resample taking into account the statistical weights, again using StatsBase
chain_resampled=sample(chain,Weights(vec(chain["weights"])),length(chain))
These are chains fromMCMCChains.jl, which offer a lot of flexibility in exploring posteriors, combining data, and offering lots of convenient conversions (like toDataFrame
s).
Finally, we can see the estimate of the Bayesian evidence
using Measurementsstate.logz± state.logzerr
Primary Author: Miles Lucas (@mileslucas)
Contributions are always welcome! In general, contributions should followColPrac. Take a look at theissues for ideas of open problems! To discuss ideas or plan contributions, open adiscussion.
About
Implementations of single and multi-ellipsoid nested sampling