1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
### test-intDensTri.R ---
#----------------------------------------------------------------------
## author: Brice Ozenne
## created: aug 31 2017 (16:32)
## Version:
## last-updated: Jan 12 2022 (16:33)
## By: Brice Ozenne
## Update #: 16
#----------------------------------------------------------------------
##
### Commentary:
##
### Change Log:
#----------------------------------------------------------------------
##
### Code:
## * header
##rm(list = ls(all.names = TRUE))
if(TRUE){ ## already called in test-all.R
library(testthat)
library(lavaSearch2)
}
library(mvtnorm)
lava.options(symbols = c("~","~~"))
context("intDensTri")
## * tests
# {{{ around 0
test_that("Integrate standard gaussian density (2D)", {
p <- 2
Sigma <- diag(p)
mu <- rep(0, p)
for(n in c(5,10,20,50,100)){ # n <- 5
res <- intDensTri(mu = mu, Sigma = Sigma, n=n, x.min=0)
expect_equal(res$value,
1/2,
tol = 1e-6)
}
})
test_that("Integrate standard gaussian density (3D)", {
p <- 3
Sigma <- diag(p)
mu <- rep(0, p)
for(n in c(5,10,20,50,100)){
res <- intDensTri(mu = mu, Sigma = Sigma, n=n, x.min=0, z.max=10)
expect_equal(res$value,
1/2,
tol = 1e-6)
}
})
# }}}
# {{{ far from 0
test_that("Integrate standard gaussian density (2D)", {
p <- 2
Sigma <- diag(p)
mu <- c(10,0)
for(n in c(5,10,20,50,100)){
res <- intDensTri(mu = mu, Sigma = Sigma, n=n, x.min=0)
expect_equal(res$value,
1,
tol = 1e-6)
}
})
test_that("Integrate standard gaussian density (3D)", {
p <- 3
Sigma <- diag(p)
mu <- c(10,0,0)
for(n in c(5,10,20,50,100)){
res <- intDensTri(mu = mu, Sigma = Sigma, n=n, x.min=0, z.max=10)
expect_equal(res$value,
1,
tol = 1e-6)
}
})
# }}}
#----------------------------------------------------------------------
### test-intDensTri.R ends here
|