Revision d2eac42f58e4e0f0d07298e8c2e719ef6a30672d authored by Dominique Makowski on 19 June 2020, 08:00:07 UTC, committed by cran-robot on 19 June 2020, 08:00:07 UTC
1 parent 01482dc
Raw File
test-estimate_density.R
if (require("logspline") && require("KernSmooth") && require("mclust")) {
  test_that("estimate_density", {
    set.seed(333)
    x <- distribution_normal(500, 1)

    # Methods
    density_kernel <- estimate_density(x, method = "kernel")
    density_logspline <- estimate_density(x, method = "logspline")
    density_KernSmooth <- estimate_density(x, method = "KernSmooth")
    density_mixture <- estimate_density(x, method = "mixture")

    testthat::expect_equal(mean(density_kernel$y - density_logspline$y), 0, tol = 0.1)
    testthat::expect_equal(mean(density_kernel$y - density_KernSmooth$y), 0, tol = 0.1)
    testthat::expect_equal(mean(density_kernel$y - density_mixture$y), 0, tol = 0.1)
  })
}
back to top