Skip to contents

Return the normalised posterior importance weights for the dead points in a nested sampling run.

Usage

# S3 method for class 'ernest_run'
weights(object, log = FALSE, ...)

Arguments

object

[ernest_run]
A nested sampling run.

log

[logical(1)]
Whether to return the weights on the log scale.

...

These dots are for future extensions and must be empty.

Value

[double()] A numeric vector of normalised importance weights. When log = FALSE, the values are exponentiated so they sum to one.

Details

The log-weights in a nested sampling run are the individual contributions of each sample to the log-evidence estimate. The unnormalised weight of the \(i\)th sampled point is given as $$w_i = \frac{L_{i-1} + L_i}{2} * (V_{i-1} - V_i)$$ where \(L_i\) is the likelihood value for the point and \(V_i\) is the prior volume at which the point was sampled.

The posterior importance weights are obtained by normalising the log-weights with the final log-evidence estimate. They can be used to reweight posterior samples from the run so they approximate the posterior distribution.

Examples

data(example_run)
weights(example_run) |> head()
#> [1] 4.626832e-59 4.642903e-57 2.136511e-56 3.407974e-56 5.357244e-56
#> [6] 5.713593e-55
weights(example_run, log = TRUE) |> head()
#> [1] -134.3206 -129.7120 -128.1856 -127.7186 -127.2663 -124.8993