17
This article was downloaded by: [Florida International University] On: 21 December 2014, At: 12:20 Publisher: Taylor & Francis Informa Ltd Registered in England and Wales Registered Number: 1072954 Registered office: Mortimer House, 37-41 Mortimer Street, London W1T 3JH, UK Journal of Statistical Computation and Simulation Publication details, including instructions for authors and subscription information: http://www.tandfonline.com/loi/gscs20 Evaluation of algorithms for generating Dirichlet random vectors Y. C. Hung a , N. Balakrishnan b & C. W. Cheng c a Department of Statistics , National Chengchi University , Taipei, 11605, Taiwan, Republic of China b Department of Mathematics and Statistics , McMaster University , Hamilton, ON, Canada , L8S 4K1 c Graduate Institute of Statistics , National Central University , Jhongli, 32049, Taiwan, Republic of China Published online: 02 Jun 2010. To cite this article: Y. C. Hung , N. Balakrishnan & C. W. Cheng (2011) Evaluation of algorithms for generating Dirichlet random vectors, Journal of Statistical Computation and Simulation, 81:4, 445-459, DOI: 10.1080/00949650903409999 To link to this article: http://dx.doi.org/10.1080/00949650903409999 PLEASE SCROLL DOWN FOR ARTICLE Taylor & Francis makes every effort to ensure the accuracy of all the information (the “Content”) contained in the publications on our platform. However, Taylor & Francis, our agents, and our licensors make no representations or warranties whatsoever as to the accuracy, completeness, or suitability for any purpose of the Content. Any opinions and views expressed in this publication are the opinions and views of the authors, and are not the views of or endorsed by Taylor & Francis. The accuracy of the Content should not be relied upon and should be independently verified with primary sources of information. Taylor and Francis shall not be liable for any losses, actions, claims, proceedings, demands, costs, expenses, damages, and other liabilities whatsoever or howsoever caused arising directly or indirectly in connection with, in relation to or arising out of the use of the Content. This article may be used for research, teaching, and private study purposes. Any substantial or systematic reproduction, redistribution, reselling, loan, sub-licensing, systematic supply, or distribution in any form to anyone is expressly forbidden. Terms &

Evaluation of algorithms for generating Dirichlet random vectors

  • Upload
    c-w

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Evaluation of algorithms for generating Dirichlet random vectors

This article was downloaded by: [Florida International University]On: 21 December 2014, At: 12:20Publisher: Taylor & FrancisInforma Ltd Registered in England and Wales Registered Number: 1072954 Registeredoffice: Mortimer House, 37-41 Mortimer Street, London W1T 3JH, UK

Journal of Statistical Computation andSimulationPublication details, including instructions for authors andsubscription information:http://www.tandfonline.com/loi/gscs20

Evaluation of algorithms for generatingDirichlet random vectorsY. C. Hung a , N. Balakrishnan b & C. W. Cheng ca Department of Statistics , National Chengchi University , Taipei,11605, Taiwan, Republic of Chinab Department of Mathematics and Statistics , McMasterUniversity , Hamilton, ON, Canada , L8S 4K1c Graduate Institute of Statistics , National Central University ,Jhongli, 32049, Taiwan, Republic of ChinaPublished online: 02 Jun 2010.

To cite this article: Y. C. Hung , N. Balakrishnan & C. W. Cheng (2011) Evaluation of algorithmsfor generating Dirichlet random vectors, Journal of Statistical Computation and Simulation, 81:4,445-459, DOI: 10.1080/00949650903409999

To link to this article: http://dx.doi.org/10.1080/00949650903409999

PLEASE SCROLL DOWN FOR ARTICLE

Taylor & Francis makes every effort to ensure the accuracy of all the information (the“Content”) contained in the publications on our platform. However, Taylor & Francis,our agents, and our licensors make no representations or warranties whatsoever as tothe accuracy, completeness, or suitability for any purpose of the Content. Any opinionsand views expressed in this publication are the opinions and views of the authors,and are not the views of or endorsed by Taylor & Francis. The accuracy of the Contentshould not be relied upon and should be independently verified with primary sourcesof information. Taylor and Francis shall not be liable for any losses, actions, claims,proceedings, demands, costs, expenses, damages, and other liabilities whatsoever orhowsoever caused arising directly or indirectly in connection with, in relation to or arisingout of the use of the Content.

This article may be used for research, teaching, and private study purposes. Anysubstantial or systematic reproduction, redistribution, reselling, loan, sub-licensing,systematic supply, or distribution in any form to anyone is expressly forbidden. Terms &

Page 2: Evaluation of algorithms for generating Dirichlet random vectors

Conditions of access and use can be found at http://www.tandfonline.com/page/terms-and-conditions

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14

Page 3: Evaluation of algorithms for generating Dirichlet random vectors

Journal of Statistical Computation and SimulationVol. 81, No. 4, April 2011, 445–459

Evaluation of algorithms for generating Dirichletrandom vectors

Y.C. Hunga*, N. Balakrishnanb and C.W. Chengc

aDepartment of Statistics, National Chengchi University, Taipei 11605, Taiwan, Republic of China;bDepartment of Mathematics and Statistics, McMaster University, Hamilton, ON, Canada L8S 4K1;

cGraduate Institute of Statistics, National Central University, Jhongli 32049, Taiwan, Republic of China

(Received 27 May 2009; final version received 12 October 2009 )

In this article, we describe various well-known Dirichlet generation algorithms and evaluate their perfor-mance in terms of the following criteria: (i) computer generation time, (ii) sensitivity, and (iii) goodnessof fit. In addition, we examine in particular an algorithm based on transformation of beta variates andprovide three useful guidelines so as to reduce its computer generation time. Simulation results show thatthe proposed algorithm significantly outperforms other approaches in terms of computer generation time,except in cases when all (or most) shape parameters are close to zero.

Keywords: Dirichlet random vector; computer generation time; sensitivity analysis; multivariate goodnessof fit

AMS Subject Classification: 65C10; 68Q25; 60E05

1. Introduction

A k-variate random vector (Y1, . . . , Yk) is said to have a Dirichlet (α1, . . . , αk+1) distribution iftheir joint density function is given by

fY1,...,Yk(y1, . . . , yk) = �(α1 + · · · + αk+1)

�(α1) · · · �(αk+1)y

α1−11 y

α2−12 · · · yαk−1

k (1 − y1 − · · · − yk)αk+1−1, (1)

where yi ≥ 0 for all i = 1, . . . , k,∑k

i=1 yi ≤ 1, and α1, . . . , αk+1 are all positive shapeparameters.

The Dirichlet distribution is used extensively in a wide array of problems. For example, it isused in analysing the correlation structure(s) among proportions of interest [1,2], for estimatingthe number of species [3], to model transition probabilities in Markovian brand switching mod-els [4], to model the consumer purchasing behaviour for non-durable items [5], as a convenientconjugate prior in non-parametric Bayesian modelling [6,7], and to model the word/text bursti-ness in machine learning [8]. Although theoretical results on the Dirichlet distribution have been

*Corresponding author. Email: [email protected]

ISSN 0094-9655 print/ISSN 1563-5163 online© 2011 Taylor & FrancisDOI: 10.1080/00949650903409999http://www.informaworld.com

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14

Page 4: Evaluation of algorithms for generating Dirichlet random vectors

446 Y.C. Hung et al.

well developed [9,10], not much work has been done specifically on the computer generation ofDirichlet random vectors.

