rStats.js v1.3.0
    Preparing search index...

    Function nextRNGStream

    • The start of the next stream of L'Ecuyer-CMRG: the state advanced by 2^127 steps. Equivalent to R's parallel::nextRNGStream().

      Streams started this way do not overlap for any practical length, so each parallel task (a worker, or one replicate of a simulation) can be given its own stream, reproducibly. Within a stream, nextRNGSubStream gives substreams of 2^76 steps.

      Parameters

      • state: ArrayLike<number>

        A 7-integer state as returned by getRandomSeed after RNGkind({ kind: "L'Ecuyer-CMRG" }), or copied from R's .Random.seed.

      Returns Int32Array

      A new state of the same form (the first element, the kind code, is unchanged). Pass it to setRandomSeed to draw from that stream.

      RangeError if state is not a valid L'Ecuyer-CMRG state.

      RNGkind({ kind: "L'Ecuyer-CMRG" });
      setSeed(1);
      const s1 = getRandomSeed();
      const s2 = nextRNGStream(s1); // R: s2 <- parallel::nextRNGStream(.Random.seed)
      setRandomSeed(s2);
      runif(2); // [0.31369782407981056, 0.9280126525616814]