Description Usage Arguments Details Value Note Author(s) See Also Examples
Probability density function for the hyperdirichlet distribution in terms of either p or e; and random sampling using Metropolis-Hastings
1 2 3 | 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)
|
HD |
Object of class |
p |
Vector of length |
e |
Vector of length |
include.Jacobian |
In function |
include.NC |
In function |
TINY |
In function |
log |
In function |
n,start,sigma |
In function |
Function dhyperdirichlet()
gives the density as a function of
the p_1, ..., 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.
Functions dhyperdirichlet()
and dhyperdirichlet_e()
return a scalar; function rhyperdirichlet()
returns a matrix
whose rows are k-tuples
Function rhyperdirichlet()
uses a Metropolis-Hastings algorithm
to construct a Markov chain. Note that successive observations are
not independent of one another. The details of this nonindependence
are poorly understood (by me, at any rate). The examples section
below shows how to generate a single random observation from the
hyperdirichlet distribution.
Function dhyperdirichlet()
silently normalizes p
by
p <- p/sum(p)
. Currently, no check for the elements being
positive is made (negative elements are nullified by TINY
).
The relationship between e and p is given in
e_to_p.Rd
.
Robin K. S. Hankin
1 2 3 4 5 6 7 8 9 10 11 12 | 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.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.