Skip to contents

P(lower < X < upper) for X ~ N(0, R) by Genz's method: exact in one and two dimensions; in more, Genz's integral after a Cholesky separation of the variables (reordered as Genz and Bretz do), estimated by scrambles independently scrambled Sobol sequences, the points doubled until three standard errors are at most abs_tol or the points reach max_points. The method of mvtnorm::pmvnorm(), with Sobol points in place of its lattice rules, so results agree within the errors.

Usage

mvn_cdf(
  upper,
  correlation,
  lower = NULL,
  abs_tol = 1e-05,
  max_points = 2^22,
  scrambles = 10,
  seed = 0
)

Arguments

upper

Upper limits (Inf for none).

correlation

A positive definite correlation or covariance matrix.

lower

Lower limits; NULL for -Inf.

abs_tol

Absolute error to reach, three standard errors; with ten scrambles the true error exceeds it in about 1.5% of calls.

max_points

Most integrand evaluations.

scrambles

Independent scrambles, at least 2.

seed

Seed of the scrambles, so a call is reproducible.

Value

The probability, with attributes error, points and converged.

Examples

r <- matrix(0.5, 3, 3)
diag(r) <- 1
mvn_cdf(c(0, 0, 0), r) # 1/4
#> [1] 0.2499985
#> attr(,"error")
#> [1] 2.665552e-06
#> attr(,"points")
#> [1] 20480
#> attr(,"converged")
#> [1] TRUE