The simulation study of Dirichlet generation algorithms was carried out by Loukas [11], whereinmethods for generating the bivariate beta distribution were compared. Narayanan [12] introducedfive simple algorithms (DIR-1 to DIR-5) for the generation of Dirichlet random vectors andevaluated their performance in terms of computer generation time. These five algorithms basi-cally implemented the following methods: (i) the multivaraite extension of Jöhnk’s method [13],(ii) the transformation method based on gamma variates, (iii) the transformation method basedon beta variates, (iv) the rejection method with uniform proposal density, and (v) the rejec-tion method with power proposal density. However, since this simulation study is dated nowand that most of the random number generators used in that study are old, it is thereforenecessary to carry out a new simulation study by incorporating current information into thesealgorithms.

The primary goal of this study is to improve the existing Dirichlet generation algorithms andthen evaluate their performance using different criteria. In particular, we examine an algorithmbased on transformation of beta variates and provide three useful guidelines so as to improve itscomputer generation time. The rest of the paper is organized as follows. In Section 2, we reviewfive methods of generating Dirichlet random vectors. For the method based on transformationof beta variates, we provide three useful guidelines that can be utilized in order to reduce itscomputer generation time. In Section 3, we evaluate the performance of all the Dirichlet generationalgorithms in terms of the following criteria: (i) computer generation time, (ii) sensitivity, and(iii) goodness of fit. For comparative purposes, the statistical software packages R and SASare also included in this simulation analysis. Finally, some concluding remarks are made inSection 4.

2. Dirichlet generation algorithms

In this section, we first describe five different methods for generating Dirichlet random vectors.We then focus on a particular method based on transformation of beta variates and provide usefulguidelines in order to reduce its computer generation time.

2.1. Method based on order statistics

Wilks [14] showed that a Dirichlet random vector with integer-valued shape parameters can begenerated by the following method. When αi ∈ Z

+ for all i, consider (∑k+1

j=1 αj − 1) independentUniform(0, 1) random variables and denote their order statistics by U(1), U(2), . . . , U(

∑k+1j=1 αj −1).

Let Ti = U(∑i

j=1 αj )for i = 1, . . . , k and Y1 = T1, Yi = Ti − Ti−1 for i = 2, . . . , k. Then, the

random vector (Y1, . . . , Yk) has a Dirichlet(α1, . . . , αk+1) distribution. The following algorithmis used for this method.

Algorithm OS (αi ∈ Z+ for all i)

Step 1: Generate independent (∑k+1

j=1 αj − 1) Uniform(0, 1) random numbers and let U(1) ≤U(2) ≤ · · · ≤ U(

∑k+1j=1 αj −1) be their order statistics;

Step 2: Set Ti = U(∑i

j=1 αj )for i = 1, . . . , k;

Step 3: Set Y1 = T1 and Yi = Ti − Ti−1 for i = 2, . . . , k;Step 4: Return (Y1, . . . , Yk).

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14

Page 5: Evaluation of algorithms for generating Dirichlet random vectors

Journal of Statistical Computation and Simulation 447

2.2. Multivariate extension of Jöhnk’s method

Jöhnk [13] proposed a simple method for generating beta variates based on the power densityfunction. Narayanan [12] introduced the following multivariate extension of Jöhnk’s method forgenerating the Dirichlet random vectors. Let U1, . . . , Uk+1 be independent Uniform(0, 1) randomvariables, and let X1 = U

1/α11 , X2 = U

1/α22 , . . . , Xk+1 = U

1/αk+1k+1 . If X1 + X2 + · · · + Xk+1 ≤ 1,

then(X1/

∑k+1i=1 Xi, . . . , Xk/

∑k+1i=1 Xi

)has a Dirichlet(α1, . . . , αk+1)distribution. The following

algorithm is used for this method.

Algorithm JK (αi > 0 for all i)

Step 1: Generate (k + 1) independent Uniform(0, 1) random numbers U1, . . . , Uk+1;Step 2: Set X1 = U

1/α11 , . . . , Xk+1 = U

1/αk+1k+1 ;

Step 3: If X1 + · · · + Xk+1 ≤ 1, set Yi = Xi/∑k+1

j=1 Xj for i = 1, . . . , k, and return (Y1, . . . , Yk);otherwise, go to Step 1.

2.3. Transformation based on gamma variates

The Dirichlet random vector can be generated by considering its relationship with gamma variates.Hogg and Craig [15] established the result that if X1, . . . , Xk+1 are (k + 1) independent gammarandom variables with Xi ∼ Gamma(αi, 1), i = 1, . . . , k + 1, and Yj = Xj/

∑k+1i=1 Xi for j =

1, . . . , k, (Y1, . . . , Yk) has a Dirichlet(α1, . . . , αk+1) distribution. The algorithm based on thisresult is as follows.

Algorithm GAMMA (αi > 0 for all i)

Step 1: Generate independent gamma random variables X1, . . . , Xk+1 with Xi ∼ Gamma(αi, 1),i = 1, . . . , k + 1;

Step 2: Set Yi = Xi/∑k+1

j=1 Xj for i = 1, . . . , k;Step 3: Return (Y1, . . . , Yk).

Note that the above algorithm is also called ‘DIR-2’ in [12], where all gamma variates weregenerated using the subroutine GGAMR in IMSL [16]. Since the subroutine GGAMR is dated now,we can improve this algorithm by choosing a more efficient Gamma(α, 1) generator. Recently,Tanizaki [17] performed an empirical study on several current gamma generation algorithms.Based on his study, we can choose the most efficient Gamma(α, 1) generator with the followingguideline:

• for 0 < α < 1, choose the RGS algorithm of Best [18];• for α > 1, choose the algorithm of Marsaglia and Tsang [19].

In our comparative study, the above guideline was automatically incorporated into AlgorithmGAMMA.

2.4. Multivariate acceptance–rejection methods

The acceptance–rejection method (or simply, the rejection method) is the most commonly usedtechnique for generating random variables. Its idea can be suitably extended for generatingrandom vectors. To be specific, suppose we wish to generate a k-dimensional random vector

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14

Page 6: Evaluation of algorithms for generating Dirichlet random vectors

448 Y.C. Hung et al.

(Y1, . . . , Yk) with joint density fY1,...,Yk(y1, . . . , yk). The first step is to choose a proposal density

fX1,...,Xk(x1, . . . , xk), with (X1, . . . , Xk) having the same support as (Y1, . . . , Yk), satisfying

M = supy1,...,yk

fY1,...,Yk(y1, . . . , yk)

fX1,...,Xk(y1, . . . , yk)

< ∞. (2)

In the second step, a random vector (x1, . . . , xk) is generated from the proposal density, and arandom variable U is generated from Uniform(0, 1). The idea of the rejection method is that, if

U ≤ fY1,...,Yk(x1, . . . , xk)

MfX1,...,Xk(x1, . . . , xk)

, (3)

then accept the generated realization (x1, . . . , xk); otherwise, repeat the same procedure untilEquation (3) is satisfied.

To generate the Dirichlet random vector, Narayanan [12] suggested two choices for the proposaldensity – the uniform and the power density function. Details of how to implement the rejectionmethod by utilizing these two proposal densities are given next.

2.4.1. The uniform proposal density

Since the Dirichlet random vector has a bounded support, a simple choice for the proposal densityis a constant function (i.e. the uniform density) of the form

fX1,...,Xk(x1, . . . , xk) = k!, (4)

