Title: | Parallel Pseudo Random Number Generator (PPRNG) 'sitmo' Header Files |
---|---|
Description: | Provided within are two high quality and fast PPRNGs that may be used in an 'OpenMP' parallel environment. In addition, there is a generator for one dimensional low-discrepancy sequence. The objective of this library to consolidate the distribution of the 'sitmo' (C++98 & C++11), 'threefry' and 'vandercorput' (C++11-only) engines on CRAN by enabling others to link to the header files inside of 'sitmo' instead of including a copy of each engine within their individual package. Lastly, the package contains example implementations using the 'sitmo' package and three accompanying vignette that provide additional information. |
Authors: | James Balamuta [aut, cre, cph] , Thijs van den Berg [aut, cph], Ralf Stubner [ctb] |
Maintainer: | James Balamuta <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.0.2 |
Built: | 2024-11-06 04:42:39 UTC |
Source: | https://github.com/coatless-rpkg/sitmo |
Provided within are two high quality and fast PPRNGs that may be used in an 'OpenMP' parallel environment. In addition, there is a generator for one dimensional low-discrepancy sequence. The objective of this library to consolidate the distribution of the 'sitmo' (C++98 & C++11), 'threefry' and 'vandercorput' (C++11-only) engines on CRAN by enabling others to link to the header files inside of 'sitmo' instead of including a copy of each engine within their individual package. Lastly, the package contains example implementations using the 'sitmo' package and three accompanying vignette that provide additional information.
Maintainer: James Balamuta [email protected] (ORCID) [copyright holder]
Authors:
Thijs van den Berg [email protected] [copyright holder]
Other contributors:
Ralf Stubner [email protected] [contributor]
Useful links:
Report bugs at https://github.com/coatless-rpkg/sitmo/issues
The function provides an alternative implementation of random uniform distribution sampling using R's rng scope.
runif_r(n, min = 0, max = 1)
runif_r(n, min = 0, max = 1)
n |
An |
min |
A |
max |
A |
set.seed(134) b = runif_r(10)
set.seed(134) b = runif_r(10)
The function provides an implementation of sampling from a random uniform distribution
runif_sitmo(n, min = 0, max = 1, seed = 1L)
runif_sitmo(n, min = 0, max = 1, seed = 1L)
n |
An |
min |
A |
max |
A |
seed |
A special |
A numeric vector
containing the realizations.
a = runif_sitmo(10)
a = runif_sitmo(10)
Shows a basic setup and use case for sitmo.
sitmo_draws(n)
sitmo_draws(n)
n |
A |
A vec
with random sequences.
n = 10 a = sitmo_draws(n)
n = 10 a = sitmo_draws(n)
Shows how to set a seed in sitmo.
sitmo_engine_reset(n, seed)
sitmo_engine_reset(n, seed)
n |
An |
seed |
An |
A matrix
with random sequences.
n = 10 a = sitmo_engine_reset(n, 1337) isTRUE(all.equal(a[,1],a[,2]))
n = 10 a = sitmo_engine_reset(n, 1337) isTRUE(all.equal(a[,1],a[,2]))
Shows how to set a seed in sitmo.
sitmo_engine_seed(n, seed)
sitmo_engine_seed(n, seed)
n |
An |
seed |
An |
A vector
with random sequences.
n = 10 a = sitmo_engine_seed(n, 1337) b = sitmo_engine_seed(n, 1337) c = sitmo_engine_seed(n, 1338) isTRUE(all.equal(a,b)) isTRUE(all.equal(a,c))
n = 10 a = sitmo_engine_seed(n, 1337) b = sitmo_engine_seed(n, 1337) c = sitmo_engine_seed(n, 1338) isTRUE(all.equal(a,b)) isTRUE(all.equal(a,c))
The function provides an implementation of creating realizations from the default engine.
sitmo_parallel(n, seeds)
sitmo_parallel(n, seeds)
n |
An |
seeds |
A |
The following function's true power is only accessible on platforms that support OpenMP (e.g. Windows and Linux). However, it does provide a very good example as to how to make ones code applicable across multiple platforms.
With this being said, how we determine how many cores to split the generation to is governed by the number of seeds supplied. In the event that one is using OS X, only the first seed supplied is used.
A vec
containing the realizations.
a = sitmo_parallel(10, c(1)) b = sitmo_parallel(10, c(1,2)) c = sitmo_parallel(10, c(1,2)) # True on only OS X or systems without openmp isTRUE(all.equal(a,b)) isTRUE(all.equal(b,c))
a = sitmo_parallel(10, c(1)) b = sitmo_parallel(10, c(1,2)) c = sitmo_parallel(10, c(1,2)) # True on only OS X or systems without openmp isTRUE(all.equal(a,b)) isTRUE(all.equal(b,c))
Shows how to create two separate RNGs and increase them together.
sitmo_two_seeds(n, seeds)
sitmo_two_seeds(n, seeds)
n |
An |
seeds |
A |
A matrix
with random sequences.
n = 10 a = sitmo_two_seeds(n, c(1337, 1338)) b = sitmo_two_seeds(n, c(1337, 1337)) isTRUE(all.equal(a[,1], a[,2])) isTRUE(all.equal(b[,1], b[,2])) isTRUE(all.equal(a[,1], b[,1]))
n = 10 a = sitmo_two_seeds(n, c(1337, 1338)) b = sitmo_two_seeds(n, c(1337, 1337)) isTRUE(all.equal(a[,1], a[,2])) isTRUE(all.equal(b[,1], b[,2])) isTRUE(all.equal(a[,1], b[,1]))