rdirichlet {bayess}R Documentation

Random generator for the Dirichlet distribution

Description

This function simulates a sample from a Dirichlet distribution on the k dimensional simplex with arbitrary parameters. The simulation is based on a renormalised vector of gamma variates.

Usage

rdirichlet(n = 1, par = rep(1, 2))

Arguments

n

number of simulations

par

parameters of the Dirichlet distribution, whose length determines the value of k

Details

Surprisingly, there is no default Dirichlet distribution generator in the R base packages like MASS or stats. This function can be used in full generality, apart from the book (Chapter 6).

Value

returns a n by k matrix of Dirichlet simulations

Examples

apply(rdirichlet(10,rep(3,5)),2,mean)

[Package bayess version 1.4 Index]