where xi ≥ 0 for all i = 1, . . . , k,∑k

i=1 xi ≤ 1.Note that in order to satisfy Equation (2), the employment of uniform proposal density in

Equation (4) leads to a natural constraint on the shape parameters of the generated Dirichletrandom vectors, viz., αi ≥ 1 for all i. The algorithm of the rejection method based on the uniformproposal density is then as follows:

Algorithm Rejection-U (αi ≥ 1 for all i)

Step 1: Generate independent Uniform(0, 1) random numbers U1, . . . , Uk until U1 + · · · +Uk ≤ 1;

Step 2: Generate a Uniform(0, 1) random number V ;

Step 3: If V(α1 − 1)α1−1 · · · (αk+1 − 1)αk+1−1

(α1 + · · · + αk+1 − (k + 1))α1+···+αk+1−(k+1)< U

α1−11 · · · Uαk−1

k(1 − ∑k

i=1 Ui

)αk+1−1, return (U1, . . . , Uk); otherwise, go to Step 1.

2.4.2. The power proposal density

An alternative choice for the proposal density is the power function density of the form

fX1,...,Xk(x1, . . . , xk) = �(α1 + · · · + αk + 1)

�(α1) · · · �(αk)x

α1−11 · · · xαk−1

k , (5)

where xi ≥ 0 for all i = 1, . . . , k,∑k

i=1 xi ≤ 1. The advantage of choosing the power proposaldensity is that the condition in Equation (3) provides a relaxed constraint on the shape parametersof the generated Dirichlet random vectors, viz., that αk+1 ≥ 1. Therefore, it can be viewed as

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14

Page 7: Evaluation of algorithms for generating Dirichlet random vectors

Journal of Statistical Computation and Simulation 449

a modification of the rejection method that employs the uniform proposal density. Note that toimplement this method, an algorithm called DIR-5 was given [12]. However, it appears that thestatements in the first two steps of DIR-5 algorithm were incorrectly placed. So, we made somechanges and the corrected algorithm is as follows.

Algorithm Rejection-P (αk+1 ≥ 1)

Step 1: Generate independent Uniform(0, 1) random numbers U1, . . . , Uk , and set Yi = U1/αi

i

for i = 1, . . . , k until∑k

i=1 Yi ≤ 1;Step 2: Generate a Uniform(0, 1) random number V , and set W = V 1/(αk+1−1);Step 3: If W ≤ 1 − ∑k

i=1 Yi , return (Y1, . . . , Yk); otherwise, go to Step 1.

2.5. Transformation based on beta variates

It is known that the marginal distributions of Dirichlet random elements are beta distribu-tions. Thus, the Dirichlet random vector can be generated by considering the transformationbased on beta variates. Narayanan [12] stated the following result. If X1, . . . , Xk are inde-pendent beta random variables with Xi ∼ Beta(αi, αi+1 + · · · + αk+1), i = 1, . . . , k, then byletting Y1 = X1, Yi = Xi

∏i−1j=1(1 − Xj) for i = 2, . . . , k, the random vector (Y1, . . . , Yk) has a

Dirichlet(α1, . . . , αk+1) distribution. The algorithm based on this result is as follows.

Algorithm BETA (αi > 0 for all i)

Step 1: Generate independent beta random variables X1, . . . , Xk with Xi ∼ Beta(αi,∑k+1j=i+1 αj ), i = 1, . . . , k;

Step 2: Set Y1 = X1 and Yi = Xi

∏i−1j=1(1 − Xj) for i = 2, . . . , k;

Step 3: Return (Y1, . . . , Yk).

Note that algorithm BETA was called ‘DIR-3’ in [12], wherein all beta variates were generatedusing the subroutine GGBTR in IMSL [16]. Since the subroutine GGBTR is dated now, we canimprove this algorithm by choosing a more efficient beta generator. Recently, Hung et al. [20]performed an empirical study on various beta generation algorithms. Base on their study, we canchoose the most efficient Beta(α, β) generator using the following guideline:

2.5.1. Guideline 1: choosing the fastest beta generation algorithm

• For α, β < 1, choose Kennedy’s MK algorithm [20] if α + β > 1.2; otherwise, choose the B00algorithm [21];

• For α < 1 < β or α > 1 > β, choose the B01 algorithm [21];• For α, β > 1, choose the B4PE algorithm [22] if one parameter is close to 1 and the other is

large (say > 4); otherwise, choose the BPRS algorithm [23].

Note that to generate a k-variate Dirichlet random vector, algorithm BETA requires k successivegenerations of beta variates. Since the generation time of distinct beta variates are quite differ-ent (see [20] for details), it would be logical to expect the algorithm to be further improved byre-ordering the generation of Dirichlet random elements. For example, to generate (Y1, Y2) fromthe Dirichlet(0.5, 0.1, 0.9) distribution, algorithm BETA requires generation of two beta variatesBeta(0.5, 1.0) and Beta(0.1, 0.9). However, one can also consider generating (Y2, 1 − Y1 − Y2)

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14

Page 8: Evaluation of algorithms for generating Dirichlet random vectors

450 Y.C. Hung et al.

from the Dirichlet(0.1, 0.9, 0.5) distribution, thus requiring generation of different beta vari-ates, viz., Beta(0.1, 1.4) and Beta(0.9, 0.5). Computer simulation shows that such a re-orderingof random elements can significantly reduce the generation time of Dirichlet random vectors.For comparative purposes, numerical results for generating various two-variate and three-variateDirichlet random vectors with all possible ordering of shape parameters are presented in Tables 1and 2, respectively.

Since re-ordering the generation of Dirichlet random elements corresponds to re-ordering theshape parameters (i.e. αi) of the desired Dirichlet distribution, the problem of interest now ishow best to ‘shuffle’ the shape parameters so that the generation time of the desired Dirichletrandom vector can be minimized. Next, we present a guideline for ordering the shape parametersof any given Dirichlet(α1, . . . , αk+1) distribution, which is based on the empirical study on betageneration algorithms presented in our previous work [20].

Table 1. Computer times of algorithm BETA for generating 106 two-variate Dirichlet random vectors with all possibleordering of shape parameters.

Parameters Time Parameters Time Parameters Time Parameters Time

(0.1, 0.5, 0.9) 1.620 (0.1, 0.5, 10) 1.742 (0.1, 5, 10) 1.639 (1.5, 5, 10) 1.619(0.1, 0.9, 0.5) 1.580 (0.1, 10, 0.5) 1.700 (0.1, 10, 5) 1.589 (1.5, 10, 5) 1.573(0.5, 0.1, 0.9) 1.654 (0.5, 0.1, 10) 1.740 (5, 0.1, 10) 1.635 (5, 1.5, 10) 1.617(0.5, 0.9, 0.1) 1.600 (0.5, 10, 0.1) 1.696 (5, 10, 0.1) 1.586 (5, 10, 1.5) 1.584(0.9, 0.1, 0.5) 1.610 (10, 0.1, 0.5) 1.747 (10, 0.1, 5) 1.580 (10, 1.5, 5) 1.548(0.9, 0.5, 0.1) 1.620 (10, 0.5, 0.1) 1.746 (10, 5, 0.1) 1.582 (10, 5, 1.5) 1.545

Note: The minimal time for the best ordering is in bold.

Table 2. Computer times of algorithm BETA for generating 106 three-variate Dirichlet random vectors with all possibleordering of shape parameters.

Parameters Time Parameters Time Parameters Time Parameters Time

