parallel: Get initial values for parallel RNGs

Description Usage Arguments Value Note Author(s) See Also Examples

Description

On a multi-processor system, you may wish to run parallel chains using multiple jags.model objects, each running a single chain on a separate processor. This function returns a list of values that may be used to initialize the random number generator of each chain.

Usage

1

Arguments

factory

Name of the RNG factory to use.

nchain

Number of chains for which to initialize RNGs.

Value

parallel.seeds returns a list of RNG states. Each element is a list of length 2 with the following elements:

.RNG.name

The name of the RNG

.RNG.state

An integer vector giving the state of the RNG.

Note

It is not yet possible to make the results of parallel.seeds reproducible. This will be fixed in a future version of JAGS.

Author(s)

Martyn Plummer

See Also

jags.model, section “Random number generators”, for further details on RNG initialization; list.factories to find the names of available RNG factories.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
##The BaseRNG factory generates up to four distinct types of RNG. If
##more than 4 chains are requested, it will recycle the RNG types, but
##use different initial values
parallel.seeds("base::BaseRNG", 3)

## The lecuyer module provides the RngStream factory, which allows large
## numbers of independent parallel RNGs to be generated. 
load.module("lecuyer")
list.factories(type="rng")
parallel.seeds("lecuyer::RngStream", 5);

Example output

Loading required package: coda
Linked to JAGS 4.2.0
Loaded modules: basemod,bugs
[[1]]
[[1]]$.RNG.name
[1] "base::Wichmann-Hill"

[[1]]$.RNG.state
[1] 17564 25239 21316


[[2]]
[[2]]$.RNG.name
[1] "base::Marsaglia-Multicarry"

[[2]]$.RNG.state
[1] -1920186120  1146482618


[[3]]
[[3]]$.RNG.name
[1] "base::Super-Duper"

[[3]]$.RNG.state
[1] 1993270967 1644684769


module lecuyer loaded
             factory status
1 lecuyer::RngStream   TRUE
2      base::BaseRNG   TRUE
[[1]]
[[1]]$.RNG.name
[1] "lecuyer::RngStream"

[[1]]$.RNG.state
[1]   712142124  1692698730 -1117115432 -1586855178 -1984813756 -1630734782


[[2]]
[[2]]$.RNG.name
[1] "lecuyer::RngStream"

[[2]]$.RNG.state
[1]  -760418857 -1844641085  1461306334 -1455282306 -1159114430 -1047888878


[[3]]
[[3]]$.RNG.name
[1] "lecuyer::RngStream"

[[3]]$.RNG.state
[1]  1514414811  -882167429  -639645870 -1747293668   667189184 -1676546552


[[4]]
[[4]]$.RNG.name
[1] "lecuyer::RngStream"

[[4]]$.RNG.state
[1] -2099126107 -1289258451  1733809954  1887312598 -2024635994   991429627


[[5]]
[[5]]$.RNG.name
[1] "lecuyer::RngStream"

[[5]]$.RNG.state
[1] -1958462431  1610206078  1899205857 -1844410908  1718157262   642035802

rjags documentation built on Nov. 6, 2019, 5:07 p.m.