Dirichlet function

Dirichlet distribution

Dirichlet distribution

Density function, cumulative distribution function and random generation for the Dirichlet distribution.

ddirichlet(x, alpha, log = FALSE) rdirichlet(n, alpha)

Arguments

  • x: kk-column matrix of quantiles.
  • alpha: kk-values vector or kk-column matrix; concentration parameter. Must be positive.
  • log: logical; if TRUE, probabilities p are given as log(p).
  • n: number of observations. If length(n) > 1, the length is taken to be the number required.

Details

Probability density function

f(x)=Γ(kαk)kΓ(αk)kxkk1f(x)=Γ(sum(α[k]))/prod(Γ(α[k]))prod(x[k]k1) f(x) = \frac{\Gamma(\sum_k \alpha_k)}{\prod_k \Gamma(\alpha_k)} \prod_k x_k^{k-1}f(x) = \Gamma(sum(\alpha[k])) / prod(\Gamma(\alpha[k])) * prod(x[k]^{k-1})

Examples

# Generating 10 random draws from Dirichlet distribution # parametrized using a vector rdirichlet(10, c(1, 1, 1, 1)) # or parametrized using a matrix where each row # is a vector of parameters alpha <- matrix(c(1, 1, 1, 1:3, 7:9), ncol = 3, byrow = TRUE) rdirichlet(10, alpha)

References

Devroye, L. (1986). Non-Uniform Random Variate Generation. Springer-Verlag.

  • Maintainer: Tymoteusz Wolodzko
  • License: GPL-2
  • Last published: 2023-11-30