Skip to content
Fast Pseudo Random Number Generators for R
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.aspell
R
external
inst/include
man
src
tests
vignettes
.Rbuildignore
.gitignore
.gitmodules
.travis.yml
DESCRIPTION
LICENSE
NAMESPACE
NEWS.md
README.Rmd
README.md
appveyor.yml
cleanup
codecov.yml
cran-comments.md
dqrng.Rproj

README.md

Travis build status AppVeyor build status CRAN status Coverage status Downloads CII Best Practices Codacy Badge

dqrng

The dqrng package provides fast random number generators (RNG) with good statistical properties for usage with R. It combines these RNGs with fast distribution functions to sample from uniform, normal or exponential distributions. Both the RNGs and the distribution functions are distributed as C++ header-only library.

Installation

The currently released version is available from CRAN via

install.packages("dqrng")

Intermediate releases can also be obtained via drat:

if (!requireNamespace("drat", quietly = TRUE)) install.packages("drat")
drat::addRepo("daqana")
install.packages("dqrng")

Example

Using the provided RNGs from R is deliberately similar to using R’s build-in RNGs:

library(dqrng)
dqset.seed(42)
dqrunif(5, min = 2, max = 10)
#> [1] 9.211802 2.616041 6.236331 4.588535 5.764814
dqrexp(5, rate = 4)
#> [1] 0.35118613 0.17656197 0.06844976 0.16984095 0.10096744

They are quite a bit faster, though:

N <- 1e7
system.time(rnorm(N))
#>    user  system elapsed 
#>   0.776   0.012   0.790
system.time(dqrnorm(N))
#>    user  system elapsed 
#>   0.088   0.008   0.098

Feedback

All feedback (bug reports, security issues, feature requests, …) should be provided as issues.

You can’t perform that action at this time.