(a <- uniform(3))
a[c(TRUE,TRUE,FALSE)] <- 0.3
## Not run: ------------------------------------
# (a <- as.hyperdirichlet(a, calculate_NC = TRUE)) # recommended way to calculate NC
## ---------------------------------------------
(b <- dirichlet(1:3))
as.hyperdirichlet(b) # "forgets" the normalizing constant
## Not run: ------------------------------------
# as.hyperdirichlet(b, TRUE) # recalculates NC; accuracy tolerable
# # (analytic answer = 1/60)
## ---------------------------------------------
## Not run: ------------------------------------
# # takes a long time
# op <- options()
# options(warn = -1)
# x <- dirichlet(rep(2,4)) + justpairs(matrix(1,4,4))
# f <- function(p){p[1]>p[2]}
# probability(x,f) # should be 0.5: distribution is symmetric
## ---------------------------------------------
# following example reveals a bug in versions <= 1.3:
d <- dirichlet(1:3)
colMeans(rhyperdirichlet(1e3,d))
# result should be (1:3)/6
# implementation >= 1.4 includes a bugfix sent by Simon Byrne
Run the code above in your browser using DataLab