Learn R Programming

rust (version 1.3.13)

print.summary.ru: Print method for objects of class "summary.ru"

Description

print method for an object object of class "summary.ru".

Usage

# S3 method for summary.ru
print(x, ...)

Value

Prints

  • a summary of the simulated values, via summary(object$sim_vals)

  • an estimate of the probability of acceptance, i.e. object$pa

  • information about the ratio-of-uniforms bounding box, i.e. object$box

Arguments

x

an object of class "summary.ru", a result of a call to summary.ru.

...

Additional optional arguments to be passed to print.

See Also

summary.ru for summaries of the simulated values and properties of the ratio-of-uniforms algorithm.

plot.ru for a diagnostic plot.

ru for descriptions of object$sim_vals and object$box.

Examples

Run this code
# one-dimensional standard normal ----------------
x <- ru(logf = function(x) -x ^ 2 / 2, d = 1, n = 1000, init = 0)
summary(x)

# 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))
summary(x)

Run the code above in your browser using DataLab