runif_trng  R Documentation 
Random number generation for the uniform distribution using the TRNG C++ library.
runif_trng(n, min = 0, max = 1, engine = NULL, parallelGrain = 0L)
n 
Number of observations. 
min, max 
Parameters of the distribution, with the same meaning as in

engine 
Optional TRNG engine object; if missing or

parallelGrain 
Optional argument controlling the parallel simulation of random variates (see â€˜Parallel Simulationâ€™ below for details). 
Numeric vector of random variates generated with the given
parameters. The length is determined by n
.
When a positive value of argument
parallelGrain
is supplied, random variates are simulated in
parallel, provided a parallel random number engine
is
selected. This is done using RcppParallel via
parallelFor
, which uses the supplied parallelGrain
to control
the grain size (the number of threads being controlled by
setThreadOptions
). The grain size can greatly affect the overhead of
performing the required block splitting jump
operations and
should be selected carefully. Note that TRNG guarantees the outcome of such
parallel execution to be equivalent to a purely sequential simulation.
runif
, TRNG.Engine
,
TRNG.Random
.
Other TRNG distributions:
rbinom_trng()
,
rlnorm_trng()
,
rnorm_trng()
,
rpois_trng()
## generate 10 random variates using the current TRNG engine runif_trng(10, min = 0, max = 1) ## use a TRNG engine reference class object r < yarn2$new() runif_trng(10, min = 0, max = 1, engine = r) ## generate 100k random variates in parallel, with 2 threads and 100 grain size TRNGseed(117) RcppParallel::setThreadOptions(numThreads = 2L) x_parallel < runif_trng(100e3, min = 0, max = 1, parallelGrain = 100L) TRNGseed(117) x_serial < runif_trng(100e3, min = 0, max = 1) identical(x_serial, x_parallel)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.