dirichlet | R Documentation |
Probability density function (PDF), cumulative density function
(CDF), and random generation for the Dirichlet distribution
with parameters \lapha = \alpha_1, ... , \alpha_n
, all positive reals,
in short, Dir(\alpha)
. 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)
x |
A numerical matrix |
alpha |
Dirichlet distribution's parameters. A numerical parameter
vector, strictly positive (default 1):
|
q |
numeric vector. |
lower.tail |
logical; if TRUE (default), probabilities are
|
log.p |
logical; if TRUE, probabilities/densities p are returned as log(p). |
log.base |
(Optional) The logarithm's base if log.p = TRUE. |
... |
Additional named or unnamed arguments to be passed to function
|
n |
number of observations. |
p |
vector of probabilities. |
interval |
The interval whether to search for the quantile (see Details). |
tol |
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 \alpha = \alpha_1, ... ,
\alpha_n
(all positive reals), in short, x ~ Dir(\alpha)
, then
x_i ~ Beta(\alpha_i, \alpha_0 - \alpha_i)
, where Beta(.) stands for the
Beta distribution and \alpha_0 = \sum \alpha_i
.
The density is computed directly from the logarithm of Dirichlet PDF
log(Dir(\alpha))
.
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 + \alpha_i)/(\sum 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)
))
head(x[[1]])
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
set.seed(123)
q <- rdirichlet(10, alpha = c(2.1, 3.2, 3.3))
pdirichlet(q, alpha = c(2.1, 3.2, 3.3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.