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.13417634 0.36680098 0.3383995 0.1606232
#>  [2,] 0.05805035 0.04131253 0.1753228 0.7253143
#>  [3,] 0.02065122 0.11792930 0.5863976 0.2750219
#>  [4,] 0.27460294 0.19772422 0.3433026 0.1843702
#>  [5,] 0.27842104 0.11901622 0.3217872 0.2807755
#>  [6,] 0.00812042 0.29817762 0.0736191 0.6200829
#>  [7,] 0.05462943 0.37344613 0.2248994 0.3470250
#>  [8,] 0.05049196 0.50056208 0.1893589 0.2595870
#>  [9,] 0.23364859 0.17407919 0.5028814 0.0893908
#> [10,] 0.04958958 0.15716435 0.5868775 0.2063686