Computational Statistics and Data Analysis ( ) Contents lists available at SciVerse ScienceDirect Computational Statistics and Data Analysis journal homepage: www.elsevier.com/locate/csda Generating beta random numbers and Dirichlet random vectors in R: The package rBeta2009 Ching-Wei Cheng a , Ying-Chao Hung b, , Narayanaswamy Balakrishnan c a Department of Statistics, Purdue University, 250 North University Street, West Lafayette, IN 47907-2066, USA b Department of Statistics, National Chengchi University, Wenshan District, Taipei 116, Taiwan c Department of Mathematics and Statistics, McMaster University, Hamilton, Ontario, Canada L8S 4K1 article info Article history: Received 30 August 2012 Received in revised form 29 January 2013 Accepted 14 February 2013 Available online xxxx Keywords: R Beta variates Dirichlet random vectors Computer time Kolmogorov–Smirnov test Ljung–Box test abstract A software package, rBeta2009, developed to generate beta random numbers and Dirichlet random vectors in R is presented. The package incorporates state-of-the-art algorithms so as to minimize the computer generation time. In addition, it is designed in a way that (i) the generation efficiency is robust to changes of computer architecture; (ii) memory allocation is flexible; and (iii) the exported objects can be easily integrated with other software. The usage of this package is then illustrated and evaluated in terms of various performance metrics. © 2013 Elsevier B.V. All rights reserved. 1. Introduction The beta variates and Dirichlet random vectors are extensively used in the areas of Bayesian statistics, stochastic modeling and simulation, program evaluation and review techniques (PERT), critical path method (CPM), and project management and control systems (Lange, 1995; Gupta and Nadarajah, 2004; Tian et al., 2010; da-Silva et al., 2011). Over the years, many algorithms have been introduced in the literature for the computer generation of beta variates and Dirichlet random vectors. For example, the beta generating function rbeta() in the R default package stats R Development Core Team (2008) is based on the algorithms by Cheng (1978); the beta generating function rand() in SAS utilizes the algorithms by Atkinson and Whittaker (1976), Cheng (1978) and Atkinson (1979); the beta generating function betarnd() in MATLAB Statistics Toolbox uses both the order statistics method and Jöhnk’s method (Jöhnk, 1964; Rubinstein and Kroese, 1981); and the Dirichlet generating functions rdirichlet() and rDirichlet() in the R packages MCMCpack and compositions utilize the method based on the transformation of gamma variates (Hogg and Craig, 1978; Aitchison, 1986). The shortcoming for the existing software packages is that most algorithms used to develop the beta and Dirichlet generating functions are dated (the readers can refer to Hung et al. (2009, 2011) for a review of recent developments on beta and Dirichlet generating functions). Besides, their efficiency (i.e., computer generation time) is usually not robust to changes in hardware/software platform. From the viewpoint of implementation, it is better to use state-of-the-art algorithms so that maximum efficiency can be achieved on different computer platforms (e.g., 32 or 64-bit processors, Windows or Mac OS X operating systems, etc.). In this study, we present a new R package rBeta2009, which contains functions rbeta() and rdirichlet() for generating beta variates and Dirichlet random vectors, respectively. The package mainly utilizes the recent guidelines provided by Corresponding author. Tel.: +886 2 29387115; fax: +886 2 29398024. E-mail addresses: cheng138@purdue.edu (C.-W. Cheng), hungy@nccu.edu.tw (Y.-C. Hung), bala@mcmaster.ca (N. Balakrishnan). 0167-9473/$ – see front matter © 2013 Elsevier B.V. All rights reserved. http://dx.doi.org/10.1016/j.csda.2013.02.019