(0.1, 0.3, 0.5, 0.9) 1.989 (0.1, 0.2, 0.3, 10) 2.126 (0.7, 2, 5, 7) 2.054 (1.1, 2, 5, 8) 1.977(0.1, 0.3, 0.9, 0.5) 1.913 (0.1, 0.2, 10, 0.3) 2.054 (0.7, 2, 7, 5) 1.989 (1.1, 2, 8, 5) 1.912(0.1, 0.5, 0.3, 0.9) 2.039 (0.1, 0.3, 0.2, 10) 2.126 (0.7, 5, 2, 7) 2.052 (1.1, 5, 2, 8) 1.967(0.1, 0.5, 0.9, 0.3) 1.972 (0.1, 0.3, 10, 0.2) 2.060 (0.7, 5, 7, 2) 1.977 (1.1, 5, 8, 2) 1.905(0.1, 0.9, 0.3, 0.5) 1.924 (0.1, 10, 0.2, 0.3) 2.137 (0.7, 7, 2, 5) 1.966 (1.1, 8, 2, 5) 1.886(0.1, 0.9, 0.5, 0.3) 1.931 (0.1, 10, 0.3, 0.2) 2.146 (0.7, 7, 5, 2) 1.970 (1.1, 8, 5, 2) 1.882(0.3, 0.1, 0.5, 0.9) 1.990 (0.2, 0.1, 0.3, 10) 2.127 (2, 0.7, 5, 7) 2.051 (2, 1.1, 5, 8) 1.975(0.3, 0.1, 0.9, 0.5) 1.919 (0.2, 0.1, 10, 0.3) 2.056 (2, 0.7, 7, 5) 1.975 (2, 1.1, 8, 5) 1.907(0.3, 0.5, 0.1, 0.9) 2.005 (0.2, 0.3, 0.1, 10) 2.127 (2, 5, 0.7, 7) 2.047 (2, 5, 1.1, 8) 1.974(0.3, 0.5, 0.9, 0.1) 1.944 (0.2, 0.3, 10, 0.1) 2.070 (2, 5, 7, 0.7) 1.986 (2, 5, 8, 1.1) 1.912(0.3, 0.9, 0.1, 0.5) 1.953 (0.2, 10, 0.1, 0.3) 2.152 (2, 7, 0.7, 5) 1.968 (2, 8, 1.1, 5) 1.892(0.3, 0.9, 0.5, 0.1) 1.963 (0.2, 10, 0.3, 0.1) 2.160 (2, 7, 5, 0.7) 1.974 (2, 8, 5, 1.1) 1.897(0.5, 0.1, 0.3, 0.9) 2.039 (0.3, 0.1, 0.2, 10) 2.126 (5, 0.7, 2, 7) 2.046 (5, 1.1, 2, 8) 1.964(0.5, 0.1, 0.9, 0.3) 1.974 (0.3, 0.1, 10, 0.2) 2.057 (5, 0.7, 7, 2) 1.972 (5, 1.1, 8, 2) 1.903(0.5, 0.3, 0.1, 0.9) 2.007 (0.3, 0.2, 0.1, 10) 2.127 (5, 2, 0.7, 7) 2.042 (5, 2, 1.1, 8) 1.969(0.5, 0.3, 0.9, 0.1) 1.944 (0.3, 0.2, 10, 0.1) 2.066 (5, 2, 7, 0.7) 1.983 (5, 2, 8, 1.1) 1.907(0.5, 0.9, 0.1, 0.3) 2.027 (0.3, 10, 0.1, 0.2) 2.180 (5, 7, 0.7, 2) 1.931 (5, 8, 1.1, 2) 1.856(0.5, 0.9, 0.3, 0.1) 2.034 (0.3, 10, 0.2, 0.1) 2.184 (5, 7, 2, 0.7) 1.935 (5, 8, 2, 1.1) 1.859(0.9, 0.1, 0.3, 0.5) 1.934 (10, 0.1, 0.2, 0.3) 2.194 (7, 0.7, 2, 5) 1.958 (8, 1.1, 2, 5) 1.884(0.9, 0.1, 0.5, 0.3) 1.943 (10, 0.1, 0.3, 0.2) 2.199 (7, 0.7, 5, 2) 1.956 (8, 1.1, 5, 2) 1.881(0.9, 0.3, 0.1, 0.5) 1.961 (10, 0.2, 0.1, 0.3) 2.215 (7, 2, 0.7, 5) 1.946 (8, 2, 1.1, 5) 1.882(0.9, 0.3, 0.5, 0.1) 1.971 (10, 0.2, 0.3, 0.1) 2.223 (7, 2, 5, 0.7) 1.960 (8, 2, 5, 1.1) 1.889(0.9, 0.5, 0.1, 0.3) 2.005 (10, 0.3, 0.1, 0.2) 2.244 (7, 5, 0.7, 2) 1.914 (8, 5, 1.1, 2) 1.844(0.9, 0.5, 0.3, 0.1) 2.010 (10, 0.3, 0.2, 0.1) 2.252 (7, 5, 2, 0.7) 1.923 (8, 5, 2, 1.1) 1.845

Note: The minimal time for the best ordering is in bold.

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14

Page 9: Evaluation of algorithms for generating Dirichlet random vectors

Journal of Statistical Computation and Simulation 451

2.5.2. Guideline 2: ordering the shape parameters

Denote the ordered values of α1, . . . , αk+1 by α(1), . . . , α(k+1), and let m (≤ k + 1) be the numberof shape parameters less than one.

• If α(k+1) < 1 and (k + 1) is odd, generate the random vector from

Dirichlet(α(1), α(3), . . . , α(k−1), α(k+1), α(k), α(k−2), α(k−4), . . . , α(4), α(2)).

• If α(k+1) < 1 and (k + 1) is even, generate the random vector from

Dirichlet(α(1), α(2), α(4), . . . , α(k−1), α(k+1), α(k−2), α(k−4), . . . , α(5), α(3)).

• If 1 ≤ α(k+1) ≤ 3 and α(1) ≥ 1, generate the random vector from

Dirichlet(α(k+1), α(k−1), α(k−2), . . . , α(1), α(k)).

• If α(k+1) > 3 and α(1) ≥ 1, generate the random vector from

Dirichlet(α(k+1), α(k), α(k−2), α(k−3), . . . , α(1), α(k−1)).

• If α(k+1) ≥ 1, α(1) < 1, m > k+22 , and α(m) ≤ 0.5, generate the random vector from

Dirichlet(α(1), α(2), . . . , α(m−1), α(m+1), α(m+2), . . . , α(k+1), α(m)).

• Otherwise, generate the random vector from

Dirichlet(α(k+1), α(k−1), α(k−2), . . . , α(1), α(k)).

To assess the performance of Guideline 2, let us examine the numerical results in Tables 1and 2. As can be seen readily, the ordering of shape parameters as given in Guideline 2 resultsin the smallest generation time for most of the cases. Exceptions are found in the cases when(α1, α2, α3) = (0.5, 10, 0.1) and (α1, α2, α3, α4) = (7, 5, 0.7, 2), for which Guideline 2 suggestsalternative orderings (0.1, 10, 0.5) and (7, 2, 0.7, 5), respectively. It should be noted that, althoughthe ordering of shape parameters suggested by Guideline 2 may not be ‘optimal’ in these cases,numerical results show that it is at least ‘nearly optimal’ in terms of generation time (see thecorresponding results in Tables 1 and 2).

