Learn R Programming

hyperdirichlet (version 1.3-8)

hyperdirichlet: The Hyperdirichlet distribution

Description

Create, coerce to, or test for an object of class hyperdirichlet

Usage

hyperdirichlet(x, NC, pnames = character(), validated=FALSE)
is.hyperdirichlet(x)
as.hyperdirichlet(x, calculate_NC = FALSE , ...)

Arguments

x
Object to be coerced or tested for
NC
Normalizing constant
pnames
names of the columns with length-0 default resulting in the print method using column names p1, p2, etc
validated
Boolean. Setting to TRUE is taken to mean that x is known to be proper (i.e. x is normalizable), but the normalizing constant is not necessarily known.
calculate_NC
Boolean, with default FALSE meaning not to calculate the normalizing constant and TRUE meaning to calculate it
...
Further arguments passed to adapt()

Value

  • Functions hyperdirichlet() and as.hyperdirichlet() return a hyperdirichlet object; function is.hyperdirichlet() returns a Boolean.

Details

To determine the normalization constant, use something like a <- as.hyperdirichlet(a,calculate_NC= TRUE).

Matrices may be coerced to a hyperdichlet object using as.hyperdirichlet(): the call is dispatched to matrix_to_HD() (qv).

If x is a matrix, be sure to specify the bernoulli argument, which is passed on to matrix_to_HD()

See Also

B,extract,matrix_to_HD

Examples

Run this code
(a <- uniform(3))
a[c(TRUE,TRUE,FALSE)] <- 0.3
(a <- as.hyperdirichlet(a, calculate_NC = TRUE))  # recommended way to calculate NC

(b <- dirichlet(1:3))
as.hyperdirichlet(b)          # "forgets" the normalizing constant

as.hyperdirichlet(b, TRUE)    # recalculates NC; accuracy tolerable
                              # (analytic answer = 1/60)

# 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

Run the code above in your browser using DataLab