Parallel Pseudo Random Number Generator (PPRNG) 'sitmo' Header Files

Provided within is a high quality and fast PPRNG that is able to be used in an 'OpenMP' parallel environment compiled under either C++98 or C++11. The objective of this package release is to consolidate the distribution of the 'sitmo' library on CRAN by enabling others to link to the 'sitmo' header file instead of including a copy of 'sitmo' within their individual package. Lastly, the package contains example implementations using 'sitmo' and three accompanying vignette that provide additional information.

Travis-CI Build StatusCRAN RStudio mirror downloads CRAN_Status_Badge

The repository houses the sitmo R package for Parallel Psuedo Random Number Generation (PPRNG). The package provides a way to obtain the sitmo header files via LinkTo.

Installing sitmo

sitmo is available on both CRAN (Stable) and GitHub (Development). Using CRAN to download and install sitmo is the preferred option as it is significantly more stable vs. the GitHub version.

To install the package from CRAN, you can simply type:


The package will be installed and available in a similar fashion to other R packages. The main exception to this note is that to use sitmo to create a package you will need to acquire a compiler. This is detailed under the development install instructions.

Development Install Instructions

To install the package, you must first have a compiler on your system that is compatible with R.

For help on obtaining a compiler consult:

With a compiler in hand, one can then install the package from GitHub by:


Using sitmo

There are two ways to use sitmo. The first is to use sitmo in a standalone script. The script is typically built using sourceCpp(). The second approach allows for sitmo to be used within an R package.

Standalone file usage

Within the C++ file, the sitmo package provides an Rcpp plugins' depends statement that must be included after sitmo.h header. This plugin statement indicates that a dependency is sitmo.

#include <rgen.h> 
// [[Rcpp::depends(sitmo)]] 

Below is a hello world example meant to show a basic implementation of sitmo.

#include <Rcpp.h>
#include <random>  // C++11 RNG library 
#include <sitmo.h> // SITMO PPRNG 
// Rcpp depends attribute is required for standalone use.  
// It is not needed if in package linking to the sitmo package (detailed next). 
// [[Rcpp::depends(sitmo)]] 
// [[Rcpp::export]] 
Rcpp::NumericVector sitmo_draws_ex(unsigned int n) {
  Rcpp::NumericVector o(n);
  // Create a prng engine 
  sitmo::prng_engine eng;
  // Draw from base engine 
  for (unsigned int i=0; i< n ; ++i){
    o(i) = eng();  
  return o;
/*** R

Package usage

To use sitmo in your R package, modify the DESCRIPTION file by adding:

LinkingTo: Rcpp, sitmo
    Rcpp (>= 0.12.11)

To use C++11's statistical distributions, you may want to add the following to your src/Makevars and src/ file:


Within the C++ file, then add:

#include <sitmo.h> // SITMO PPRNG 


sitmo 1.2.2


  • Addressed import of Rcpp.plugin.maker() by using the exported variable name, e.g. ::, in place of the internal variable name, e.g. ::: (#7).
  • Updated sitmo URL to point to stdfin/random (#8).

sitmo 1.2.1


  • Removed extra ; in sitmo header to quiet compile warnings (#4, thanks @helske)
  • Updated sitmo_two_seeds() src and documentation in "Deployment of sitmo within C++ Code" so that it uses the second seed for eng2 and returns an n x 2 matrix instead of n x 3. (#5, thanks @helske)

sitmo 1.2.0


  • Added plugin registration for Rcpp:::Rcpp.plugin.maker() (#3)
  • Added CxxFlags() and sitmoCxxFlags() functions to display CXX_FLAGS required by sitmo. (#3)
  • Updated examples in README.Rmd and SITMO internal vignette to use the Rcpp depends attribute. (#3)


  • Corrected a signed and unsigned integer comparison in "Making a Uniform PRNG with sitmo" vignette.
  • Fixed notation in "Making a Uniform PRNG with sitmo" vignette.

sitmo 1.1.0


  • Added src/init.c to address R 3.4 C++ registration requirement (#2)
  • Clarified content in "Making a Uniform PRNG with sitmo" vignette.


  • Addressed signed and unsigned integer comparison in sitmo header (#1)
  • Corrected a URL that was problematic in "Deployment of sitmo within C++ Code" vignette.

sitmo 1.0.0


  • Embedded sitmo header file in an R package.
  • Provided code examples using sitmo header file.
  • Released three vignettes detailing sitmo contents:
    • Deployment of sitmo within C++ Code
    • Making a Uniform PRNG with sitmo
    • sitmo's BigCrush Results

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.2.2 by James Balamuta, 4 months ago,,

Report a bug at

Browse source code at

Authors: James Balamuta [aut, cre, cph], Thijs van den Berg [aut, cph]

Documentation:   PDF Manual  

MIT + file LICENSE license

Imports Rcpp

Suggests knitr, rmarkdown, ggplot2

Linking to Rcpp

Suggested by bssm.

See at CRAN