View source: R/sampling_functions.R
sample.z | R Documentation |
Draw samples of independent normals (matrix) given previous sample, and maximal values
sample.z(mu, y, z)
mu |
n by d matrix of latent means |
y |
n-length vector of maximal indices |
z |
n by d matrix of latent random variables |
A new sample of n by d matrix of latent random variables
set.seed(1)
n <- 100; d <- 3
mu <- matrix(rnorm(n*d), n, d)
bound <- qnorm(1/d^(1/(d-1)))
mu[,1] <- bound
z <- mu
z[,-1] <- rnorm(length(mu[,-1]), mu[,-1], 1)
y <- apply(z, 1, which.max)
z.new <- sample.z(mu, y, z)
all(apply(z.new, 1, which.max) == y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.