Remark 1 Owing to the complex structure between the generation time and the ordering of shapeparameters, it is a hard task to find an optimal shuffling rule that can be applied to any Dirichletdistribution.

We next introduce another guideline that can be used to reduce the amount of arithmeticoperations for algorithm BETA.

2.5.3. Guideline 3: reducing the amount of arithmetic operations

Note that to generate Yi , the expression Yi = Xi

∏i−1j=1(1 − Xj) in Step 2 of algorithm BETA

requires i operations of multiplication and (i − 1) operations of subtraction. However, it can beequivalently written as

Yi = Xi(1 − Y1 − · · · − Yi−1), i = 2, . . . , k. (6)

Therefore, the generation time for each Yi can be further reduced by using Equation (6), in whichonly one multiplication is required (though the number of subtraction remains the same). Bysummarizing the ideas in Guidelines 1–3, we have the following modified version of algorithmBETA.

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14

Page 10: Evaluation of algorithms for generating Dirichlet random vectors

452 Y.C. Hung et al.

Algorithm BETA-M (αi > 0 for all i)

Step 1: Re-order the shape parameters α1, . . . , αk+1 based on Guideline 2, and denote the newordering by αs1 , . . . , αsk+1 ;

Step 2: For i = 1, . . . , k, generate independent random variables Xi ∼ Beta(αsi,∑k+1

j=i+1 αsj) by

using Guideline 1;Step 3: Set Y1 = X1 and Yi = Xi(1 − Y1 − · · · − Yi−1) for i = 2, . . . , k (Guideline 3);Step 4: Rearrange the order of Y1, . . . , Yk , and return the desired vector.

3. Performance evaluation

In this section, we evaluate all the algorithms described in Section 2 in terms of (i) the computergeneration time, (ii) sensitivity, and (iii) goodness of fit. For comparative purposes, we havealso included the results of the statistical software packages R and SAS (the latest version). Allnumerical results were obtained based on a large number of simulation trials that were executed on2.83 GHz Intel� Core™2 Duo E8300 processors with 2 GB of cache under the operating systemof Microsoft� Windows XP Service Pack 3 (SP3). The necessary computer programs were allwritten in C++ (with GNU GCC complier), where a 32-bit linear congruential random numbergenerator called SHR3 [19], the Quicksort, and insertion sort algorithms were used.

3.1. Computer generation time

We evaluated the computer times of all Dirichlet generation algorithms described in Section 2.We first considered generating two-variate Dirichlet random vectors with a wide range of shapeparameters. The resulting computer times (in seconds) for 106 generated random vectors for awide range of parameter choices are presented in Table 3.

As can be seen from Table 3, the proposed BETA-M algorithm outperforms significantly otherapproaches in almost all the cases considered. Exceptions are found only when all (or most)of the shape parameters are close to zero. For example, algorithm JK performs slightly betterwhen (α1, α2, α3) = (0.1, 0.1, 0.1) and (0.1, 0.1, 0.3), while algorithm Rejection-P performsslightly better when (α1, α2, α3) = (0.1, 0.1, 1.5). Another potential competitor is algorithmGAMMA, which is the second best (after algorithm BETA-M) for most of the cases. It is seenthat algorithm JK and the two rejection methods perform poorly when the shape parametersare large. In addition, we also note that R performs significantly better than SAS for the casesconsidered.

Next, we generated four-variate Dirichlet random vectors with a wide range of shape parameters.The resulting computer times (in seconds) of 106 generated random vectors for a wide range ofparameter choices are presented in Table 4.

From Table 4, it can be seen once again that algorithm BETA-M significantly outperforms otherapproaches for all possible parameter choices, except in the case when all shape parameters areequal to 0.1 (algorithm JK performs slightly better in this case). Algorithm GAMMA is seen tobe fairly competitive in all cases, algorithm JK and the two rejection methods perform poorlywhen the shape parameters are large, and R performs significantly better than SAS for all casesconsidered. The numerical results for generating nine-variate Dirichlet random vectors with allshape parameters less than one are presented in Table 5. The two rejection methods were excludedfrom analysis since they are not applicable in this case.

By summarizing the results from Tables 3–5, we draw the following conclusions.

• In general, the rejection methods and the software packages (R and SAS) are relatively slowwhen compared with algorithms GAMMA and BETA-M.

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14

Page 11: Evaluation of algorithms for generating Dirichlet random vectors

Journal of Statistical Computation and Simulation 453

Table 3. The computer generation times (in seconds) of 106 two-variate Dirichlet random vectors.

Parameters Generation time

α1 = α2 α3 OS GAMMA Rejection-U Rejection-P JK BETA-M R SAS

0.1 0.1 – 0.792 – – 0.610 0.744 1.11 4.950.3 – 0.822 – – 0.636 0.667 1.12 5.030.5 – 0.840 – – 0.651 0.606 1.14 5.050.75 – 0.836 – – 0.678 0.547 1.17 5.021.5 – 0.709 – 0.573 0.732 0.641 1.07 4.995 – 0.706 – 0.765 0.870 0.660 0.99 4.95

10 – 0.710 – 0.896 0.977 0.666 0.97 4.95

0.3 0.1 – 0.863 – – 0.684 0.633 1.17 5.080.3 – 0.890 – – 0.757 0.636 1.21 5.000.5 – 0.907 – – 0.819 0.592 1.22 5.100.75 – 0.905 – – 0.906 0.534 1.23 5.061.5 – 0.778 – 0.726 1.120 0.609 1.14 5.035 – 0.775 – 1.578 1.872 0.649 1.07 4.99

10 – 0.777 – 2.428 2.673 0.662 1.04 5.00

0.5 0.1 – 0.892 – – 0.776 0.515 1.22 5.080.3 – 0.926 – – 0.902 0.513 1.25 5.090.5 – 0.941 – – 1.017 0.507 1.28 5.030.75 – 0.937 – – 1.180 0.509 1.30 5.061.5 – 0.811 – 0.897 1.646 0.513 1.19 5.035 – 0.809 – 2.976 3.811 0.513 1.10 4.99

10 – 0.809 – 5.973 6.896 0.513 1.11 5.00

0.75 0.1 – 0.886 – – 0.984 0.444 1.25 5.050.3 – 0.917 – – 1.198 0.456 1.30 5.060.5 – 0.936 – – 1.415 0.463 1.32 5.060.75 – 0.932 – – 1.730 0.463 1.33 4.971.5 – 0.803 – 1.217 2.745 0.493 1.22 5.005 – 0.801 – 6.391 9.243 0.423 1.14 4.97

10 – 0.801 – 17.616 22.256 0.440 1.14 4.97

1.5 0.1 – 0.629 – – 2.099 0.496 1.03 4.890.3 – 0.663 – – 2.862 0.505 1.06 4.940.5 – 0.680 – – 3.729 0.507 1.10 4.910.75 – 0.676 – – 5.140 0.502 1.11 4.921.5 – 0.549 0.985 2.975 11.103 0.507 1.00 4.725 – 0.547 3.320 47.390 94.060 0.510 0.94 4.84

10 – 0.547 9.813 ∗∗ ∗∗ 0.519 0.92 4.81

5 0.1 – 0.625 – – 182.204 0.463 0.88 4.840.3 – 0.660 – – ∗∗ 0.492 0.90 4.890.5 – 0.677 – – ∗∗ 0.509 0.92 4.860.75 – 0.673 – – ∗∗ 0.509 0.93 4.881.5 – 0.545 4.121 ∗∗ ∗∗ 0.432 0.85 4.805 2.014 0.546 3.596 ∗∗ ∗∗ 0.407 0.77 4.69

