tests/testthat/surprisals.R

test_that("multiplication works", {
  set.seed(2)
  y <- c(rnorm(10), 100)
  expect_identical(max(surprisals(y, dist_normal())), Inf)
  expect_identical(max(surprisals(y, h = 1, loo = TRUE)), Inf)
  expect_equal(
    max(surprisals(y, h = 1, loo = FALSE)),
    log(11 / dnorm(0, 0, 1)),
    tolerance = 0.01
  )
})

Try the weird package in your browser

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

weird documentation built on Jan. 27, 2026, 9:06 a.m.