@numero-uno-jpn/rstats 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.ja.md +5 -4
- package/README.md +6 -4
- package/dist/chunks/{chunk-YSWGDOWK.js → chunk-2X7JYQBI.js} +2 -2
- package/dist/chunks/{chunk-F5EDJFEO.js → chunk-36GVER3O.js} +2 -2
- package/dist/chunks/{chunk-7GQMKH3Z.js → chunk-3WUXRSM6.js} +1 -1
- package/dist/chunks/{chunk-JWBO5WVN.js → chunk-6I6QKTFK.js} +2 -2
- package/dist/chunks/{chunk-EZWBRCJL.js → chunk-ETOEZTGL.js} +1 -1
- package/dist/chunks/{chunk-VJ4BDBMU.js → chunk-FVPDVRJQ.js} +2 -2
- package/dist/chunks/{chunk-EZAFN5CD.js → chunk-GG4BJMJW.js} +1 -1
- package/dist/chunks/{chunk-5WDJPHYY.js → chunk-HITD7CX6.js} +1 -1
- package/dist/chunks/{chunk-Y5PYRAYP.js → chunk-KK4GE65D.js} +2 -2
- package/dist/chunks/{chunk-AHHS6AC4.js → chunk-LAUYSGV4.js} +2 -2
- package/dist/chunks/{chunk-ALM3VHFP.js → chunk-M6GDXKKS.js} +1 -1
- package/dist/chunks/{chunk-C5XTWMGB.js → chunk-PHHUHR7T.js} +1 -1
- package/dist/chunks/{chunk-TOGXTCZO.js → chunk-WQPFDDIY.js} +2 -2
- package/dist/chunks/{chunk-CGBNKHNZ.js → chunk-X2AWQSVS.js} +2 -2
- package/dist/chunks/{chunk-Y5CNQ266.js → chunk-ZRJQD7VS.js} +2 -2
- package/dist/data/grouping.d.ts +33 -12
- package/dist/data/grouping.js +2 -0
- package/dist/descriptive/basic.d.ts +130 -17
- package/dist/descriptive/basic.js +115 -14
- package/dist/descriptive/cov.d.ts +22 -12
- package/dist/descriptive/dataFrames.d.ts +39 -11
- package/dist/descriptive/dataFrames.js +14 -6
- package/dist/descriptive/factanal.d.ts +26 -6
- package/dist/descriptive/factanal.js +7 -3
- package/dist/descriptive/hist.d.ts +27 -6
- package/dist/descriptive/hist.js +9 -3
- package/dist/descriptive/missing.d.ts +13 -6
- package/dist/descriptive/missing.js +4 -2
- package/dist/descriptive/moments.d.ts +91 -13
- package/dist/descriptive/moments.js +66 -9
- package/dist/descriptive/omega.d.ts +28 -6
- package/dist/descriptive/omega.js +16 -4
- package/dist/descriptive/pivot.d.ts +22 -6
- package/dist/descriptive/pivot.js +7 -3
- package/dist/descriptive/quantile.d.ts +33 -5
- package/dist/descriptive/quantile.js +20 -2
- package/dist/descriptive/rank.d.ts +12 -2
- package/dist/descriptive/rank.js +2 -0
- package/dist/descriptive/table.d.ts +55 -7
- package/dist/descriptive/table.js +38 -4
- package/dist/descriptive.js +2 -2
- package/dist/distributions/arcsine.d.ts +40 -5
- package/dist/distributions/arcsine.js +35 -4
- package/dist/distributions/beta.d.ts +12 -0
- package/dist/distributions/beta.js +12 -0
- package/dist/distributions/binomial.d.ts +18 -0
- package/dist/distributions/binomial.js +18 -0
- package/dist/distributions/bvnorm.d.ts +4 -1
- package/dist/distributions/bvnorm.js +4 -1
- package/dist/distributions/cauchy.d.ts +24 -0
- package/dist/distributions/cauchy.js +24 -0
- package/dist/distributions/chisq.d.ts +18 -0
- package/dist/distributions/chisq.js +18 -0
- package/dist/distributions/exponential.d.ts +29 -1
- package/dist/distributions/exponential.js +24 -0
- package/dist/distributions/f.d.ts +18 -0
- package/dist/distributions/f.js +18 -0
- package/dist/distributions/gamma.d.ts +20 -0
- package/dist/distributions/gamma.js +18 -0
- package/dist/distributions/geometric.d.ts +24 -0
- package/dist/distributions/geometric.js +24 -0
- package/dist/distributions/hypergeometric.d.ts +24 -0
- package/dist/distributions/hypergeometric.js +24 -0
- package/dist/distributions/invgamma.d.ts +32 -4
- package/dist/distributions/invgamma.js +27 -3
- package/dist/distributions/kumaraswamy.d.ts +31 -3
- package/dist/distributions/kumaraswamy.js +31 -3
- package/dist/distributions/laplace.d.ts +36 -4
- package/dist/distributions/laplace.js +31 -3
- package/dist/distributions/logistic.d.ts +29 -1
- package/dist/distributions/logistic.js +24 -0
- package/dist/distributions/lognormal.d.ts +29 -1
- package/dist/distributions/lognormal.js +24 -0
- package/dist/distributions/multinomial.d.ts +7 -1
- package/dist/distributions/multinomial.js +2 -0
- package/dist/distributions/negbinomial.d.ts +29 -1
- package/dist/distributions/negbinomial.js +24 -0
- package/dist/distributions/normal.d.ts +11 -1
- package/dist/distributions/normal.js +6 -0
- package/dist/distributions/pareto.d.ts +36 -4
- package/dist/distributions/pareto.js +31 -3
- package/dist/distributions/poisson.d.ts +18 -0
- package/dist/distributions/poisson.js +18 -0
- package/dist/distributions/signrank.d.ts +24 -0
- package/dist/distributions/signrank.js +24 -0
- package/dist/distributions/summary.d.ts +20 -2
- package/dist/distributions/summary.js +4 -0
- package/dist/distributions/t.d.ts +18 -0
- package/dist/distributions/t.js +18 -0
- package/dist/distributions/triangular.d.ts +36 -4
- package/dist/distributions/triangular.js +31 -3
- package/dist/distributions/tukey.d.ts +15 -1
- package/dist/distributions/tukey.js +10 -0
- package/dist/distributions/uniform.d.ts +29 -1
- package/dist/distributions/uniform.js +24 -0
- package/dist/distributions/weibull.d.ts +29 -1
- package/dist/distributions/weibull.js +24 -0
- package/dist/distributions/wilcox.d.ts +24 -0
- package/dist/distributions/wilcox.js +24 -0
- package/dist/distributions.js +2 -2
- package/dist/entries/descriptive.d.ts +1 -1
- package/dist/entries/numerics.d.ts +1 -1
- package/dist/entries/tests.js +1 -1
- package/dist/htest/agreement.d.ts +61 -23
- package/dist/htest/agreement.js +19 -9
- package/dist/htest/ansariTest.d.ts +8 -2
- package/dist/htest/aov.d.ts +43 -10
- package/dist/htest/aov.js +17 -3
- package/dist/htest/binomTest.d.ts +12 -2
- package/dist/htest/binomTest.js +2 -0
- package/dist/htest/brunnerMunzelTest.d.ts +9 -3
- package/dist/htest/brunnerMunzelTest.js +4 -2
- package/dist/htest/chisqTest.d.ts +19 -3
- package/dist/htest/cor.d.ts +20 -4
- package/dist/htest/effectSize.d.ts +70 -12
- package/dist/htest/effectSize.js +40 -7
- package/dist/htest/fisherTest.d.ts +9 -1
- package/dist/htest/fisherTest.js +2 -0
- package/dist/htest/groups.d.ts +5 -1
- package/dist/htest/ksTest.d.ts +20 -3
- package/dist/htest/leveneTest.d.ts +15 -4
- package/dist/htest/leveneTest.js +5 -2
- package/dist/htest/mantelhaenTest.d.ts +25 -3
- package/dist/htest/mantelhaenTest.js +15 -1
- package/dist/htest/mcnemarTest.d.ts +14 -4
- package/dist/htest/mcnemarTest.js +4 -2
- package/dist/htest/multipleComparisons.d.ts +173 -29
- package/dist/htest/multipleComparisons.js +123 -19
- package/dist/htest/normalityTests.d.ts +56 -9
- package/dist/htest/normalityTests.js +40 -6
- package/dist/htest/onewayTest.d.ts +32 -3
- package/dist/htest/onewayTest.js +10 -0
- package/dist/htest/pAdjust.d.ts +9 -1
- package/dist/htest/pAdjust.js +2 -0
- package/dist/htest/pairwise.d.ts +50 -5
- package/dist/htest/pairwise.js +25 -0
- package/dist/htest/poissonTest.d.ts +12 -2
- package/dist/htest/poissonTest.js +2 -0
- package/dist/htest/polycor.d.ts +29 -10
- package/dist/htest/power.d.ts +60 -6
- package/dist/htest/power.js +6 -0
- package/dist/htest/propTest.d.ts +13 -2
- package/dist/htest/propTest.js +2 -0
- package/dist/htest/pwr.d.ts +286 -36
- package/dist/htest/pwr.js +116 -15
- package/dist/htest/rankTests.d.ts +80 -12
- package/dist/htest/rankTests.js +11 -2
- package/dist/htest/tTest.d.ts +13 -3
- package/dist/htest/trendTests.d.ts +29 -8
- package/dist/htest/trendTests.js +8 -4
- package/dist/htest/types.d.ts +14 -2
- package/dist/htest/varTest.d.ts +25 -8
- package/dist/htest/wilcoxTest.d.ts +10 -2
- package/dist/internal/dpq.d.ts +4 -0
- package/dist/internal/noncentral.d.ts +2 -0
- package/dist/internal/vectorize.d.ts +4 -0
- package/dist/linalg/basic.d.ts +39 -5
- package/dist/linalg/basic.js +15 -0
- package/dist/linalg/chol.d.ts +26 -5
- package/dist/linalg/chol.js +7 -0
- package/dist/linalg/eigen.d.ts +16 -7
- package/dist/linalg/eigen.js +6 -5
- package/dist/linalg/expm.d.ts +15 -5
- package/dist/linalg/expm.js +5 -3
- package/dist/linalg/kappa.d.ts +21 -1
- package/dist/linalg/kappa.js +16 -0
- package/dist/linalg/lu.d.ts +30 -6
- package/dist/linalg/lu.js +15 -3
- package/dist/linalg/matrix.d.ts +4 -0
- package/dist/linalg/norm.d.ts +16 -1
- package/dist/linalg/norm.js +9 -0
- package/dist/linalg/ops.d.ts +156 -35
- package/dist/linalg/ops.js +96 -15
- package/dist/linalg/qr.d.ts +87 -12
- package/dist/linalg/qr.js +31 -0
- package/dist/linalg/schur.d.ts +8 -2
- package/dist/linalg/schur.js +3 -1
- package/dist/linalg/solve.d.ts +42 -6
- package/dist/linalg/solve.js +22 -0
- package/dist/linalg/svd.d.ts +12 -2
- package/dist/linalg/svd.js +2 -0
- package/dist/linalg.js +2 -2
- package/dist/models/anovaSequential.d.ts +26 -4
- package/dist/models/anovaSequential.js +3 -1
- package/dist/models/aovEz.d.ts +29 -6
- package/dist/models/aovEz.js +5 -2
- package/dist/models/aovStrata.d.ts +12 -2
- package/dist/models/carAnova.d.ts +9 -3
- package/dist/models/carAnova.js +4 -2
- package/dist/models/coxph.d.ts +33 -7
- package/dist/models/coxph.js +8 -3
- package/dist/models/glm.d.ts +128 -21
- package/dist/models/glm.js +71 -14
- package/dist/models/glmAnova.d.ts +30 -5
- package/dist/models/glmAnova.js +15 -2
- package/dist/models/glmConfint.d.ts +16 -2
- package/dist/models/glmConfint.js +9 -1
- package/dist/models/glmFamily.d.ts +27 -5
- package/dist/models/lm.d.ts +75 -17
- package/dist/models/lm.js +22 -4
- package/dist/models/mauchly.d.ts +20 -5
- package/dist/models/mauchly.js +7 -3
- package/dist/models/modelFrame.d.ts +5 -1
- package/dist/models/modelMatrix.d.ts +18 -4
- package/dist/models/modelMatrix.js +3 -1
- package/dist/models/survival.d.ts +41 -9
- package/dist/models/survival.js +10 -4
- package/dist/numerics/deriv.d.ts +21 -6
- package/dist/numerics/deriv.js +16 -5
- package/dist/numerics/integrate.d.ts +37 -7
- package/dist/numerics/integrate.js +8 -2
- package/dist/numerics/interp.d.ts +63 -12
- package/dist/numerics/interp.js +30 -6
- package/dist/numerics/ode.d.ts +15 -5
- package/dist/numerics/ode.js +5 -3
- package/dist/numerics.js +2 -2
- package/dist/optim/optim.d.ts +32 -8
- package/dist/optim/optim.js +8 -4
- package/dist/random/beta.d.ts +8 -0
- package/dist/random/beta.js +8 -0
- package/dist/random/binomial.d.ts +16 -0
- package/dist/random/binomial.js +16 -0
- package/dist/random/continuous.d.ts +51 -0
- package/dist/random/continuous.js +51 -0
- package/dist/random/extra.d.ts +66 -6
- package/dist/random/extra.js +66 -6
- package/dist/random/gamma.d.ts +33 -0
- package/dist/random/gamma.js +33 -0
- package/dist/random/hyper.d.ts +8 -0
- package/dist/random/hyper.js +8 -0
- package/dist/random/poisson.d.ts +25 -0
- package/dist/random/poisson.js +25 -0
- package/dist/random/r2dtable.d.ts +2 -0
- package/dist/random/r2dtable.js +2 -0
- package/dist/random/rank.d.ts +16 -0
- package/dist/random/rank.js +16 -0
- package/dist/random/rng.d.ts +49 -6
- package/dist/random/rng.js +29 -2
- package/dist/random/sample.d.ts +10 -2
- package/dist/random/sample.js +5 -1
- package/dist/random/streams.d.ts +13 -0
- package/dist/random/streams.js +13 -0
- package/dist/rstats.js +1 -1
- package/dist/special/besselIK.d.ts +11 -3
- package/dist/special/besselIK.js +6 -2
- package/dist/special/besselJY.d.ts +6 -2
- package/dist/special/besselJY.js +6 -2
- package/dist/special/beta.d.ts +16 -2
- package/dist/special/beta.js +16 -2
- package/dist/special/choose.d.ts +13 -5
- package/dist/special/choose.js +13 -5
- package/dist/special/erf.d.ts +8 -3
- package/dist/special/erf.js +8 -3
- package/dist/special/extra.d.ts +30 -10
- package/dist/special/extra.js +25 -9
- package/dist/special/gamma.d.ts +18 -2
- package/dist/special/gamma.js +18 -2
- package/dist/special/log1p.d.ts +16 -7
- package/dist/special/log1p.js +16 -7
- package/dist/special/psigamma.d.ts +9 -3
- package/dist/special/psigamma.js +9 -3
- package/dist/special/rCompatible.d.ts +5 -1
- package/dist/special.js +2 -2
- package/dist/tests.js +2 -2
- package/llms.txt +2 -0
- package/package.json +1 -1
package/dist/random/rng.js
CHANGED
|
@@ -46,6 +46,8 @@ function ensureSeeded() {
|
|
|
46
46
|
* rnorm(3); // [-0.6264538107423324, 0.18364332422208224, -0.8356286124100472]
|
|
47
47
|
* // R: set.seed(1); rnorm(3)
|
|
48
48
|
* ```
|
|
49
|
+
*
|
|
50
|
+
* @category Random numbers
|
|
49
51
|
*/
|
|
50
52
|
export function setSeed(seed) {
|
|
51
53
|
if (!Number.isFinite(seed))
|
|
@@ -99,6 +101,8 @@ function lookup(table, name, what) {
|
|
|
99
101
|
* sampleInt(10, { size: 3 }); // [2, 3, 4]
|
|
100
102
|
* // R: set.seed(1, kind = "default", sample.kind = "Rounding"); sample.int(10, 3) - 1
|
|
101
103
|
* ```
|
|
104
|
+
*
|
|
105
|
+
* @category Random numbers
|
|
102
106
|
*/
|
|
103
107
|
export function RNGkind(options = {}) {
|
|
104
108
|
const previous = {
|
|
@@ -121,12 +125,23 @@ export function RNGkind(options = {}) {
|
|
|
121
125
|
/** Value of .Random.seed[1]: uniform kind (3 Mersenne-Twister, 7 L'Ecuyer-CMRG) + 100 × normal 4 (Inversion) + 10000 × sample kind (0 Rounding, 1 Rejection) */
|
|
122
126
|
const kindCode = () => (gen === mt ? 3 : 7) + 400 + (rounding ? 0 : 10000);
|
|
123
127
|
/**
|
|
124
|
-
* Returns a copy of the current generator state
|
|
128
|
+
* Returns a copy of the current generator state, as reading R's `.Random.seed` does.
|
|
129
|
+
* Equivalent to R's `.Random.seed`.
|
|
125
130
|
*
|
|
126
131
|
* @returns The same integers as R's `.Random.seed`: the kind code (`10403` for R's default,
|
|
127
132
|
* `403` with `sampleKind: "Rounding"`, `10407` for L'Ecuyer-CMRG), followed by 625 integers
|
|
128
133
|
* for Mersenne-Twister or 6 for L'Ecuyer-CMRG (unsigned seeds of 2^31 or more appear as
|
|
129
134
|
* negative numbers, as in R). Pass it to {@link setRandomSeed} to restore the state.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* setSeed(1);
|
|
139
|
+
* const s = getRandomSeed();
|
|
140
|
+
* s.length; // 626
|
|
141
|
+
* s[0]; // 10403
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @category Random numbers
|
|
130
145
|
*/
|
|
131
146
|
export function getRandomSeed() {
|
|
132
147
|
ensureSeeded();
|
|
@@ -136,12 +151,24 @@ export function getRandomSeed() {
|
|
|
136
151
|
return Int32Array.of(kindCode(), ...gen.s);
|
|
137
152
|
}
|
|
138
153
|
/**
|
|
139
|
-
* Restores a generator state, including its kinds
|
|
154
|
+
* Restores a generator state, including its kinds, as assigning R's `.Random.seed` does.
|
|
155
|
+
* Equivalent to R's `.Random.seed`.
|
|
140
156
|
*
|
|
141
157
|
* @param state The integers returned by {@link getRandomSeed}, or copied from R's `.Random.seed`.
|
|
142
158
|
* @throws RangeError for a kind code other than those of Mersenne-Twister or L'Ecuyer-CMRG with
|
|
143
159
|
* Inversion and Rejection or Rounding (`10403`, `403`, `10407`, `407`), a state of the wrong
|
|
144
160
|
* length, or an invalid L'Ecuyer-CMRG state (R reseeds from the clock in these cases).
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* setSeed(1);
|
|
165
|
+
* const s = getRandomSeed();
|
|
166
|
+
* runif(2); // [0.2655087, 0.3721239]
|
|
167
|
+
* setRandomSeed(s);
|
|
168
|
+
* runif(2); // [0.2655087, 0.3721239] (the same again)
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @category Random numbers
|
|
145
172
|
*/
|
|
146
173
|
export function setRandomSeed(state) {
|
|
147
174
|
const code = state[0];
|
package/dist/random/sample.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Options for {@link sample} and {@link sampleInt}.
|
|
3
|
+
*
|
|
4
|
+
* @category Random numbers
|
|
5
|
+
*/
|
|
2
6
|
export interface SampleOptions {
|
|
3
7
|
/** Number of items to draw. Default: the number of candidates (a random permutation). */
|
|
4
8
|
size?: number;
|
|
@@ -8,7 +12,7 @@ export interface SampleOptions {
|
|
|
8
12
|
prob?: readonly number[];
|
|
9
13
|
}
|
|
10
14
|
/**
|
|
11
|
-
* Random sample of integers from `0..n-1`. Equivalent to R's `sample.int()
|
|
15
|
+
* Random sample of integers from `0..n-1`. Equivalent to R's `sample.int()`. Unlike R, it is 0-based.
|
|
12
16
|
*
|
|
13
17
|
* The result is R's `sample.int(n, ...)` minus 1, so it can be used directly as array
|
|
14
18
|
* indices. It consumes the same random numbers as R (default `sample.kind = "Rejection"`).
|
|
@@ -22,6 +26,8 @@ export interface SampleOptions {
|
|
|
22
26
|
* setSeed(42);
|
|
23
27
|
* sampleInt(10, { size: 3 }); // [0, 4, 9] (R: set.seed(42); sample.int(10, 3) - 1)
|
|
24
28
|
* ```
|
|
29
|
+
*
|
|
30
|
+
* @category Random numbers
|
|
25
31
|
*/
|
|
26
32
|
export declare function sampleInt(n: number, options?: SampleOptions): number[];
|
|
27
33
|
/**
|
|
@@ -41,5 +47,7 @@ export declare function sampleInt(n: number, options?: SampleOptions): number[];
|
|
|
41
47
|
* sample(["a", "b", "c", "d", "e"]); // ["a", "e", "d", "c", "b"]
|
|
42
48
|
* sample([1, 2, 3], { size: 5, replace: true, prob: [0.5, 0.3, 0.2] });
|
|
43
49
|
* ```
|
|
50
|
+
*
|
|
51
|
+
* @category Random numbers
|
|
44
52
|
*/
|
|
45
53
|
export declare function sample<T>(x: readonly T[], options?: SampleOptions): T[];
|
package/dist/random/sample.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// All of this was verified against observed R output.
|
|
9
9
|
import { isRounding, unifIndex, unifRand } from "./rng.js";
|
|
10
10
|
/**
|
|
11
|
-
* Random sample of integers from `0..n-1`. Equivalent to R's `sample.int()
|
|
11
|
+
* Random sample of integers from `0..n-1`. Equivalent to R's `sample.int()`. Unlike R, it is 0-based.
|
|
12
12
|
*
|
|
13
13
|
* The result is R's `sample.int(n, ...)` minus 1, so it can be used directly as array
|
|
14
14
|
* indices. It consumes the same random numbers as R (default `sample.kind = "Rejection"`).
|
|
@@ -22,6 +22,8 @@ import { isRounding, unifIndex, unifRand } from "./rng.js";
|
|
|
22
22
|
* setSeed(42);
|
|
23
23
|
* sampleInt(10, { size: 3 }); // [0, 4, 9] (R: set.seed(42); sample.int(10, 3) - 1)
|
|
24
24
|
* ```
|
|
25
|
+
*
|
|
26
|
+
* @category Random numbers
|
|
25
27
|
*/
|
|
26
28
|
export function sampleInt(n, options = {}) {
|
|
27
29
|
return sampleInt1(n, options).map((v) => v - 1);
|
|
@@ -105,6 +107,8 @@ function sampleInt1(n, options) {
|
|
|
105
107
|
* sample(["a", "b", "c", "d", "e"]); // ["a", "e", "d", "c", "b"]
|
|
106
108
|
* sample([1, 2, 3], { size: 5, replace: true, prob: [0.5, 0.3, 0.2] });
|
|
107
109
|
* ```
|
|
110
|
+
*
|
|
111
|
+
* @category Random numbers
|
|
108
112
|
*/
|
|
109
113
|
export function sample(x, options = {}) {
|
|
110
114
|
return sampleInt1(x.length, options).map((i) => x[i - 1]);
|
package/dist/random/streams.d.ts
CHANGED
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
* setRandomSeed(s2);
|
|
22
22
|
* runif(2); // [0.31369782407981056, 0.9280126525616814]
|
|
23
23
|
* ```
|
|
24
|
+
*
|
|
25
|
+
* @category Random numbers
|
|
24
26
|
*/
|
|
25
27
|
export declare function nextRNGStream(state: ArrayLike<number>): Int32Array;
|
|
26
28
|
/**
|
|
@@ -30,5 +32,16 @@ export declare function nextRNGStream(state: ArrayLike<number>): Int32Array;
|
|
|
30
32
|
* @param state A 7-integer state, as for {@link nextRNGStream}.
|
|
31
33
|
* @returns A new state of the same form.
|
|
32
34
|
* @throws RangeError if `state` is not a valid L'Ecuyer-CMRG state.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* RNGkind({ kind: "L'Ecuyer-CMRG" });
|
|
39
|
+
* setSeed(1);
|
|
40
|
+
* setRandomSeed(nextRNGSubStream(getRandomSeed()));
|
|
41
|
+
* // R: .Random.seed <- parallel::nextRNGSubStream(.Random.seed)
|
|
42
|
+
* runif(2); // [0.9158314, 0.1484848]
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @category Random numbers
|
|
33
46
|
*/
|
|
34
47
|
export declare function nextRNGSubStream(state: ArrayLike<number>): Int32Array;
|
package/dist/random/streams.js
CHANGED
|
@@ -58,6 +58,8 @@ function jump(state, a1, a2) {
|
|
|
58
58
|
* setRandomSeed(s2);
|
|
59
59
|
* runif(2); // [0.31369782407981056, 0.9280126525616814]
|
|
60
60
|
* ```
|
|
61
|
+
*
|
|
62
|
+
* @category Random numbers
|
|
61
63
|
*/
|
|
62
64
|
export function nextRNGStream(state) {
|
|
63
65
|
return jump(state, A1P127, A2P127);
|
|
@@ -69,6 +71,17 @@ export function nextRNGStream(state) {
|
|
|
69
71
|
* @param state A 7-integer state, as for {@link nextRNGStream}.
|
|
70
72
|
* @returns A new state of the same form.
|
|
71
73
|
* @throws RangeError if `state` is not a valid L'Ecuyer-CMRG state.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* RNGkind({ kind: "L'Ecuyer-CMRG" });
|
|
78
|
+
* setSeed(1);
|
|
79
|
+
* setRandomSeed(nextRNGSubStream(getRandomSeed()));
|
|
80
|
+
* // R: .Random.seed <- parallel::nextRNGSubStream(.Random.seed)
|
|
81
|
+
* runif(2); // [0.9158314, 0.1484848]
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @category Random numbers
|
|
72
85
|
*/
|
|
73
86
|
export function nextRNGSubStream(state) {
|
|
74
87
|
return jump(state, A1P76, A2P76);
|