Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Dirichlet

Dirichlet distribution


Description

Random number generation for the Dirichlet distribution D(alpha[1],...,alpha[K]).

Usage

rDirichlet(n, alpha=c(1, 1))

Arguments

n

number of observations to be sampled.

alpha

parameters of the Dirichlet distribution (‘prior sample sizes’).

Value

Some objects.

Value for rDirichlet

A matrix with sampled values.

Author(s)

References

Devroye, L. (1986). Non-Uniform Random Variate Generation. New York: Springer-Verlag, Chap. XI.

Gelman, A., Carlin, J. B., Stern, H. S., and Rubin, D. B. (2004). Bayesian Data Analysis. Second Edition. Boca Raton: Chapman and Hall/CRC, pp. 576, 582.

See Also

Examples

set.seed(1977)

alpha <- c(1, 2, 3)
Mean <- alpha/sum(alpha)
Var <- -(alpha %*% t(alpha))
diag(Var) <- diag(Var) + alpha*sum(alpha)
Var <- Var/(sum(alpha)^2*(1+sum(alpha)))
x <- rDirichlet(1000, alpha=alpha)
x[1:5,]

apply(x, 1, sum)[1:5]           ### should be all ones
rbind(Mean, apply(x, 2, mean))

var(x)
print(Var)

mixAK

Multivariate Normal Mixture Models and Mixtures of Generalized Linear Mixed Models Including Model Based Clustering

v5.3
GPL (>= 3)
Authors
Arnošt Komárek <arnost.komarek@mff.cuni.cz>
Initial release
2020-06-02

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.