iRNGStream: Iterators that support parallel RNG

Description Usage Arguments See Also Examples

Description

The iRNGStream function creates an infinite iterator that calls nextRNGStream repeatedly, and iRNGSubStream creates an infinite iterator that calls nextRNGSubStream repeatedly.

Usage

1
2

Arguments

seed

Either a single number to be passed to set.seed or a vector to be passed to nextRNGStream or nextRNGSubStream.

See Also

set.seed, nextRNGStream, nextRNGSubStream

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
it <- iRNGStream(313)
print(nextElem(it))
print(nextElem(it))

## Not run: 
library(foreach)
foreach(1:3, rseed=iRNGSubStream(1970), .combine='c') %dopar% {
  RNGkind("L'Ecuyer-CMRG") # would be better to initialize workers only once
  assign('.Random.seed', rseed, pos=.GlobalEnv)
  runif(1)
}

## End(Not run)


Search within the itertools package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.