bilby.core.result.reweight

bilby.core.result.reweight(result, label=None, new_likelihood=None, new_prior=None, old_likelihood=None, old_prior=None, conversion_function=None, npool=1, verbose_output=False, resume_file=None, n_checkpoint=5000, use_nested_samples=False)[source]

Reweight a result to a new likelihood/prior using rejection sampling

Parameters:
label: str, optional

An updated label to apply to the result object

new_likelihood: bilby.core.likelood.Likelihood, (optional)

If given, the new likelihood to reweight too. If not given, likelihood reweighting is not applied

new_prior: bilby.core.prior.PriorDict, (optional)

If given, the new prior to reweight too. If not given, prior reweighting is not applied

old_likelihood: bilby.core.likelihood.Likelihood, (optional)

If given, calculate the old likelihoods from this object. If not given, the values stored in the posterior are used.

old_prior: bilby.core.prior.PriorDict, (optional)

If given, calculate the old prior from this object. If not given, the values stored in the posterior are used.

conversion_function: function, optional

Function which adds in extra parameters to the data frame, should take the data_frame, likelihood and prior as arguments.

npool: int, optional

Number of threads with which to execute the conversion function

verbose_output: bool, optional

Flag determining whether the weight array and associated prior and likelihood evaluations are output as well as the result file

resume_file: string, optional

filepath for the resume file which stores the weights

n_checkpoint: int, optional

Number of samples to reweight before writing a resume file

use_nested_samples: bool, optional

If true reweight the nested samples instead. This can greatly improve reweighting efficiency, especially if the target distribution has support beyond the proposal posterior distribution.

Returns:
result: bilby.core.result.Result

A copy of the result object with a reweighted posterior

new_log_likelihood_array: array, optional (if verbose_output=True)

An array of the natural-log likelihoods from the new likelihood

new_log_prior_array: array, optional (if verbose_output=True)

An array of the natural-log priors from the new likelihood

old_log_likelihood_array: array, optional (if verbose_output=True)

An array of the natural-log likelihoods from the old likelihood

old_log_prior_array: array, optional (if verbose_output=True)

An array of the natural-log priors from the old likelihood