The kinds to change; omitted entries are kept. Default: change nothing.
The kinds in effect before the call (the current ones when called without options), as R.
RNGkind(); // { kind: "Mersenne-Twister", normalKind: "Inversion", sampleKind: "Rejection" }
RNGkind({ kind: "L'Ecuyer-CMRG" });
setSeed(1);
runif(2); // [0.6775328286287442, 0.4273457228876442]
// R: set.seed(1, kind = "L'Ecuyer-CMRG"); runif(2)
RNGkind({ kind: "default", sampleKind: "Rounding" });
setSeed(1);
sampleInt(10, { size: 3 }); // [2, 3, 4]
// R: set.seed(1, kind = "default", sample.kind = "Rounding"); sample.int(10, 3) - 1
Reads or changes the kinds of random number generation. Equivalent to R's
RNGkind().kind: "Mersenne-Twister"(or"default"): R's default generator.kind: "L'Ecuyer-CMRG": L'Ecuyer's MRG32k3a, with independent streams for parallel work (nextRNGStream, nextRNGSubStream).sampleKind: "Rounding": indices drawn asfloor(n * u), assample,sampleIntandrwilcoxdid in R before 3.6.0 (slightly non-uniform for large n; R warns about it, rStats.js does not)."Rejection"(or"default") is R's default since 3.6.0. Other functions are not affected.As in R, changing
kindseeds the new generator from the next uniform of the current one (also when the kind does not change), so a stream stays reproducible from the last setSeed; changing onlysampleKindkeeps the stream. Call setSeed afterwards to seed the new generator directly:RNGkind({ kind }); setSeed(seed)is R'sset.seed(seed, kind). Also as in R, a call that gives a kind seeds a generator that has not been seeded yet (from the clock, as a first draw would); a call without kinds only reads them.