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

    Function setRandomSeed

    • Restores a generator state, including its kinds, as assigning R's .Random.seed does. Equivalent to R's .Random.seed.

      Parameters

      • state: ArrayLike<number>

        The integers returned by getRandomSeed, or copied from R's .Random.seed.

      Returns void

      RangeError for a kind code other than those of Mersenne-Twister or L'Ecuyer-CMRG with Inversion and Rejection or Rounding (10403, 403, 10407, 407), a state of the wrong length, or an invalid L'Ecuyer-CMRG state (R reseeds from the clock in these cases).

      setSeed(1);
      const s = getRandomSeed();
      runif(2); // [0.2655087, 0.3721239]
      setRandomSeed(s);
      runif(2); // [0.2655087, 0.3721239] (the same again)