slice_quantile: Quantile Slice Sampler

View source: R/slice_samplers_univariate.R

slice_quantileR Documentation

Quantile Slice Sampler

Description

Single update using a quantile slice sampler of Heiner et al. (2026+).

Usage

slice_quantile(x, log_target, pseudo, 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.

pseudo

List containing two functions specifying the pseudo-target distribution:

ld evaluates the log density for a scalar input, and

q evaluates the quantile (inverse-CDF) function for an input in (0,1).

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.

Details

The sampler works with \psi, the pseudo-target CDF of the state, in double precision. Because floating-point numbers are dense near zero but not near one, states whose pseudo-target upper-tail probability is below about 1e-16 cannot be represented. Use a pseudo-target whose right tail is at least as heavy as that of the target (e.g., Student t).

Value

A list containing three elements:

x is the new state.

u is the value of the CDF of the pseudo-target associated with the returned value (also referred to as psi).

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

References

Heiner, M. J., Johnson, S. B., Christensen, J. R., and Dahl, D. B. (2026+), "Quantile Slice Sampling," arXiv preprint arXiv:2407.12608 \Sexpr[results=rd]{tools:::Rd_expr_doi("https://doi.org/10.48550/arXiv.2407.12608")}

Examples

lf <- function(x) dbeta(x, 3, 4, log = TRUE)
pseu <- pseudo_list(family = "beta", params = list(shape1 = 2.0, shape2 = 2.0))
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_quantile(draws[i - 1], log_target = lf, pseudo = pseu)
  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.