slice_genelliptical: Generalized Elliptical Slice Sampler (univariate)

View source: R/slice_samplers_univariate.R

slice_genellipticalR Documentation

Generalized Elliptical Slice Sampler (univariate)

Description

Single update using the generalized elliptical slice sampler of Nishihara et al. (2014).

Usage

slice_genelliptical(x, log_target, mu, sigma, df, diagnostics = NULL)

Arguments

x

The current state (as a numeric scalar).

log_target

A function taking numeric scalar that evaluates the (potentially unnormalized) log-target density, returning a numeric scalar.

mu

A numeric scalar with the location parameter of the Student t pseudo-target.

sigma

A positive numeric scalar with the scale parameter of the Student t pseudo-target.

df

Degrees of freedom of Student t pseudo-target.

diagnostics

Logical, indicating whether the sampler should be run in diagnostic mode for informative error handling. When diagnostics is NULL, it is reset to match the value of getOption("qslice.diagnostics") which defaults to FALSE if the option is not set. Default for diagnostics is NULL.

Value

A list containing two elements:

x is the new state.

nEvaluations is the number of evaluations of the target function used to obtain the new state.

References

Nishihara, R., Murray, I., and Adams, R. P. (2014), "Parallel MCMC with Generalized Elliptical Slice Sampling," Journal of Machine Learning Research, 15, 2087-2112. https://jmlr.org/papers/v15/nishihara14a.html

Examples

lf <- function(x) dbeta(x, 3, 4, log = TRUE)
draws <- numeric(10) + 0.5 # set to numeric(1e3) + 0.5 for more complete illustration
nEvaluations <- 0L
for (i in seq.int(2, length(draws))) {
  out <- slice_genelliptical(draws[i - 1], log_target = lf,
                                      mu = 0.5, sigma = 1, df = 5)
  draws[i] <- out$x
  nEvaluations <- nEvaluations + out$nEvaluations
}
nEvaluations / (length(draws) - 1)
plot(density(draws), xlim = c(0, 1))
curve(exp(lf(x)), 0, 1, col = "blue", add = TRUE)


qslice documentation built on Oct. 22, 2026, 1:06 a.m.