hyperdirichlet (version 1.5-1)

dhyperdirichlet: Probability density function for, and random sampling from, the hyperdirichlet distribution

Description

Probability density function for the hyperdirichlet distribution in terms of either \(p\) or \(e\); and random sampling using Metropolis-Hastings

Usage

dhyperdirichlet_e(e, HD, include.Jacobian = TRUE)
dhyperdirichlet(p, HD, include.NC = FALSE, TINY = 1e-10, log = FALSE)
rhyperdirichlet(n, HD, start=NULL, sigma=NULL)

Arguments

HD
Object of class hyperdirichlet, or coerced thereto
p
Vector of length dim(HD), notionally summing to one
e
Vector of length dim(HD) giving the point in e-space
include.Jacobian
In function dhyperdiriclet_e(), Boolean with default TRUE meaning to include the Jabobian of the transform from e to p
include.NC
In function dhyperdirichlet_e(), Boolean with TRUE meaning to include the normalization factor and default FALSE meaning not to include it (it is expensive to calculate). Note that if the normalizing factor is not known, the function will return NA
TINY
In function dhyperdirichlet_p(), numeric, specifying minimum size for elements of p via p <- pmax(p , TINY)
log
In function dhyperdirichlet_p(), Boolean with default FALSE meaning to return the probability density and TRUE meaning to return its logarithm
n,start,sigma
In function rhyperdirichlet(), n is the number of observations to take, start is the start-point for the random walk (with default NULL meaning to use the neutral point), and sigmais the standard deviation for the (Gaussian) kernel, with default NULL meaning to use \(1/d\)

Value

Functions dhyperdirichlet() and dhyperdirichlet_e() return a scalar; function rhyperdirichlet() returns a matrix whose rows are \(k\)-tuples

Details

Function dhyperdirichlet() gives the density as a function of the \(p_1,p_2,\ldots,p_d\).

Function dhyperdirichlet_e() gives the density as a function of the \(e_i\). This is useful when integrating as the simplex (in p-space) transforms to a hypercube in e-space.

See Also

maximum.likelihood,e_to_p

Examples

Run this code

dhyperdirichlet(c(1,4,3,2)/10, dirichlet(1:4))

rhyperdirichlet(20, dirichlet(1:3))

diff(c(0,sort(runif(9)),1))  # random sample drawn from dirichlet(rep(1,10))

# how to draw a single observation from the hyperdirichlet:
f <- function(HD,n,...){rhyperdirichlet(n,HD=HD,...)[n,,drop=TRUE]}
f(dirichlet(1:3),n=100)
f(dirichlet(1:3),n=100)
f(dirichlet(1:3),n=100)
# Note, n=100 might not be enough burn-in.


Run the code above in your browser using DataLab