Learn R Programming

MultiRNG (version 1.2.4)

draw.dirichlet: Pseudo-Random Number Generation under Multivariate Beta (Dirichlet) Distribution

Description

This function implements pseudo-random number generation for a multivariate beta (Dirichlet) distribution with pdf

$$f(x|\alpha_{1},...,\alpha_{d})=\frac{\Gamma(\sum_{j=1}^{d}\alpha_{j})}{\prod_{j=1}^{d}\Gamma(\alpha_{j})} \prod_{j=1}^{d}x_{j}^{\alpha_{j}-1}$$

for \(\alpha_{j}>0\), \(x_{j}\geq 0\), and \(\sum_{j=1}^{d}x_{j}=1\), where \(\alpha_{1},...,\alpha_{d}\) are the shape parameters and \(\beta\) is a common scale paramter.

Usage

draw.dirichlet(no.row,d,alpha,beta)

Arguments

no.row

Number of rows to generate.

d

Number of variables to generate.

alpha

Vector of shape parameters.

beta

Scale parameter common to \(d\) variables.

Value

A \(no.row \times d\) matrix of generated data.

Examples

Run this code
# NOT RUN {
alpha.vec=c(1,3,4,4)
mydata=draw.dirichlet(no.row=1e5,d=4,alpha=alpha.vec,beta=2)
apply(mydata,2,mean)-alpha.vec/sum(alpha.vec)
# }

Run the code above in your browser using DataLab