useR!2017 has ended
Back To Schedule
Wednesday, July 5 • 2:42pm - 3:00pm
**rTRNG**: Advanced Parallel Random Number Generation in R

Sign up or log in to save this to your schedule, view media, leave feedback and see who's attending!

Keywords: Random Number Generation, Monte Carlo, Parallel Execution, Reproducibility
Webpages: https://github.com/miraisolutions/rTRNG
Monte Carlo simulations provide a powerful computational approach to address a wide variety of problems in several domains, such as physical sciences, engineering, computational biology and finance. The independent-samples and large-scale nature of Monte Carlo simulations make the corresponding computation suited for parallel execution, at least in theory. In practice, pseudo-random number generators (RNGs) are intrinsically sequential. This often prevents having a parallel Monte Carlo algorithm that is playing fair, meaning that results are independent of the architecture, parallelization techniques and number of parallel processes (Mertens 2009; Bauke 2016).
We will show that parallel-oriented RNGs and techniques in fact exist and can be used in R with the rTRNG package (Porreca, Schmid, and Bauke 2017). The package relies on TRNG (Bauke 2016), a state-of-the-art C++ pseudo-random number generator library for sequential and parallel Monte Carlo simulations.
TRNG provides parallel RNGs that can be manipulated by jumping ahead an arbitrary number of steps or splitting a sequence into any desired subsequence(s), thus supporting techniques such as block-splitting and leapfrogging suitable to parallel algorithms.
The rTRNG package provides access to the functionality of the underlying TRNG C++ library by embedding its sources and headers. Beyond this, it makes use of Rcpp and RcppParallel to offer several ways of creating and manipulating pseudo-random streams, and drawing random variates from them, which we will demonstrate:
  • Base-R-like usage for selecting and manipulating the current engine, as a simple and immediate way for R users to use rTRNG
  • Reference objects wrapping the underlying C++ TRNG random number engines can be created and manipulated in OOP-style, for greater flexibility in using parallel RNGs in R
  • TRNG C++ library and headers can be accessed directly from within R projects that use C++, both via standalone C++ code (via sourceCpp) or through creating an R package that depends on rTRNG
References Bauke, Heiko. 2016. Tina’s Random Number Generator Library. https://numbercrunch.de/trng/trng.pdf.

Mertens, Stephan. 2009. “Random Number Generators: A Survival Guide for Large Scale Simulations.” In Modern Computational Science 09. BIS-Verlag.

Porreca, Riccardo, Roland Schmid, and Heiko Bauke. 2017. rTRNG: R Package Providing Access and Examples to TRNG C++ Library. https://github.com/miraisolutions/rTRNG/.

avatar for Riccardo Porreca

Riccardo Porreca

Mirai Solutions GmbH

Wednesday July 5, 2017 2:42pm - 3:00pm CEST
3.02 Wild Gallery
  Talk, HPC