tests/testthat/test-inverse_cv.R

test_that("integral cv is reversible", {

  rand_var <- runif(1, 0.3, 3)
  tolerance <- 1/100

  lnorm_u <- exp(runif(1, -3, 3))
  lnorm_intcv <- dist.intcv("log", v=rand_var, exact=FALSE)
  lnorm_test <- invcv(dist.intcv("log",fun=TRUE), lnorm_intcv)
  expect_lt(abs(lnorm_test/rand_var - 1), tolerance)

  expect_message({invcv(dist.intcv("log",fun=TRUE), lnorm_intcv, verbose=TRUE)})

  logit_u <- runif(1, 0.001, 0.999)
  logit_intcv <- dist.intcv("logit", u=logit_u, v=rand_var)
  logit_test <- invcv(dist.intcv("logit",fun=TRUE), logit_intcv, u=logit_u)
  expect_lt(abs(logit_test/rand_var - 1), tolerance)

})

Try the pmxcv package in your browser

Any scripts or data that you put into this service are public.

pmxcv documentation built on May 29, 2024, 7:28 a.m.