10 2.939 0.545 5.399 ∗∗ ∗∗ 0.403 0.78 4.77

10 0.1 – 0.626 – – ∗∗ 0.467 0.85 4.840.3 – 0.659 – – ∗∗ 0.502 0.91 4.890.5 – 0.676 – – ∗∗ 0.523 0.91 4.860.75 – 0.672 – – ∗∗ 0.521 0.92 4.841.5 – 0.544 10.958 ∗∗ ∗∗ 0.452 0.83 4.805 3.766 0.543 6.665 ∗∗ ∗∗ 0.417 0.76 4.80

10 4.655 0.542 7.325 ∗∗ ∗∗ 0.404 0.73 4.64

Note: The minimal generation time for each parameter choice is in bold. Note that ‘−’ represents the cases for which the algorithm is notapplicable, while ‘∗∗’ represents the cases for which the generation time is over 300 s.

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14

Page 12: Evaluation of algorithms for generating Dirichlet random vectors

454 Y.C. Hung et al.

Table 4. The computer generation times (in seconds) of 106 four-variate Dirichlet random vectors.

Parameters Generation time

α1 = α2 = α3 α4 = α5 OS GAMMA Rejection-U Rejection-P JK BETA-M R SAS

0.1 0.1 – 1.293 – – 1.059 1.354 1.80 7.420.3 – 1.355 – – 1.263 1.163 1.86 7.600.5 – 1.389 – – 1.529 1.033 1.92 7.550.75 – 1.380 – – 1.995 0.897 1.93 7.561.5 – 1.139 – 2.036 4.798 0.934 1.76 7.385 – 1.135 – 213.748 ∗∗ 0.922 1.61 7.41

10 – 1.135 – ∗∗ ∗∗ 0.931 1.60 7.39

0.3 0.1 – 1.389 – – 1.431 1.148 1.93 7.590.3 – 1.457 – – 1.979 1.096 1.99 7.550.5 – 1.491 – – 2.718 1.002 2.03 7.610.75 – 1.483 – – 4.049 1.011 2.07 7.631.5 – 1.241 – 4.453 13.045 0.962 1.88 7.475 – 1.237 – ∗∗ ∗∗ 1.012 1.72 7.49

10 – 1.237 – ∗∗ ∗∗ 1.038 1.71 7.41

0.5 0.1 – 1.440 – – 2.081 1.046 2.00 7.610.3 – 1.506 – – 3.237 1.012 2.08 7.540.5 – 1.540 – – 4.919 0.994 2.11 7.530.75 – 1.533 – – 8.161 1.015 2.14 7.611.5 – 1.292 – 9.554 33.484 0.983 1.94 7.475 – 1.288 – ∗∗ ∗∗ 1.067 1.78 7.47

10 – 1.286 – ∗∗ ∗∗ 1.101 1.76 7.44

0.75 0.1 – 1.428 – – 3.725 0.929 2.04 7.530.3 – 1.496 – – 6.508 1.032 2.13 7.610.5 – 1.528 – – 10.947 1.023 2.16 7.550.75 – 1.520 – – 20.328 0.982 2.21 7.451.5 – 1.278 – 26.090 107.511 1.008 2.00 7.415 – 1.276 – ∗∗ ∗∗ 1.068 1.84 7.42

10 – 1.276 – ∗∗ ∗∗ 1.099 1.83 7.36

1.5 0.1 – 1.064 – – 27.320 0.895 1.74 7.360.3 – 1.132 – – 60.104 0.914 1.79 7.440.5 – 1.165 – – 123.868 0.921 1.86 7.410.75 – 1.158 – – 288.744 0.931 1.90 7.391.5 – 0.916 11.654 ∗∗ ∗∗ 0.905 1.63 7.035 – 0.912 130.404 ∗∗ ∗∗ 0.861 1.51 7.20

10 – 0.911 ∗∗ ∗∗ ∗∗ 0.889 1.51 7.16

5 0.1 – 1.060 – – ∗∗ 0.871 1.48 7.280.3 – 1.126 – – ∗∗ 0.931 1.57 7.370.5 – 1.163 – – ∗∗ 0.967 1.61 7.310.75 – 1.152 – – ∗∗ 0.967 1.64 7.311.5 – 0.912 172.107 ∗∗ ∗∗ 0.829 1.43 7.125 4.012 0.907 155.078 ∗∗ ∗∗ 0.780 1.22 6.95

10 5.779 0.908 ∗∗ ∗∗ ∗∗ 0.791 1.27 7.06

10 0.1 – 1.060 – – ∗∗ 0.873 1.46 7.300.3 – 1.126 – – ∗∗ 0.944 1.55 7.360.5 – 1.160 – – ∗∗ 0.986 1.60 7.330.75 – 1.153 – – ∗∗ 0.984 1.63 7.311.5 – 0.913 ∗∗ ∗∗ ∗∗ 0.844 1.42 7.125 6.679 0.907 ∗∗ ∗∗ ∗∗ 0.779 1.25 7.11

10 8.539 0.910 ∗∗ ∗∗ ∗∗ 0.762 1.18 6.88

Note: The minimal generation time for each parameter choice is in bold. Note that ‘−’ represents the cases for which the algorithm is notapplicable, while ‘∗∗’ represents the cases for which the generation time is over 300 s.

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14

Page 13: Evaluation of algorithms for generating Dirichlet random vectors

Journal of Statistical Computation and Simulation 455

Table 5. The computer generation times (in seconds) of 106 nine-variate Dirichlet random vectors.

Parameters Generation time

α1 = α2 = α3 = α4 α5 = α6 = α7 α8 = α9 α10 GAMMA JK BETA-M R SAS

0.01 0.1 0.1 0.1 2.575 2.209 2.667 3.53 13.270.2 2.594 2.316 2.621 3.56 13.310.3 2.614 2.419 2.568 3.58 13.36

0.2 0.2 2.634 2.606 2.522 3.59 13.330.3 2.648 2.761 2.458 3.63 13.42

0.3 0.3 2.680 3.149 2.409 3.65 13.340.2 0.2 0.2 2.693 3.264 2.331 3.65 13.36

0.3 2.706 3.522 2.323 3.69 13.390.3 0.3 2.738 4.153 2.295 3.71 13.44

0.3 0.3 0.3 2.786 5.527 2.214 3.79 13.39

0.1 0.1 0.1 0.1 2.669 2.832 2.621 3.61 13.240.2 2.684 3.046 2.574 3.64 13.340.3 2.699 3.255 2.517 3.67 13.38

0.2 0.2 2.722 3.589 2.484 3.70 13.360.3 2.740 3.876 2.458 3.70 13.45

0.3 0.3 2.769 4.614 2.428 3.75 13.380.2 0.2 0.2 2.783 4.775 2.356 3.75 13.42

0.3 2.798 5.248 2.350 3.78 13.450.3 0.3 2.829 6.421 2.341 3.81 13.49

0.3 0.3 0.3 2.875 8.998 2.243 3.86 13.45

0.2 0.2 0.2 0.2 2.860 7.521 2.287 3.84 13.360.3 2.877 8.407 2.331 3.86 13.45

0.3 0.3 2.905 10.682 2.330 3.89 13.500.3 0.3 0.3 2.954 15.671 2.285 3.96 13.50

