Skip to contents

An R6 class that contains a nested sampling run.

This object is normally created by calling nested_sampling(), and interacted with by calling S3 methods like generate(), calculate(), and glance().

Public fields

verbose

Should a progress bar be displayed during sampling?

Active bindings

n_iterations

The total number of sampling iterations.

n_calls

The total calls made to the likelihood function, or 0L if no calls have been made yet.

variables

The names of each variable in the prior space.

live_points

Access the live points list.

dead_points

Access the dead points list.

Methods


Method new()

Creates a new ernest_sampler.

Usage

ernest_sampler$new(
  lrps,
  ptype,
  n_points = 500L,
  verbose = getOption("verbose")
)

Arguments

lrps

An ernest_lrps object describing the model and prior space.

ptype

The parameters involved in nested sampling. Possible values are:

  • A single integer, describing the dimensions of the prior space.

  • A character vector, naming each dimension in the prior space.

  • A zero-row tibble::tibble(), where each column names a dimension of the prior space.

n_points

The number of live points to use during nested sampling. Higher values allow for more accurate estimates of the evidence integral at the cost of increased computational time.

verbose

Whether to display a progress bar during a run.

Returns

An ernest_sampler object.


Method compile()

Prepare the ernest_sampler for generating nested samples by validating the set of live points within the object, creating live points if none exist yet.

Usage

ernest_sampler$compile(refresh = FALSE)

Arguments

refresh

Whether to clear existing points from object and generating new ones. If TRUE, the function will clear both the live points and dead points gathered from previous runs.

Returns

itself, invisibly.


Method generate()

Generate samples from nested sampling until a given criterion is met.

Usage

ernest_sampler$generate(
  max_iterations = Inf,
  max_calls = Inf,
  min_logz = 0.05,
  refresh = FALSE
)

Arguments

max_iterations

The maximum number of iterations to perform. If set to Inf, this stopping criterion is ignored.

max_calls

The maximum number of calls to the likelihood function. If set to Inf, this stopping criterion is ignored.

min_logz

The minimum log-evidence value to achieve. Must be a number strictly larger than zero.

refresh

Whether to clear existing points from the sampler, starting a run from scratch.

Returns

itself, invisibly.


Method calculate()

Calculate the marginal likelihood of a given model and return the estimates in a tidy tibble().

Usage

ernest_sampler$calculate(
  add_points = c("none", "unit", "original", "both"),
  add_progress = FALSE
)

Arguments

add_points

A string, either "none", "unit", "parameter", or "both". If "none", no additional columns are added. If "unit"or "parameter", the parameter values associated with each point are added, in their respective units. If "both", both the unit and parameter values are added.

add_progress

Adds columns for the number of calls to the likelihood function between each iteration.

Returns

A tibble with columns reporting the results of the run.


Method summary()

Summarise the results of a nested sampling run.

Usage

ernest_sampler$summary()

Returns

A list with class summary.ernest_sampler().


Method format()

Encode the run as a string for pretty printing.

Usage

ernest_sampler$format(digits = max(3, getOption("digits") - 3))

Arguments

digits

The number of digits to display.

Returns

A string.


Method print()

Print a brief summary of the sampler to the string.

Usage

ernest_sampler$print(...)

Arguments

...

Arguments forwarded to format()

Returns

itself, invisibly.


Method clone()

The objects of this class are cloneable with this method.

Usage

ernest_sampler$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.