# Log-normal density ----------------
x <- ru(logf = dlnorm, log = TRUE, d = 1, n = 1000, lower = 0, init = 1)
# \donttest{
plot(x)
# }
# Improve appearance using arguments to plot() and hist()
# \donttest{
plot(x, breaks = seq(0, ceiling(max(x$sim_vals)), by = 0.25),
xlim = c(0, 10))
# }
# Two-dimensional normal with positive association ----------------
rho <- 0.9
covmat <- matrix(c(1, rho, rho, 1), 2, 2)
log_dmvnorm <- function(x, mean = rep(0, d), sigma = diag(d)) {
x <- matrix(x, ncol = length(x))
d <- ncol(x)
- 0.5 * (x - mean) %*% solve(sigma) %*% t(x - mean)
}
x <- ru(logf = log_dmvnorm, sigma = covmat, d = 2, n = 1000, init = c(0, 0))
# \donttest{
plot(x)
# }
Run the code above in your browser using DataLab