0.3 0.3 0.3 0.3 3.015 27.495 2.282 4.03 13.45

Note: The minimal generation time for each parameter choice is in bold.

• The proposed BETA-M algorithm has the smallest generation time, except in cases when all(or most) shape parameters are close to zero.

• When all (or most) shape parameters are close to zero, Jöhnk’s method performs best.

Remark 2 The Dirichlet generating functions used in R and SAS are rdirichlet(·) (in the MCM-Cpack package) and RANDDIRICHLET(·) (in the IML procedure), respectively. Note that bothgenerating functions are based on the old versions of the gamma method, i.e. Ahrens and Dieter’salgorithm [24,25], Fishman’s algorithm [26] and Cheng’s algorithm [27].

3.2. Sensitivity analysis

Based on the comparative study in Section 3.1, the three major competing algorithms in terms ofcomputer generation time are evidently GAMMA, JK, and BETA-M. We now proceed to examinehow the generation time of these three algorithms are affected by the values of the Dirichlet shapeparameters. Such a study is called sensitivity analysis [28], which is important when consecutivegeneration of random vectors from different Dirichlet distributions is required. Let A be the setwherein the shape parameter(s) can possibly change and denote the maximum and minimumgeneration times of an algorithm π over the set A by tmax

π (A) and tminπ (A), respectively. The

‘sensitivity’ of an algorithm π over the set A can be examined by considering the quantity

t∗π (A) = tmaxπ (A)

tminπ (A)

. (7)

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14

Page 14: Evaluation of algorithms for generating Dirichlet random vectors

456 Y.C. Hung et al.

Note that if t∗π (A) is small, then algorithm π is rather robust (or insensitive) to the change ofparameters in A. On the other hand, algorithm π is rather unstable (or sensitive) to the change ofparameters in A if t∗π (A) is large. Therefore, in addition to having small generation times, a goodalgorithm should also have small values of t∗π (A) over a wide range of sets A. Figure 1 shows thesensivility of algorithms GAMMA, JK, and BETA-M, wherein each t∗π (A) was computed basedon 106 generated random vectors from the Dirichlet distributions of the form Dirichlet(α, α, β),Dirichlet(β, β, α), Dirichlet(α, α, α, β, β), and Dirichlet(β, β, β, α, α). Each simulation trial wasperformed by fixing the value of α, with the value of β changing over a set A.

As can be seen from Figure 1, the proposed BETA-M and GAMMA algorithms are both quitestable over a wide range of shape parameters. On the other hand, algorithm JK seems to bequite sensitive to the change of shape parameters in general, except in the case when all shapeparameters are close to zero.

3.3. Goodness of fit

Another way of evaluating a Dirichlet generation algorithm is to perform a multivariate goodnessof fit test based on the generated random vectors. Since the well-known Kolmogorov–Smirnovand the Cramér–von Mises tests do not readily extend to the multivariate case, a testing procedurebased on the construction of statistically equivalent blocks (SEBs) is employed [29–33]. Wenow describe briefly how to perform this test. Let x1, . . . , xn be n observations of the randomvector X generated from a k-variate Dirichlet distribution F having support S. We first choose n

cutting functions φ1, . . . , φn such that the distribution of φi(X) is continuous, i = 1, . . . , n. Let

(a) (b)

(c) (d)

Figure 1. Sensitivity analysis of algorithms GAMMA, BETA-M, and JK for 106 random vectors generatedfrom (a) Dirichlet(α, α, β), (b) Dirichlet(β, β, α), (c) Dirichlet(α, α, α, β, β), and (d) Dirichlet(β, β, β, α, α). Here,A = {0.1, 0.3, 0.5, 0.75, 1.5} for (a) and (b), and A = {0.1, 0.3, 0.5, 0.75} for (c) and (d), with A being the set ofpossible values of β.

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14

Page 15: Evaluation of algorithms for generating Dirichlet random vectors

Journal of Statistical Computation and Simulation 457

x(1) = arg minx∈{x1,...,xn} φ1(x); it is then clear that the support S is cut into two blocks

B1 = {x ∈ S: φ1(x) ≤ φ1(x(1))} and B2···n = S\B1. (8)

Next, let x(2) = arg minx∈{x1,...,xn}\{x(1)} φ2(x) so that B2···n is cut into two subblocks

B2 = {x ∈ B2···n: φ2(x) ≤ φ2(x(2))} and B3···n = B2···n\B2. (9)

Continuing in this manner, we see that there exist x(1), . . . , x(n) and (n + 1) exclusive blocksB1, B2, . . ., Bn+1 such that

⋃n+1i=1 Bi = S. Let di = PF (X ∈ Bi) for i = 1, . . . , n. Then, Ander-

son [31] showed that (d1, . . . , dn) is uniformly distributed over an n-simplex (which is the reasonwhy B1, B2, . . . , Bn+1 are called SEBs).

A multivariate version of the Kolmogorov–Smirnov statistic is defined as

D̃n = max

{0, max

1≤j≤n

(j

n− Dj

), max

1≤j≤n

(Dj − j − 1

n

)}, (10)

where Dj = PF (X ∈ ⋃j

i=1 Bi) = ∑j

i=1 di , j = 1, . . . , n. Clearly, the null hypothesis that obser-vations x1, . . . , xn are from the distribution F is rejected for large values of D̃n. To test thishypothesis, the following asymptotic result, given by Serfling [34], turns out to be quite useful:

limn→∞ P(

√nD̃n ≤ d) = 1 − 2

∞∑j=1

(−1)j+1e−2j 2d2, d > 0. (11)

Based on this result, if we repeat the procedure of generating x1, . . . , xn (n is large) for N timesand denote the 95th percentile of N resulting

√nD̃n values by d, then Equation (11) should be

very close to 0.95 under the null hypothesis.To test the goodness of fit of all the algorithms described earlier, we chose the cutting functions

suggested by Tukey [29], say, φi+rk(x) = x ′i , i = 1, . . . , k, r = 0, 1, . . ., where x ′

i denotes the ithcoordinate of the vector x. Note that the SEBs constructed in this fashion are simply rectangularblocks. For each algorithm, we then generated 1000 Dirichlet random vectors (i.e. n = 1000)and repeated the procedure 200 times (i.e. N = 200). All estimated probabilities P̂ (

√nD̃n ≤ d)

determined from various Dirichlet distributions are presented in Table 6.As can be seen from Table 6, the estimated probabilities for all algorithms are quite close to

0.95, which reveals that none of the algorithms performed unsatisfactorily in terms of goodnessof fit.

Remark 3 The amount of random number generation required is sometimes considered asanother important measure for evaluating an algorithm. The reason for this is that the more

Table 6. The estimated probabilities P̂ (√

nD̃n ≤ d) for all Dirichlet generation algorithms.

P̂ (√

1000D̃1000 ≤ d)

Parameters OS GAMMA Rejection-U Rejection-P JK BETA-M R SAS

(0.1, 0.5, 0.9) – 0.943 – – 0.965 0.955 0.944 0.954(0.5, 1.5, 10) – 0.969 – 0.964 0.967 0.971 0.950 0.954(1.5, 5, 10) – 0.932 0.967 0.931 0.946 0.946 0.959 0.967(2, 3, 5) 0.962 0.952 0.953 0.944 0.951 0.946 0.963 0.945(0.1, 0.3, 0.5, 0.7, 0.9) – 0.933 – – 0.963 0.948 0.966 0.965(1, 1, 2, 2, 3) 0.931 0.953 0.946 0.964 0.952 0.957 0.943 0.957

