[R-pkgs] new R package dqrng
Ralf Stubner
r@lf@@tubner @ending from d@q@n@@com
Fri May 18 10:44:09 CEST 2018
Dear R users,
A new package, dqrng, is available on CRAN:
dqrng: Fast Pseudo Random Number Generators
Several fast random number generators are provided as C++ header only
libraries: The PCG family by O'Neill (2014
<https://www.cs.hmc.edu/tr/hmc-cs-2014-0905.pdf>) as well as
Xoroshiro128+ and Xoshiro256+ by Blackman and Vigna (2018
<arXiv:1805.01407>). In addition fast functions for generating random
numbers according to a uniform, normal and exponential distribution are
included. The latter two use the Ziggurat algorithm originally proposed
by Marsaglia and Tsang (2000, <doi:10.18637/jss.v005.i08>). These
functions are exported to R and as a C++ interface and are enabled for
use with the 64 bit version of the Mersenne-Twister by Matsumoto and
Nishimura (1998 <doi:10.1145/272991.272995>), the default 64 bit
generator from the PCG family as well as Xoroshiro128+ and Xoshiro256+.
Using the provided RNGs from R is deliberately similar to using R’s
build-in RNGs:
library(dqrng)
dqRNGkind("Xoroshiro128+")
dqset.seed(42)
dqrunif(5, min = 2, max = 10)
#> [1] 4.498747 9.647875 5.232044 6.176499 8.453008
dqrexp(5, rate = 4)
#> [1] 0.5520084 0.1982174 0.3281557 0.1913137 0.7544450
They are quite a bit faster, though:
N <- 1e7
system.time(rnorm(N))
#> user system elapsed
#> 0.650 0.005 0.654
system.time(dqrnorm(N))
#> user system elapsed
#> 0.059 0.012 0.072
Greetings
Ralf
--
Ralf Stubner
Senior Software Engineer / Trainer
daqana GmbH
Dortustraße 48
14467 Potsdam
T: +49 331 23 70 81 66
F: +49 331 23 70 81 67
M: +49 162 20 91 196
Mail: ralf.stubner at daqana.com
Sitz: Potsdam
Register: AG Potsdam HRB 27966 P
Ust.-IdNr.: DE300072622
Geschäftsführer: Prof. Dr. Dr. Karl-Kuno Kunze
More information about the R-packages
mailing list