nessai.posterior
Functions related to computing the posterior samples.
Module Contents
Functions
|
Returns the log-evidence and log-weights for the log-likelihood samples |
|
Draw posterior samples given the nested samples. |
- nessai.posterior.compute_weights(samples, nlive, expectation='logt')
Returns the log-evidence and log-weights for the log-likelihood samples assumed to the result of nested sampling with nlive live points
- Parameters:
- samplesarray_like
Log-likelihood samples.
- nliveUnion[int, array_like]
Number of live points used in nested sampling.
- expectationstr, {logt, t}
Method used to compute the expectation value for the shrinkage t. Choose between log <t> or <log t>. Defaults to <log t>.
- Returns:
- float
The computed log-evidence.
- array_like
Array of computed weights (already normalised by the log-evidence).
- nessai.posterior.draw_posterior_samples(nested_samples, nlive=None, n=None, log_w=None, method='rejection_sampling', return_indices=False, expectation='logt')
Draw posterior samples given the nested samples.
Requires either the posterior weights or the number of live points.
- Parameters:
- nested_samplesstructured array
Array of nested samples.
- nliveint, optional
Number of live points used during nested sampling. Either this arguments or log_w must be specified.
- nint, optional
Number of samples to draw. Only used for importance sampling. If not specified, the effective sample size is used instead.
- log_warray_like, optional
Array of posterior weights. If specified the weights are not computed and these weights are used instead.
- methodstr
Method for drawing the posterior samples. Choose from
'rejection_sampling'
'multinomial_resampling'
'importance_sampling'
(same as multinomial)
- return_indicesbool
If true return the indices of the accepted samples.
- expectationstr, {logt, t}
Method used to compute the expectation value for the shrinkage t. Choose between log <t> or <log t>. Defaults to <log t>. Only used when
log_w
is not specified.
- Returns:
- posterior_samplesnumpy.ndarray
Samples from the posterior distribution.
- indicesnumpy.ndarray
Indices of the accepted samples in the original nested samples. Only returned if
return_indices
is True.
- Raises:
- ValueError
If the chosen method is not a valid method.