Description Usage Arguments See Also Examples
The iRNGStream
function creates an infinite iterator that calls
nextRNGStream
repeatedly, and iRNGSubStream
creates an
infinite iterator that calls nextRNGSubStream
repeatedly.
1 2 | iRNGStream(seed)
iRNGSubStream(seed)
|
seed |
Either a single number to be passed to |
set.seed
, nextRNGStream
,
nextRNGSubStream
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)
|
Loading required package: iterators
[1] 407 -148706266 816896415 -423200657 64647451 -1536586263
[7] 64930425
[1] 407 147611069 397195254 280483519 -1571776966 -1788649533
[7] -335749277
[1] 0.9200322 0.9857821 0.9834940
Warning message:
executing %dopar% sequentially: no parallel backend registered
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.