summary method for class "ru".

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

# S3 method for ru
summary(object, ...)

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

Arguments

object

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

...

For summary.lm: additional arguments passed to summary. For print.lm: additional optional arguments passed to print.

x

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

Value

For summary.lm: a list of the following components from

object:

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

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

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

For print.summary.ru: the argument x, invisibly.

See also

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

plot.ru for a diagnostic plot.

Examples

# 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.7942812
#> 
#> sample summary 
#>        V1          
#>  Min.   :-2.99325  
#>  1st Qu.:-0.66050  
#>  Median : 0.03568  
#>  Mean   : 0.01637  
#>  3rd Qu.: 0.68481  
#>  Max.   : 3.11812  

# 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.538503
#> 
#> sample summary 
#>        V1                 V2          
#>  Min.   :-3.16310   Min.   :-3.67917  
#>  1st Qu.:-0.67990   1st Qu.:-0.65036  
#>  Median : 0.05461   Median : 0.08597  
#>  Mean   : 0.03924   Mean   : 0.05126  
#>  3rd Qu.: 0.75936   3rd Qu.: 0.76554  
#>  Max.   : 3.55926   Max.   : 3.51601