Package 'sitmo'

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

Help Index


sitmo: 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.

Author(s)

Maintainer: James Balamuta [email protected] (ORCID) [copyright holder]

Authors:

Other contributors:

See Also

Useful links:


Random Uniform Number Generator using base R

Description

The function provides an alternative implementation of random uniform distribution sampling using R's rng scope.

Usage

runif_r(n, min = 0, max = 1)

Arguments

n

An unsigned integer denoting the number of realizations to generate.

min

A double indicating the minimum aa value in the uniform's interval [a,b]\left[a,b\right]

max

A double indicating the maximum bb value in the uniform's interval [a,b]\left[a,b\right]

Examples

set.seed(134)
b = runif_r(10)

Random Uniform Number Generator with sitmo

Description

The function provides an implementation of sampling from a random uniform distribution

Usage

runif_sitmo(n, min = 0, max = 1, seed = 1L)

Arguments

n

An unsigned integer denoting the number of realizations to generate.

min

A double indicating the minimum aa value in the uniform's interval [a,b]\left[a,b\right]

max

A double indicating the maximum bb value in the uniform's interval [a,b]\left[a,b\right]

seed

A special unsigned integer containing a single seed.

Value

A numeric vector containing the realizations.

Examples

a = runif_sitmo(10)

Example RNG Draws with sitmo

Description

Shows a basic setup and use case for sitmo.

Usage

sitmo_draws(n)

Arguments

n

A unsigned int is a .

Value

A vec with random sequences.

Examples

n = 10
a = sitmo_draws(n)

Example Seed Set and RNG Draws with sitmo

Description

Shows how to set a seed in sitmo.

Usage

sitmo_engine_reset(n, seed)

Arguments

n

An unsigned int that dictates how many realizations occur.

seed

An unsigned int that controls the rng seed.

Value

A matrix with random sequences.

Examples

n = 10
a = sitmo_engine_reset(n, 1337)

isTRUE(all.equal(a[,1],a[,2]))

Example Seed Set and RNG Draws with sitmo

Description

Shows how to set a seed in sitmo.

Usage

sitmo_engine_seed(n, seed)

Arguments

n

An unsigned int that dictates how many realizations occur.

seed

An unsigned int that controls the rng seed.

Value

A vector with random sequences.

Examples

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))

Test Generation using sitmo and C++11

Description

The function provides an implementation of creating realizations from the default engine.

Usage

sitmo_parallel(n, seeds)

Arguments

n

An unsigned integer denoting the number of realizations to generate.

seeds

A vec containing a list of seeds. Each seed is run on its own core.

Details

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.

Value

A vec containing the realizations.

Examples

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))

Two RNG engines running side-by-side

Description

Shows how to create two separate RNGs and increase them together.

Usage

sitmo_two_seeds(n, seeds)

Arguments

n

An unsigned int that dictates how many realizations occur.

seeds

A vec containing two integers greater than 0.

Value

A matrix with random sequences.

Examples

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]))