nessai.proposal.rejection
Proposal method for initial sampling when priors are not analytical.
Module Contents
Classes
Object for rejection sampling from the priors. |
- class nessai.proposal.rejection.RejectionProposal(*args, **kwargs)
Bases:
nessai.proposal.analytic.AnalyticProposal
Object for rejection sampling from the priors.
See parent for explanation of arguments and keyword arguments.
Will be used when
nessai
is called withanalytic_priors=False
. This is the default behaviour.Relies on
nessai.model.Model.new_point()
to draw new points andnessai.model.Model.new_point_log_prob()
when computing the probability of each new point.- draw_proposal(N=None)
Draw new point(s).
- Parameters:
- Nint, optional
Number of samples to draw. If not specified
poolsize
will be used.
- Returns:
- structured_array
Array of N new points
- log_proposal(x)
Log proposal probability. Calls
nessai.model.Model.new_point_log_prob()
- Parameters:
- xstructured_array
Array of new points
- Returns:
numpy.ndarray
Array of log-probabilities.
- compute_weights(x, return_log_prior=False)
Get weights for the samples.
Computes the log weights for rejection sampling sampling but does not normalize the weights.
- Parameters:
- xstructured_array
Array of points
- return_log_prior: bool
If true, the log-prior probability is also returned.
- Returns:
- log_w
numpy.ndarray
Array of log-weights rescaled such that the maximum value is zero.
- log_w
- populate(N=None)
Populate the pool by drawing from the proposal distribution and using rejection sampling.
Will also evaluate the likelihoods if the proposal contains a multiprocessing pool.
- Parameters:
- Nint, optional
Number of samples to draw. Not all samples will be accepted to the number of samples saved will be less than N. If not specified
poolsize
will be used.