dirichlet: Dirichlet Distribution

dirichletR Documentation

Dirichlet Distribution


Probability density function (PDF), cumulative density function (CDF), and random generation for the Dirichlet distribution with parameters \lapha = α_1, ... , α_n, all positive reals, in short, Dir(α). Dirichlet distribution is a family of continuous multivariate probability distributions, a multivariate generalization of the Beta distribution. The PDF is a multidimensional generalization of the beta distribution.


ddirichlet(x, alpha, log = FALSE)

pdirichlet(q, alpha, lower.tail = TRUE, log.p = FALSE, log.base = exp(1), ...)

rdirichlet(n, alpha)



A numerical matrix x_ij >= 0 or vector x_i >= 0 of observed counts or relative frequencies ∑ x_i = 1.


Dirichlet distribution's parameters. A numerical parameter vector, strictly positive (default 1): \lapha = α_1, ... , α_n.


numeric vector.


logical; if TRUE (default), probabilities are P(X<=x), otherwise, P(X > x)


logical; if TRUE, probabilities/densities p are returned as log(p).


(Optional) The logarithm's base if log.p = TRUE.


Additional named or unnamed arguments to be passed to function hcubature used in functions 'pdirichlet' and 'qdirichlet'.


number of observations.


vector of probabilities.


The interval whether to search for the quantile (see Details).


The desired accuracy (convergence tolerance) for the quantile estimation.


The computation of the function 'pdirichlet' is accomplished using Monte Carlo integration of the density 'dirichlet'. The estimation are based on the fact that if a variable x = (x_1, x_2, ...x_n) follows Dirichlet Distribution with parameters α = α_1, ... , α_n (all positive reals), in short, x ~ Dir(α), then x_i ~ Beta(α_i, α_0 - α_i), where Beta(.) stands for the Beta distribution and α_0 = ∑ α_i.

The density is computed directly from the logarithm of Dirichlet PDF log(Dir(α)).

if x = (x_1, x_2, ...x_n) are observed counts, then they are transformed estimated probability p_i of the observation x_i is estimated as: p_i = (x_i + α_i)/(∑ x_i + sum \alpa_i).


GG PDF values (3-parameters or 4-parameters) for ddirichlet, GG probability for pdirichlet, quantiles or GG random generated values for rdirichlet.


Robersy Sanchez (https://genomaths.com).


1. Sjolander K, Karplus K, Brown M, Hughey R, Krogh A, Saira Mian I, et al. Dirichlet mixtures: A method for improved detection of weak but significant protein sequence homology. Bioinformatics. 1996;12: 327–345. doi:10.1093/bioinformatics/12.4.327.


## A random generation of numerical vectors
x <- rdirichlet(n = 1e3, alpha = rbind(
    c(2.1, 3.1, 1.2),
    c(2.5, 1.9, 1.6)
lapply(x, estimateDirichDist)

### Density computation
alpha <- cbind(1:10, 5, 10:1)
x <- rdirichlet(10, c(5, 5, 10))
ddirichlet(x = x, alpha = alpha)

### Or just one vector alpha
x <- rdirichlet(n = 10, alpha = c(2.1, 3.1, 1.2))
ddirichlet(x = x, alpha = c(2.1, 3.1, 1.2))

## Compute Dirichlet probability
q <- rdirichlet(10, alpha = c(2.1, 3.2, 3.3))
pdirichlet(q, alpha = c(2.1, 3.2, 3.3))

genomaths/usefr documentation built on July 28, 2022, 12:31 p.m.