print
method for an object object
of class
"summary.ru"
.
# S3 method for summary.ru
print(x, ...)
an object of class "summary.ru"
, a result of a call to
summary.ru
.
Additional optional arguments to be passed to
print
.
The argument x
, invisibly.
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
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
.
# one-dimensional standard normal ----------------
x <- ru(logf = function(x) -x ^ 2 / 2, d = 1, n = 1000, init = 0)
summary(x)
#> ru bounding box:
#> box vals1 conv
#> a 1.000000 0.00000 0
#> b1minus -1.050542 -1.73205 0
#> b1plus 1.050542 1.73205 0
#>
#> estimated probability of acceptance:
#> [1] 0.8019246
#>
#> sample summary
#> V1
#> Min. :-3.481312
#> 1st Qu.:-0.695558
#> Median :-0.004972
#> Mean : 0.002988
#> 3rd Qu.: 0.693680
#> Max. : 3.030506
# 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)
#> ru bounding box:
#> box vals1 vals2 conv
#> a 1.0000000 0.000000e+00 0.000000e+00 0
#> b1minus -0.8008868 -1.320440e+00 -7.414894e-09 0
#> b2minus -0.8008868 -9.922367e-10 -1.320440e+00 0
#> b1plus 0.8008868 1.320440e+00 -2.548085e-09 0
#> b2plus 0.8008868 -9.851831e-10 1.320440e+00 0
#>
#> estimated probability of acceptance:
#> [1] 0.5324814
#>
#> sample summary
#> V1 V2
#> Min. :-3.54922 Min. :-3.83213
#> 1st Qu.:-0.63340 1st Qu.:-0.62853
#> Median :-0.03214 Median :-0.02042
#> Mean : 0.00334 Mean :-0.02704
#> 3rd Qu.: 0.63403 3rd Qu.: 0.61184
#> Max. : 3.27577 Max. : 3.71356