Note: Here, d was chosen to be the 95th percentile of N resulting√

nD̃n, where n = 1000, N = 200, and ‘−’ represents the cases forwhich the algorithm is not applicable.

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14

Page 16: Evaluation of algorithms for generating Dirichlet random vectors

458 Y.C. Hung et al.

the random numbers required for each generation, the more likely the algorithm can produceconsecutively ‘dependent’ generations, thus affecting goodness of fit. However, the numericalresults in Table 6, therefore, suggests that the evalutation of amount of random number generationfor each algorithm may be unnecessary.

4. Concluding remarks

In this study, we describe various Dirichlet generation algorithms and evaluate their performanceusing different criteria. We provide, in particular, three useful guidelines for the algorithm basedon transformation of beta variates and show that the computer generation time can be signif-icantly reduced. We highlight some important results obtained from the empirical study. First,the algorithm based on the proposed guidelines (i.e. algorithm BETA-M) is basically a modifiedversion of algorithm DIR-3 introduced in [12]. To distinguish from the numeric results obtainedin [12], we see that algorithm BETA-M outperforms significantly other approaches in terms ofcomputer generation time, except in the cases when all (or most) shape parameters are close tozero (for which Jöhnk’s method performs best). Second, algorithms based on the transformation ofbeta and gamma variates are more robust (or insensitive) to changes in shape parameters. Finally,none of the algorithms considered in this study performs unsatisfactorily in terms of goodness offit. In summary, our proposed method based on beta transformation is preferable for generatingalmost the entire class of Dirichlet random vectors, except in the cases when all (or most) shapeparameters are close to zero (for which Jöhnk’s method is preferable). It is our hope that thesefindings will be useful to anyone needing to perform a large amount of Dirichlet random numbergeneration.

References

[1] J. Mosimann, On the compound multinomial distribution, the multivariate β distribution and correlations amongproportions, Biometrika 49 (1962), pp. 65–82.

[2] R.J. Connor and J.E. Mosimann, Concepts of independence of proportions with a generalization of the Dirichletdistribution. J. Am. Statist. Assoc. 64 (1969), pp. 194–206.

[3] T. Huillet and C. Paroissin, Sampling from Dirichlet partitions: estimating the number of species, Environmetrics20 (2009), pp. 853–876.

[4] J.J. Martin Bayesian Decision Problems and Markov Chains, John Wiley & Sons, New York, 1967.[5] C. Chatfield and G. Goodhardt, Results concerning brand choice, J. Marketing Res. 12 (1975), pp. 110–113.[6] K.W. Tsui, E.M. Matsumura, and K. L.Tsui, Multinomial–Dirichlet bounds for dollar unit sampling in auditing,

Account. Rev. 60 (1985), pp. 76–96.[7] K. Lange, Applications of the Dirichlet distribution to forensic match probabilities, Genetica 96 (2005), pp. 107–117.[8] R.E. Madsen, D. Kauchak, and C. Elkan, Modeling word burstiness using the Dirichlet distribution, Proceedings of

the 22nd International Conference on Machine Learning, 2005, pp. 545–552.[9] S. Kotz, N. Balakrishnan, and N.L. Johnson Continuous Multivariate Distributions, 2nd ed., Vol. I, John Wiley &

Sons, New York, 2000.[10] R.D. Gupta and D.S.P. Richards, The history of the Dirichlet and Liouville distributions, Int. Statist. Rev. 69 (2001),

pp. 433–446.[11] S. Loukas, Simple methods for computer generation of bivariate beta random variables, J. Statist. Comput. Simul.

20 (1984), pp. 145–152.[12] A. Narayanan, Computer generation of Dirichlet random vectors, J. Statist. Comput. Simul. 36 (1990), pp. 19–30.[13] M.D. Jöhnk, Erzeugung von Betaverteilten und Gammaverteilten Zufallszahlen, Metrika 8 (1964), pp. 5–15.[14] S.S. Wilks Mathematical Statistics, Princeton University Press, Princeton, 1962.[15] R.V. Hogg and V.A. Craig Introduction to Mathematical Statistics, 4th ed., Macmillan, New York, 1978.[16] IMSL, International Mathematical and Statistical Libraries, Houston, 1980.[17] H. Tanizaki, A simple gamma random number generator for arbitrary shape parameters, Econ. Bull. 3 (2008),

pp. 1–10.[18] D.J. Best, A note on gamma variate generators with shape parameter less than unity, Computing 30 (1983),

pp. 185–188.[19] G. Marsaglia and W.W. Tsang, A simple method for generating gamma variables, ACM Trans. Math. Softw. 26

(2001), pp. 363–372.

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14

Page 17: Evaluation of algorithms for generating Dirichlet random vectors

Journal of Statistical Computation and Simulation 459

[20] Y.C. Hung, N. Balakrishnan, andY.T. Lin, Evaluation of beta generation algorithms, Commun. Stat., Simul. Comput.38 (2009), pp. 750–770.

[21] H. Sakasegawa, Stratified rejection and squeeze method for generating beta random numbers, Ann. Inst. Statist.Math. 35 (1983), pp. 291–302.

[22] B.W. Schmeiser and A.J.G. Babu, Beta variate generation via exponential majorizing functions, Oper. Res. 28(1980), pp. 917–926.

[23] H. Zechner and E. Stadlober, Generating beta variates via patchwork rejection, Computing 50 (1993), pp. 1–18.[24] J.H. Ahrens and U. Dieter, Computer methods for sampling from gamma, beta, Poisson and binomial distributions,

Computing 12 (1974), pp. 223–246.[25] J.H. Ahrens and U. Dieter, Generating gamma variates by a modified rejection technique, Commun. ACM 25 (1982),

pp. 47–54.[26] G.S. Fishman, Principles of Discrete Event Simulation, John Wiley & Sons, New York, 1978.[27] R.C.H. Cheng, The generation of gamma variables with non-integral shape parameters, Appl. Stat. 26 (1977),

pp. 71–75.[28] A. Saltelli, S. Tarantola, F. Campolongo, and M. Ratto, Sensitivity Analysis in Practice: A Guide to Assessing

Scientific Models, John Wiley & Sons, Hoboken, 2004.[29] J.W. Tukey, Non-parametric estimation II. Statistically equivalent blocks and tolerance regions – the continuous

case, Ann. Math. Stat. 18 (1947), pp. 529–539.[30] D.A.S. Fraser, Nonparametric Methods in Statistics, John Wiley & Sons, New York, 1957.[31] T.W. Anderson, Some nonparametric procedures based on statistically equivalent blocks, in Proceedings of

International Symposium on Multivariate Analysis, P.R. Krishnaiah ed., Academic Press Inc., New York, 1966,pp. 5–27.

[32] R.V. Foutz, A test for goodness of fit based on empirical probability measure, Ann. Stat. 8 (1980), pp. 989–1001.[33] K. Alam, R. Abernathy, and C.L. Williams, Multivariate goodness of fit tests based on statistically equivalent blocks,

Commun. Stat., Theory Methods 22 (1993), pp. 1515–1533.[34] R.J. Serfling, Approximation Theorems for Mathematical Statistics, John Wiley & Sons, New York, 1980.

Dow

nloa

ded

by [

Flor

ida

Inte

rnat

iona

l Uni

vers

ity]

at 1

2:20

21

Dec

embe

r 20

14