Learn R Programming

gtools (version 3.9.2)

dirichlet: Functions for the Dirichlet Distribution

Description

Functions to compute the density of or generate random deviates from the Dirichlet distribution

Usage

ddirichlet(x, alpha)

rdirichlet(n, alpha)

Arguments

x

A vector containing a single random deviate or matrix containing one random deviate per row.

alpha

Vector or (for ddirichlet) matrix containing shape parameters.

n

Number of random vectors to generate.

Value

ddirichlet returns a vector containing the Dirichlet density for the corresponding rows of x.

rdirichlet returns a matrix with n rows, each containing a single Dirichlet random deviate.

Functions

  • ddirichlet: Dirichlet distribution function.

  • rdirichlet: Generate dirichlet random deviates.

Details

The Dirichlet distribution is the multidimensional generalization of the beta distribution. It is the canonical Bayesian distribution for the parameter estimates of a multinomial distribution.

See Also

dbeta, rbeta

Examples

Run this code
# NOT RUN {

x <- rdirichlet(20, c(1, 1, 1))

ddirichlet(x, c(1, 1, 1))
# }

Run the code above in your browser using DataLab