Nothing
library(testthat)
library(DistributionalDDA)
bdl = BDataDensities(list(fx(dnorm(x,1,1)),fx(dnorm(x,-1,1)) ),basis=B2N01Basis5,closed=TRUE)
lbdl = BDataLogDensities(list(fx(dnorm(x,1,1,log=TRUE)),fx(dnorm(x,-1,1,log=TRUE)) ),basis=B2N01Basis5,closed=TRUE)
test_that("Multiplication works as expected",{
bdl2=bdl*0.5
expect_equal(bdl2[[1]](-3:3), sqrt(dnorm(-3:3, 1,1)) )
expect_equal(bdl2[[2]](-3:3), sqrt(dnorm(-3:3, -1,1)) )
bdl2=0.5*bdl
expect_equal(bdl2[[1]](-3:3), sqrt(dnorm(-3:3, 1,1)) )
expect_equal(bdl2[[2]](-3:3), sqrt(dnorm(-3:3, -1,1)) )
lbdl2=lbdl*0.5
expect_equal(lbdl2[[1]](-3:3), 0.5*dnorm(-3:3, 1,1,log=TRUE))
expect_equal(lbdl2[[2]](-3:3), 0.5*dnorm(-3:3, -1,1,log=TRUE))
lbdl2=0.5*lbdl
expect_equal(lbdl2[[1]](-3:3), 0.5*dnorm(-3:3, 1,1,log=TRUE))
expect_equal(lbdl2[[2]](-3:3), 0.5*dnorm(-3:3, -1,1,log=TRUE) )
})
test_that("Division works as expected",{
bdl2=bdl/2
expect_equal(bdl2[[1]](-3:3), sqrt(dnorm(-3:3, 1,1)) )
expect_equal(bdl2[[2]](-3:3), sqrt(dnorm(-3:3, -1,1)) )
lbdl2=lbdl/2
expect_equal(lbdl2[[1]](-3:3), 0.5*dnorm(-3:3, 1,1,log=TRUE))
expect_equal(lbdl2[[2]](-3:3), 0.5*dnorm(-3:3, -1,1,log=TRUE) )
})
test_that("scale works as expected",{
bdl2=scale(bdl)
expect_equal(mean(bdl2)[[1]](-3:3), rep(1,7) )
expect_equal(msd(bdl2), 1,tolerance=1E-2)
lbdl2=scale(lbdl)
expect_equal(mean(lbdl2)[[1]](-3:3), rep(0,7) )
expect_equal(msd(lbdl2), 1,tolerance=1E-2)
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.