# NOT RUN {
n <- seq(1, 50, by=1/4)
st.n <- stirlerr(n) # now vectorized
stopifnot(identical(st.n, sapply(n, stirlerr)))
plot(n, st.n, type = "b", log="xy", ylab = "stirlerr(n)")
x <- 800:1200
bd0x1k <- bd0(x, np = 1000)
plot(x, bd0x1k, type="l", ylab = "bd0(x, np=1000)")
bd0x1kC <- bd0C(x, np = 1000)
lines(x, bd0x1kC, col=2)
stopifnot(all.equal(bd0x1kC, bd0x1k, tol=1e-15)) # even tol=0 currently ..
if(FALSE) ## FIXME !
ebd0x1k <- ebd0(x, 1000) # FIXME: subscript out of bout
if(FALSE) # the bug is only here:
ebd0(1001, 1000)
## so this works:
ex. <- ebd0(x[x != 1001], 1000)
## but there is more wrong currently:
lines(x[x!=1001], colSums(ex.), col=3)
x <- 1:80
dp <- dpois (x, 48, log=TRUE)# R's 'stats' pkg function
dp.r <- dpois_raw(x, 48, log=TRUE)
all.equal(dp, dp.r, tol = 0) # on Linux 64b, see TRUE
stopifnot(all.equal(dp, dp.r, tol = 1e-14))
# matplot(x, cbind(dp, dp.r), type = "b") # looks "ok", .. but not if you look closely:
# plot(x, dp.r - dp, type = "b",
# main = "dpois_raw(x, 48, log=T) - dpois(..) -- something's wrong!")
# abline(h=0, lty=3)
# }
Run the code above in your browser using DataLab