diff --git a/tests/testthat/test_kldstudent.R b/tests/testthat/test_kldstudent.R index d9254b88bb2379e01fe0a61c3c7428a0e6a645a7..a4bf739594ed559ca44dd0ad2157cf4bb887377c 100644 --- a/tests/testthat/test_kldstudent.R +++ b/tests/testthat/test_kldstudent.R @@ -3,8 +3,8 @@ Sigma1 <- 0.5 Sigma2 <- 1 -kl1_12 <- kld(Sigma1, Sigma2, distribution = "mtd", nu1 = 1, nu2 = 1, eps = 1e-16) -kl1_21 <- kld(Sigma2, Sigma1, distribution = "mtd", nu1 = 1, nu2 = 1, eps = 1e-16) +kl1_12 <- kldstudent(nu1 = 1, Sigma1, nu2 = 1, Sigma2, eps = 1e-16) +kl1_21 <- kldstudent(nu1 = 1, Sigma2, nu2 = 1, Sigma1, eps = 1e-16) lambda <- 0.5 @@ -24,8 +24,8 @@ test_that("kl works (dim 1)", { Sigma1 <- diag(0.5, nrow = 2) Sigma2 <- diag(1, nrow = 2) -kl2_12 <- kld(Sigma1, Sigma2, distribution = "mtd", nu1 = 1, nu2 = 1, eps = 1e-16) -kl2_21 <- kld(Sigma2, Sigma1, distribution = "mtd", nu1 = 1, nu2 = 1, eps = 1e-16) +kl2_12 <- kldstudent(nu1 = 1, Sigma1, nu2 = 1, Sigma2, eps = 1e-16) +kl2_21 <- kldstudent(nu1 = 1, Sigma2, nu2 = 1, Sigma1, eps = 1e-16) lambda <- as.complex(0.5) @@ -47,7 +47,7 @@ Sigma2 <- diag(nrow = 2) lambda <- 0.5 -kl2 <- kld(Sigma1, Sigma2, distribution = "mtd", nu1 = 1, nu2 = 1, eps = 1e-16) +kl2 <- kldstudent(nu1 = 1, Sigma1, nu2 = 1, Sigma2, eps = 1e-16) test_that("kl works (dim 2, one of the eigenvalues = 1)", { expect_equal( @@ -65,8 +65,8 @@ Sigma2 <- rbind(c(1, 0.3, 0.1), c(0.3, 1, 0.4), c(0.1, 0.4, 1)) lambda <- 0.5 -kl3_12 <- kld(Sigma1, Sigma2, distribution = "mtd", nu1 = nu1, nu2 = nu2, eps = 1e-8) -kl3_21 <- kld(Sigma2, Sigma1, distribution = "mtd", nu1 = nu1, nu2 = nu2, eps = 5e-5) +kl3_12 <- kldstudent(nu1, Sigma1, nu2, Sigma2, eps = 1e-8) +kl3_21 <- kldstudent(nu1, Sigma2, nu2, Sigma1, eps = 5e-5) test_that("kl works (dim 3)", { expect_equal( attr(kl3_12, "epsilon"), 1e-8 @@ -74,7 +74,7 @@ test_that("kl works (dim 3)", { expect_equal( round(as.numeric(kl3_12), 16), 0.9297752865860369 ) - + expect_equal( attr(kl3_21, "epsilon"), 5e-5 ) @@ -88,8 +88,7 @@ test_that("kl works (dim 3)", { Sigma1 <- 2*rbind(c(1, 0.6, 0.2), c(0.6, 1, 0.3), c(0.2, 0.3, 1)) Sigma2 <- rbind(c(1, 0.3, 0.1), c(0.3, 1, 0.4), c(0.1, 0.4, 1)) -kl3 <- kld(Sigma1, Sigma2, distribution = "mtd", nu1 = nu1, nu2 = nu2, eps = 1e-16) -Sigma2 <- rbind(c(1, 0.3, 0.1), c(0.3, 1, 0.4), c(0.1, 0.4, 1)) +kl3 <- kldstudent(nu1, Sigma1, nu2, Sigma2, eps = 1e-16) test_that("kl12 works (dim 3, 2nd)", { expect_equal( @@ -111,8 +110,8 @@ Sigma2 <- rbind(c(1, 0.3, 0.1, 0), c(0.1, 0.4, 1, 0), c(0, 0, 0, 1)) -kl4_12 <- kld(Sigma1, Sigma2, distribution = "mtd", nu1 = nu1, nu2 = nu2, eps = 1e-6) -kl4_21 <- kld(Sigma2, Sigma1, distribution = "mtd", nu1 = nu1, nu2 = nu2, eps = 1e-6) +kl4_12 <- kldstudent(nu1, Sigma1, nu2, Sigma2, eps = 1e-6) +kl4_21 <- kldstudent(nu1, Sigma2, nu2, Sigma1, eps = 1e-6) test_that("kl12 works (dim 4)", { expect_equal( @@ -121,7 +120,7 @@ test_that("kl12 works (dim 4)", { expect_equal( round(as.numeric(kl4_12), 16), 1.039925196101446 ) - + expect_equal( attr(kl4_21, "epsilon"), 1e-06 )