Sample
Use these functions to run sampling/integration processes.
- xpsi.Sample.nested(likelihood, prior, check_kwargs={}, **kwargs)[source]
Initialise MultiNest and integrate.
- Parameters:
likelihood (dict) – Keyword arguments required for instantiation of
Likelihood
.prior (dict) – Keyword arguments required for instantiation of
Prior
.check_kwargs (dict) – Keywords for likelihood function checker. Passed to checker before commencement of sampling.
kwargs – Keyword arguments for PyMultiNest.
- xpsi.Sample.ensemble(likelihood, prior, MPI=True, **kwargs)[source]
Initialise emcee and sample.
- Parameters:
likelihood – An instance of
Likelihood
.prior – An instance of
Prior
.MPI (bool) – Parallelise with MPI? If calling script not lauched with an MPI directive, sampling will not commence because there is only one process. Default is
True
since only in testing is it justifiable to use a single process.kwargs –
Passed to initialisers of appropriate classes:
boolean to resume, under keyword
resume
;number of steps, under keyword
nsteps
;number of walkers, under keyword
nwalkers
;moments of initial walker multivariate Gaussian distribution, under keyword
walker_dist_moments
(can beNone
);root directory for output, under keyword
root_dir
.
The above objects are used to instantiate
Posterior
.- Returns:
An instance of
emcee.backends.HDFBackend
.
- xpsi.Sample.ultranested(likelihood, prior, sampler_params={}, runtime_params={}, use_stepsampler=False, stepsampler_params={}, out_filename='weighted_post_ultranest_xpsi')[source]
- Wrapper for the UltraNest (https://johannesbuchner.github.io/UltraNest/)
package (Buchner 2021).
- Parameters:
likelihood – An instance of
Likelihood
.prior – An instance of
Prior
.sampler_params – A dictionary of the keyword arguments passed to the instance of
UltranestSampler
to initialise the sampler.runtime_params – A dictionary of the keyword arguments passed to the instance of
UltranestSampler
to run the sampler.use_stepsampler – Boolean indicating if the step sampler is used. In this case the
ultranest.stepsampler.SliceSampler
is used.stepsampler_params – A dictionary of the keyword arguments passed to the to the instance of
UltranestSampler
specifying the step sampler runtime parameters.out_filename – String specifying the name of the output file.
- Returns:
An instance of
UltranestSampler