Skip to contents

Generate random variates from the Dirichlet distribution

Usage

rdir(n, alpha)

Arguments

n

Number of random variates to generate (single integer)

alpha

Concentration parameter (vector of positive numbers)

Value

An n by d matrix, where d is the length of alpha.

Examples

rdir(10, 1:4)
#>             [,1]       [,2]       [,3]      [,4]
#>  [1,] 0.30851215 0.19334775 0.08262365 0.4155164
#>  [2,] 0.00119423 0.16053261 0.16846392 0.6698092
#>  [3,] 0.11051988 0.20892246 0.15162045 0.5289372
#>  [4,] 0.01015862 0.19161373 0.18718857 0.6110391
#>  [5,] 0.05552366 0.42607656 0.29957400 0.2188258
#>  [6,] 0.09875354 0.10227381 0.47943576 0.3195369
#>  [7,] 0.14690634 0.14107160 0.52678450 0.1852376
#>  [8,] 0.05171136 0.09220846 0.17069595 0.6853842
#>  [9,] 0.08413149 0.22146371 0.24496082 0.4494440
#> [10,] 0.06189348 0.20430909 0.38429910 0.3494983