zigzagHMC | R Documentation |
Generate MCMC samples from a d-dimensional truncated Gaussian distribution with element-wise truncations using the Zigzag Hamiltonian Monte Carlo sampler (Zigzag-HMC).
zigzagHMC(
nSample,
burnin = 0,
mean,
prec,
lowerBounds,
upperBounds,
init = NULL,
stepsize = NULL,
nutsFlg = FALSE,
precondition = FALSE,
seed = NULL,
diagnosticMode = FALSE
)
nSample |
number of samples after burn-in. |
burnin |
number of burn-in samples (default = 0). |
mean |
a d-dimensional mean vector. |
prec |
a d-by-d precision matrix of the Gaussian distribution. |
lowerBounds |
a d-dimensional vector specifying the lower bounds. |
upperBounds |
a d-dimensional vector specifying the upper bounds. |
init |
a d-dimensional vector of the initial value. |
stepsize |
step size for Zigzag-HMC or Zigzag-NUTS (if |
nutsFlg |
logical. If |
precondition |
logical. If |
seed |
random seed (default = 1). |
diagnosticMode |
logical. |
an nSample-by-d matrix of samples. If diagnosticMode
is TRUE
, a list with additional diagnostic information is returned.
nishimura2024zigzaghdtg
\insertRefnishimura2020discontinuoushdtg
set.seed(1)
d <- 10
A <- matrix(runif(d^2)*2-1, ncol=d)
covMat <- t(A) %*% A
precMat <- solve(covMat)
initial <- rep(1, d)
results <- zigzagHMC(nSample = 1000, burnin = 1000, mean = rep(0, d), prec = precMat,
lowerBounds = rep(0, d), upperBounds = rep(Inf, d))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.