@numero-uno-jpn/rstats 0.16.0 → 0.17.0
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 +128 -0
- package/README.ja.md +44 -18
- package/README.md +45 -18
- package/dist/chunks/chunk-2C33MXSW.js +3 -0
- package/dist/chunks/chunk-34S5SQY6.js +2 -0
- package/dist/chunks/{chunk-URIO5LY5.js → chunk-4WE3OO62.js} +2 -2
- package/dist/chunks/chunk-5AYHCITP.js +2 -0
- package/dist/chunks/chunk-6JJQL6HL.js +2 -0
- package/dist/chunks/chunk-C7V2FH6L.js +3 -0
- package/dist/chunks/chunk-CZI7KUO3.js +2 -0
- package/dist/chunks/chunk-DXI5N2ET.js +2 -0
- package/dist/chunks/chunk-FY3FVOBM.js +2 -0
- package/dist/chunks/{chunk-QNNL7AZ3.js → chunk-H3WVPZDL.js} +2 -2
- package/dist/chunks/chunk-LHUIJQHY.js +2 -0
- package/dist/chunks/chunk-LV3W2F7N.js +2 -0
- package/dist/chunks/chunk-M4ITG7YR.js +2 -0
- package/dist/chunks/{chunk-FLJNSXSW.js → chunk-NSYZTS26.js} +2 -2
- package/dist/chunks/chunk-ONY5CISH.js +2 -0
- package/dist/chunks/chunk-RFE7MVP7.js +2 -0
- package/dist/chunks/{chunk-W26LRYOJ.js → chunk-SE7V2KLO.js} +1 -1
- package/dist/chunks/chunk-THIGHOKK.js +2 -0
- package/dist/chunks/chunk-TNMJPQPV.js +2 -0
- package/dist/chunks/chunk-WM7VFXTV.js +2 -0
- package/dist/chunks/chunk-WMDYDTVQ.js +2 -0
- package/dist/chunks/chunk-XLSFJTTK.js +2 -0
- package/dist/chunks/{chunk-5UQCRBAG.js → chunk-Z37NELOS.js} +1 -1
- package/dist/chunks/chunk-ZFQWB222.js +2 -0
- package/dist/data/grouping.js +6 -2
- package/dist/descriptive/basic.js +20 -0
- package/dist/descriptive/cov.js +11 -0
- package/dist/descriptive/dataFrames.js +13 -5
- package/dist/descriptive/factanal.d.ts +2 -0
- package/dist/descriptive/factanal.js +10 -2
- package/dist/descriptive/hist.js +6 -0
- package/dist/descriptive/moments.js +14 -0
- package/dist/descriptive/omega.js +8 -3
- package/dist/descriptive/pivot.d.ts +4 -1
- package/dist/descriptive/pivot.js +27 -13
- package/dist/descriptive/quantile.js +8 -0
- package/dist/descriptive/rank.js +4 -0
- package/dist/descriptive/table.d.ts +20 -1
- package/dist/descriptive/table.js +14 -14
- package/dist/descriptive.js +2 -2
- package/dist/distributions/arcsine.js +8 -0
- package/dist/distributions/beta.js +9 -0
- package/dist/distributions/binomial.js +9 -0
- package/dist/distributions/cauchy.js +9 -0
- package/dist/distributions/chisq.js +9 -0
- package/dist/distributions/exponential.js +9 -0
- package/dist/distributions/f.js +9 -0
- package/dist/distributions/gamma.js +8 -0
- package/dist/distributions/geometric.js +9 -0
- package/dist/distributions/hypergeometric.js +8 -0
- package/dist/distributions/invgamma.js +8 -0
- package/dist/distributions/kumaraswamy.js +9 -0
- package/dist/distributions/laplace.js +9 -0
- package/dist/distributions/logistic.js +9 -0
- package/dist/distributions/lognormal.js +8 -0
- package/dist/distributions/multinomial.js +4 -0
- package/dist/distributions/negbinomial.js +8 -0
- package/dist/distributions/normal.js +8 -0
- package/dist/distributions/pareto.js +8 -0
- package/dist/distributions/poisson.js +9 -0
- package/dist/distributions/signrank.js +9 -0
- package/dist/distributions/summary.d.ts +2 -1
- package/dist/distributions/summary.js +31 -1
- package/dist/distributions/t.js +9 -0
- package/dist/distributions/triangular.js +9 -0
- package/dist/distributions/tukey.js +6 -0
- package/dist/distributions/uniform.js +8 -0
- package/dist/distributions/weibull.js +8 -0
- package/dist/distributions/wilcox.js +9 -0
- package/dist/distributions.js +2 -2
- package/dist/entries/descriptive.d.ts +3 -1
- package/dist/entries/descriptive.js +1 -1
- package/dist/entries/distributions.d.ts +1 -0
- package/dist/entries/distributions.js +2 -0
- package/dist/entries/linalg.d.ts +3 -1
- package/dist/entries/mixed.d.ts +3 -0
- package/dist/entries/mixed.js +2 -0
- package/dist/entries/numerics.d.ts +2 -1
- package/dist/entries/tests.d.ts +8 -5
- package/dist/entries/tests.js +3 -1
- package/dist/htest/agreement.d.ts +13 -0
- package/dist/htest/agreement.js +46 -7
- package/dist/htest/ansariTest.d.ts +2 -1
- package/dist/htest/ansariTest.js +43 -12
- package/dist/htest/aov.d.ts +28 -22
- package/dist/htest/aov.js +42 -13
- package/dist/htest/binomTest.js +6 -0
- package/dist/htest/brunnerMunzelTest.js +5 -0
- package/dist/htest/chisqTest.d.ts +3 -1
- package/dist/htest/chisqTest.js +21 -3
- package/dist/htest/cor.d.ts +7 -1
- package/dist/htest/cor.js +40 -7
- package/dist/htest/core/simulate.d.ts +6 -0
- package/dist/htest/core/simulate.js +20 -0
- package/dist/htest/effectSize.d.ts +3 -0
- package/dist/htest/effectSize.js +28 -8
- package/dist/htest/fisherTest.d.ts +2 -1
- package/dist/htest/fisherTest.js +52 -6
- package/dist/htest/ksTest.d.ts +4 -0
- package/dist/htest/ksTest.js +13 -4
- package/dist/htest/leveneTest.d.ts +2 -0
- package/dist/htest/leveneTest.js +9 -3
- package/dist/htest/mantelhaenTest.js +7 -0
- package/dist/htest/mcnemarTest.js +8 -0
- package/dist/htest/multipleComparisons.d.ts +16 -25
- package/dist/htest/multipleComparisons.js +26 -43
- package/dist/htest/normalityTests.js +10 -4
- package/dist/htest/onewayTest.js +10 -0
- package/dist/htest/pAdjust.js +4 -0
- package/dist/htest/pairwise.d.ts +2 -0
- package/dist/htest/pairwise.js +29 -6
- package/dist/htest/poissonTest.js +6 -0
- package/dist/htest/polycor.js +20 -10
- package/dist/htest/power.d.ts +4 -0
- package/dist/htest/power.js +16 -2
- package/dist/htest/propTest.d.ts +3 -0
- package/dist/htest/propTest.js +23 -2
- package/dist/htest/pwr.d.ts +38 -1
- package/dist/htest/pwr.js +38 -15
- package/dist/htest/rankTests.js +7 -1
- package/dist/htest/tTest.d.ts +2 -0
- package/dist/htest/tTest.js +9 -0
- package/dist/htest/testFormula.js +11 -11
- package/dist/htest/trendTests.d.ts +21 -1
- package/dist/htest/trendTests.js +13 -18
- package/dist/htest/types.d.ts +2 -0
- package/dist/htest/varTest.js +7 -0
- package/dist/htest/wilcoxTest.js +51 -9
- package/dist/internal/checkOptions.d.ts +11 -0
- package/dist/internal/checkOptions.js +31 -0
- package/dist/internal/optionalArgs.d.ts +12 -0
- package/dist/internal/optionalArgs.js +46 -0
- package/dist/internal/warnings.d.ts +66 -0
- package/dist/internal/warnings.js +122 -0
- package/dist/linalg/basic.js +7 -0
- package/dist/linalg/chol.js +6 -0
- package/dist/linalg/eigen.js +4 -0
- package/dist/linalg/expm.js +4 -0
- package/dist/linalg/kappa.js +6 -0
- package/dist/linalg/lu.js +5 -0
- package/dist/linalg/norm.js +4 -0
- package/dist/linalg/ops.d.ts +27 -2
- package/dist/linalg/ops.js +14 -13
- package/dist/linalg/qr.js +14 -0
- package/dist/linalg/solve.js +9 -0
- package/dist/linalg/svd.js +6 -2
- package/dist/linalg.js +2 -2
- package/dist/mixed.js +4 -4
- package/dist/models/anovaSequential.d.ts +16 -1
- package/dist/models/anovaSequential.js +50 -7
- package/dist/models/aovEz.js +16 -11
- package/dist/models/aovStrata.js +15 -4
- package/dist/models/carAnova.js +11 -17
- package/dist/models/coxph.d.ts +6 -0
- package/dist/models/coxph.js +21 -6
- package/dist/models/glm.d.ts +22 -2
- package/dist/models/glm.js +32 -22
- package/dist/models/glmAnova.js +8 -3
- package/dist/models/glmConfint.js +6 -2
- package/dist/models/glmFamily.d.ts +1 -6
- package/dist/models/glmFamily.js +3 -22
- package/dist/models/lm.js +13 -3
- package/dist/models/lmer.d.ts +11 -6
- package/dist/models/lmer.js +20 -15
- package/dist/models/lmerAnova.d.ts +3 -3
- package/dist/models/lmerAnova.js +10 -5
- package/dist/models/lmerTest.d.ts +4 -4
- package/dist/models/lmerTest.js +19 -11
- package/dist/models/mauchly.d.ts +2 -0
- package/dist/models/mauchly.js +7 -2
- package/dist/models/modelFrame.js +2 -2
- package/dist/models/modelMatrix.js +7 -2
- package/dist/models/survival.d.ts +6 -0
- package/dist/models/survival.js +9 -2
- package/dist/numerics/deriv.js +8 -0
- package/dist/numerics/integrate.js +8 -0
- package/dist/numerics/interp.d.ts +32 -7
- package/dist/numerics/interp.js +27 -9
- package/dist/numerics/ode.js +4 -0
- package/dist/numerics.js +2 -2
- package/dist/optim/optim.js +17 -2
- package/dist/random/beta.js +5 -0
- package/dist/random/continuous.js +17 -0
- package/dist/random/extra.js +13 -0
- package/dist/random/gamma.js +11 -0
- package/dist/random/poisson.js +5 -0
- package/dist/random/rng.js +4 -0
- package/dist/random/sample.js +6 -0
- package/dist/rstats.js +17 -14
- package/dist/special/besselIK.js +7 -0
- package/dist/special/choose.js +7 -0
- package/dist/special/psigamma.js +7 -0
- package/dist/special.js +2 -2
- package/dist/tests.js +15 -11
- package/llms.txt +5 -2
- package/package.json +19 -10
- package/dist/chunks/chunk-2D2IQWUQ.js +0 -2
- package/dist/chunks/chunk-6CSTWA5E.js +0 -2
- package/dist/chunks/chunk-72Y3HZID.js +0 -2
- package/dist/chunks/chunk-BG2KLEHM.js +0 -2
- package/dist/chunks/chunk-CMEKBNHQ.js +0 -2
- package/dist/chunks/chunk-GM53LWSR.js +0 -2
- package/dist/chunks/chunk-JBCA56ZS.js +0 -3
- package/dist/chunks/chunk-K3RJAD2T.js +0 -2
- package/dist/chunks/chunk-KAZRWIB5.js +0 -2
- package/dist/chunks/chunk-KBVVIMXX.js +0 -3
- package/dist/chunks/chunk-N3SIFCZX.js +0 -2
- package/dist/chunks/chunk-SC6CV4Z3.js +0 -2
- package/dist/chunks/chunk-SYWOBOTR.js +0 -2
- package/dist/chunks/chunk-VTUGG2SV.js +0 -2
- package/dist/chunks/chunk-XHETEYVC.js +0 -2
- package/dist/chunks/chunk-YRZWONZB.js +0 -3
- package/dist/chunks/chunk-ZGABZMWX.js +0 -2
package/dist/distributions/f.js
CHANGED
|
@@ -16,6 +16,12 @@ import { ddAdd, ddDiv, ddLog, ddMul, ddNeg, ddSub, twoProd, twoSum } from "../sp
|
|
|
16
16
|
import { dgamma1, pgamma1, qgamma1 } from "./gamma.js";
|
|
17
17
|
import { dnf1, pnf1, qnf1 } from "./nbeta.js";
|
|
18
18
|
import { betaQuantileGuess } from "./beta.js";
|
|
19
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
20
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
21
|
+
const DF_KEYS = ["log", "ncp"];
|
|
22
|
+
const PF_KEYS = ["lowerTail", "logP", "ncp"];
|
|
23
|
+
const QF_KEYS = ["lowerTail", "logP", "ncp"];
|
|
24
|
+
// Generated by `node scripts/option-keys.mjs --write` (end)
|
|
19
25
|
const DBL_MIN = 2.2250738585072014e-308;
|
|
20
26
|
const LOG_DBL_MIN = Math.log(DBL_MIN);
|
|
21
27
|
/**
|
|
@@ -310,6 +316,7 @@ export function qf1(p, m, n, lowerTail, logP) {
|
|
|
310
316
|
* @category Distributions
|
|
311
317
|
*/
|
|
312
318
|
export function df(x, df1, df2, options = {}) {
|
|
319
|
+
checkOptions(options, DF_KEYS, "df"); // generated: option-keys.mjs
|
|
313
320
|
const { log = false, ncp } = options;
|
|
314
321
|
if (ncp !== undefined)
|
|
315
322
|
return vectorize(x, (v) => dnf1(v, df1, df2, ncp, log));
|
|
@@ -334,6 +341,7 @@ export function df(x, df1, df2, options = {}) {
|
|
|
334
341
|
* @category Distributions
|
|
335
342
|
*/
|
|
336
343
|
export function pf(q, df1, df2, options = {}) {
|
|
344
|
+
checkOptions(options, PF_KEYS, "pf"); // generated: option-keys.mjs
|
|
337
345
|
const { lowerTail = true, logP = false, ncp } = options;
|
|
338
346
|
if (ncp !== undefined)
|
|
339
347
|
return vectorize(q, (v) => pnf1(v, df1, df2, ncp, lowerTail, logP));
|
|
@@ -359,6 +367,7 @@ export function pf(q, df1, df2, options = {}) {
|
|
|
359
367
|
* @category Distributions
|
|
360
368
|
*/
|
|
361
369
|
export function qf(p, df1, df2, options = {}) {
|
|
370
|
+
checkOptions(options, QF_KEYS, "qf"); // generated: option-keys.mjs
|
|
362
371
|
const { lowerTail = true, logP = false, ncp } = options;
|
|
363
372
|
if (ncp !== undefined)
|
|
364
373
|
return vectorize(p, (v) => qnf1(v, df1, df2, ncp, lowerTail, logP));
|
|
@@ -18,6 +18,11 @@ import { dpoisRaw } from "../special/loader.js";
|
|
|
18
18
|
import { ddAdd, ddDivNum, ddLog, ddMulNum, ddSub } from "../special/dd.js";
|
|
19
19
|
import { ddExp, log1mExp, logRatioDD } from "../internal/ddexp.js";
|
|
20
20
|
import { qnorm } from "./normal.js";
|
|
21
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
22
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
23
|
+
const DGAMMA_KEYS = ["rate", "scale", "log"];
|
|
24
|
+
const PGAMMA_KEYS = ["rate", "scale", "lowerTail", "logP"];
|
|
25
|
+
const QGAMMA_KEYS = ["rate", "scale", "lowerTail", "logP"];
|
|
21
26
|
/** Determine scale from rate / scale (as in R, giving both is an error unless scale = 1/rate; also used by rgamma) */
|
|
22
27
|
export function gammaScale(params) {
|
|
23
28
|
const { rate, scale } = params;
|
|
@@ -294,6 +299,7 @@ export function qgamma1(p, shape, scale, lowerTail, logP) {
|
|
|
294
299
|
* @category Distributions
|
|
295
300
|
*/
|
|
296
301
|
export function dgamma(x, shape, options = {}) {
|
|
302
|
+
checkOptions(options, DGAMMA_KEYS, "dgamma"); // generated: option-keys.mjs
|
|
297
303
|
const scale = gammaScale(options);
|
|
298
304
|
const log = options.log ?? false;
|
|
299
305
|
return vectorize(x, (v) => dgamma1(v, shape, scale, log));
|
|
@@ -318,6 +324,7 @@ export function dgamma(x, shape, options = {}) {
|
|
|
318
324
|
* @category Distributions
|
|
319
325
|
*/
|
|
320
326
|
export function pgamma(q, shape, options = {}) {
|
|
327
|
+
checkOptions(options, PGAMMA_KEYS, "pgamma"); // generated: option-keys.mjs
|
|
321
328
|
const scale = gammaScale(options);
|
|
322
329
|
const { lowerTail = true, logP = false } = options;
|
|
323
330
|
return vectorize(q, (v) => pgamma1(v, shape, scale, lowerTail, logP));
|
|
@@ -341,6 +348,7 @@ export function pgamma(q, shape, options = {}) {
|
|
|
341
348
|
* @category Distributions
|
|
342
349
|
*/
|
|
343
350
|
export function qgamma(p, shape, options = {}) {
|
|
351
|
+
checkOptions(options, QGAMMA_KEYS, "qgamma"); // generated: option-keys.mjs
|
|
344
352
|
const scale = gammaScale(options);
|
|
345
353
|
const { lowerTail = true, logP = false } = options;
|
|
346
354
|
return vectorize(p, (v) => qgamma1(v, shape, scale, lowerTail, logP));
|
|
@@ -11,6 +11,12 @@ import { countAtMost, nonInt } from "../internal/integer.js";
|
|
|
11
11
|
import { FUZZ_LINEAR, FUZZ_LOG } from "../internal/discrete.js";
|
|
12
12
|
import { dbinomRawDD } from "../special/loader.js";
|
|
13
13
|
import { ddAdd, ddDiv, ddLog, ddMul, ddMulNum, twoSum } from "../special/dd.js";
|
|
14
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
15
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
16
|
+
const DGEOM_KEYS = ["log"];
|
|
17
|
+
const PGEOM_KEYS = ["lowerTail", "logP"];
|
|
18
|
+
const QGEOM_KEYS = ["lowerTail", "logP"];
|
|
19
|
+
// Generated by `node scripts/option-keys.mjs --write` (end)
|
|
14
20
|
/** p and q = 1 - p in double-double (the smaller one is the exact base) */
|
|
15
21
|
export function probPair(prob) {
|
|
16
22
|
return prob <= 0.5
|
|
@@ -147,6 +153,7 @@ export function qgeom1(p, prob, lowerTail, logP) {
|
|
|
147
153
|
* @category Distributions
|
|
148
154
|
*/
|
|
149
155
|
export function dgeom(x, prob, options = {}) {
|
|
156
|
+
checkOptions(options, DGEOM_KEYS, "dgeom"); // generated: option-keys.mjs
|
|
150
157
|
const log = options.log ?? false;
|
|
151
158
|
return vectorize(x, (v) => dgeom1(v, prob, log));
|
|
152
159
|
}
|
|
@@ -167,6 +174,7 @@ export function dgeom(x, prob, options = {}) {
|
|
|
167
174
|
* @category Distributions
|
|
168
175
|
*/
|
|
169
176
|
export function pgeom(q, prob, options = {}) {
|
|
177
|
+
checkOptions(options, PGEOM_KEYS, "pgeom"); // generated: option-keys.mjs
|
|
170
178
|
const { lowerTail = true, logP = false } = options;
|
|
171
179
|
return vectorize(q, (v) => pgeom1(v, prob, lowerTail, logP));
|
|
172
180
|
}
|
|
@@ -187,6 +195,7 @@ export function pgeom(q, prob, options = {}) {
|
|
|
187
195
|
* @category Distributions
|
|
188
196
|
*/
|
|
189
197
|
export function qgeom(p, prob, options = {}) {
|
|
198
|
+
checkOptions(options, QGEOM_KEYS, "qgeom"); // generated: option-keys.mjs
|
|
190
199
|
const { lowerTail = true, logP = false } = options;
|
|
191
200
|
return vectorize(p, (v) => qgeom1(v, prob, lowerTail, logP));
|
|
192
201
|
}
|
|
@@ -13,6 +13,11 @@ import { bd0dd, dbinomExponent } from "../special/loader.js";
|
|
|
13
13
|
import { ddAdd, ddDiv, ddLog, ddMul, ddNeg, ddSub, twoProd, twoSum } from "../special/dd.js";
|
|
14
14
|
import { qnorm } from "./normal.js";
|
|
15
15
|
import { dbinom1, pbinom1, qbinom1 } from "./binomial.js";
|
|
16
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
17
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
18
|
+
const DHYPER_KEYS = ["log"];
|
|
19
|
+
const PHYPER_KEYS = ["lowerTail", "logP"];
|
|
20
|
+
const QHYPER_KEYS = ["lowerTail", "logP"];
|
|
16
21
|
/**
|
|
17
22
|
* Binomial probability b(x; x + nmx, p) as an ExpForm (0 <= x, 0 <= nmx, 0 < p < 1).
|
|
18
23
|
* At the ends (x = 0 or nmx = 0), q^n / p^n is represented by the exponent alone.
|
|
@@ -296,6 +301,7 @@ export function qhyper1(p, m, n, k, lowerTail, logP, limitTime = true) {
|
|
|
296
301
|
* @category Distributions
|
|
297
302
|
*/
|
|
298
303
|
export function dhyper(x, m, n, k, options = {}) {
|
|
304
|
+
checkOptions(options, DHYPER_KEYS, "dhyper"); // generated: option-keys.mjs
|
|
299
305
|
const log = options.log ?? false;
|
|
300
306
|
return vectorize(x, (v) => dhyper1(v, m, n, k, log));
|
|
301
307
|
}
|
|
@@ -318,6 +324,7 @@ export function dhyper(x, m, n, k, options = {}) {
|
|
|
318
324
|
* @category Distributions
|
|
319
325
|
*/
|
|
320
326
|
export function phyper(q, m, n, k, options = {}) {
|
|
327
|
+
checkOptions(options, PHYPER_KEYS, "phyper"); // generated: option-keys.mjs
|
|
321
328
|
const { lowerTail = true, logP = false } = options;
|
|
322
329
|
return vectorize(q, (v) => phyper1(v, m, n, k, lowerTail, logP));
|
|
323
330
|
}
|
|
@@ -340,6 +347,7 @@ export function phyper(q, m, n, k, options = {}) {
|
|
|
340
347
|
* @category Distributions
|
|
341
348
|
*/
|
|
342
349
|
export function qhyper(p, m, n, k, options = {}) {
|
|
350
|
+
checkOptions(options, QHYPER_KEYS, "qhyper"); // generated: option-keys.mjs
|
|
343
351
|
const { lowerTail = true, logP = false } = options;
|
|
344
352
|
return vectorize(p, (v) => qhyper1(v, m, n, k, lowerTail, logP));
|
|
345
353
|
}
|
|
@@ -13,6 +13,11 @@ import { ddExp, logRatioDD, standardizeDD } from "../internal/ddexp.js";
|
|
|
13
13
|
import { ddAdd, ddLog, ddMulNum, ddSub } from "../special/dd.js";
|
|
14
14
|
import { lgamma } from "../special/gamma.js";
|
|
15
15
|
import { dgamma1, logTinyGammaQuantile, pgamma1, qgamma1 } from "./gamma.js";
|
|
16
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
17
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
18
|
+
const DINVGAMMA_KEYS = ["beta", "log"];
|
|
19
|
+
const PINVGAMMA_KEYS = ["beta", "lowerTail", "logP"];
|
|
20
|
+
const QINVGAMMA_KEYS = ["beta", "lowerTail", "logP"];
|
|
16
21
|
const valid = (alpha, beta) => alpha > 0 && beta > 0 && Number.isFinite(beta);
|
|
17
22
|
// alpha = Inf is taken as the limit (the distribution concentrates at 0), as extraDistr does
|
|
18
23
|
const MIN_NORMAL = 2 ** -1022;
|
|
@@ -123,6 +128,7 @@ export function qinvgamma1(p, alpha, beta, lowerTail, logP) {
|
|
|
123
128
|
* @category Distributions
|
|
124
129
|
*/
|
|
125
130
|
export function dinvgamma(x, alpha, options = {}) {
|
|
131
|
+
checkOptions(options, DINVGAMMA_KEYS, "dinvgamma"); // generated: option-keys.mjs
|
|
126
132
|
const { beta = 1, log = false } = options;
|
|
127
133
|
return vectorize(x, (v) => dinvgamma1(v, alpha, beta, log));
|
|
128
134
|
}
|
|
@@ -139,6 +145,7 @@ export function dinvgamma(x, alpha, options = {}) {
|
|
|
139
145
|
* @category Distributions
|
|
140
146
|
*/
|
|
141
147
|
export function pinvgamma(q, alpha, options = {}) {
|
|
148
|
+
checkOptions(options, PINVGAMMA_KEYS, "pinvgamma"); // generated: option-keys.mjs
|
|
142
149
|
const { beta = 1, lowerTail = true, logP = false } = options;
|
|
143
150
|
return vectorize(q, (v) => pinvgamma1(v, alpha, beta, lowerTail, logP));
|
|
144
151
|
}
|
|
@@ -155,6 +162,7 @@ export function pinvgamma(q, alpha, options = {}) {
|
|
|
155
162
|
* @category Distributions
|
|
156
163
|
*/
|
|
157
164
|
export function qinvgamma(p, alpha, options = {}) {
|
|
165
|
+
checkOptions(options, QINVGAMMA_KEYS, "qinvgamma"); // generated: option-keys.mjs
|
|
158
166
|
const { beta = 1, lowerTail = true, logP = false } = options;
|
|
159
167
|
return vectorize(p, (v) => qinvgamma1(v, alpha, beta, lowerTail, logP));
|
|
160
168
|
}
|
|
@@ -7,6 +7,12 @@ import { vectorize } from "../internal/vectorize.js";
|
|
|
7
7
|
import { d0, dt0, dt1, quantileBoundaries } from "../internal/dpq.js";
|
|
8
8
|
import { ddExp, log1mExp } from "../internal/ddexp.js";
|
|
9
9
|
import { ddAdd, ddDivNum, ddLog, ddMul, ddSub, twoProd, twoSum } from "../special/dd.js";
|
|
10
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
11
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
12
|
+
const DKUMAR_KEYS = ["log"];
|
|
13
|
+
const PKUMAR_KEYS = ["lowerTail", "logP"];
|
|
14
|
+
const QKUMAR_KEYS = ["lowerTail", "logP"];
|
|
15
|
+
// Generated by `node scripts/option-keys.mjs --write` (end)
|
|
10
16
|
const valid = (a, b) => a > 0 && b > 0 && Number.isFinite(b);
|
|
11
17
|
// a = Inf is taken as the limit (the distribution concentrates at 1), as extraDistr does
|
|
12
18
|
const MIN_NORMAL = 2.2250738585072014e-308;
|
|
@@ -188,6 +194,7 @@ export function qkumar1(p, a, b, lowerTail, logP) {
|
|
|
188
194
|
* @category Distributions
|
|
189
195
|
*/
|
|
190
196
|
export function dkumar(x, a, b, options = {}) {
|
|
197
|
+
checkOptions(options, DKUMAR_KEYS, "dkumar"); // generated: option-keys.mjs
|
|
191
198
|
const { log = false } = options;
|
|
192
199
|
return vectorize(x, (v) => dkumar1(v, a, b, log));
|
|
193
200
|
}
|
|
@@ -203,6 +210,7 @@ export function dkumar(x, a, b, options = {}) {
|
|
|
203
210
|
* @category Distributions
|
|
204
211
|
*/
|
|
205
212
|
export function pkumar(q, a, b, options = {}) {
|
|
213
|
+
checkOptions(options, PKUMAR_KEYS, "pkumar"); // generated: option-keys.mjs
|
|
206
214
|
const { lowerTail = true, logP = false } = options;
|
|
207
215
|
return vectorize(q, (v) => pkumar1(v, a, b, lowerTail, logP));
|
|
208
216
|
}
|
|
@@ -218,6 +226,7 @@ export function pkumar(q, a, b, options = {}) {
|
|
|
218
226
|
* @category Distributions
|
|
219
227
|
*/
|
|
220
228
|
export function qkumar(p, a, b, options = {}) {
|
|
229
|
+
checkOptions(options, QKUMAR_KEYS, "qkumar"); // generated: option-keys.mjs
|
|
221
230
|
const { lowerTail = true, logP = false } = options;
|
|
222
231
|
return vectorize(p, (v) => qkumar1(v, a, b, lowerTail, logP));
|
|
223
232
|
}
|
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
import { vectorize } from "../internal/vectorize.js";
|
|
7
7
|
import { quantileBoundaries, smallerTail } from "../internal/dpq.js";
|
|
8
8
|
import { expNeg, expNegOver, locationScale, standardizeDD } from "../internal/ddexp.js";
|
|
9
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
10
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
11
|
+
const DLAPLACE_KEYS = ["mu", "sigma", "log"];
|
|
12
|
+
const PLAPLACE_KEYS = ["mu", "sigma", "lowerTail", "logP"];
|
|
13
|
+
const QLAPLACE_KEYS = ["mu", "sigma", "lowerTail", "logP"];
|
|
14
|
+
// Generated by `node scripts/option-keys.mjs --write` (end)
|
|
9
15
|
const MIN_NORMAL = 2 ** -1022;
|
|
10
16
|
const valid = (mu, sigma) => !Number.isNaN(mu) && sigma > 0;
|
|
11
17
|
// an infinite mu is taken as the limit (the distribution moves out to that infinity), as extraDistr does. sigma = Inf is
|
|
@@ -86,6 +92,7 @@ export function qlaplace1(p, mu, sigma, lowerTail, logP) {
|
|
|
86
92
|
* @category Distributions
|
|
87
93
|
*/
|
|
88
94
|
export function dlaplace(x, options = {}) {
|
|
95
|
+
checkOptions(options, DLAPLACE_KEYS, "dlaplace"); // generated: option-keys.mjs
|
|
89
96
|
const { mu = 0, sigma = 1, log = false } = options;
|
|
90
97
|
return vectorize(x, (v) => dlaplace1(v, mu, sigma, log));
|
|
91
98
|
}
|
|
@@ -101,6 +108,7 @@ export function dlaplace(x, options = {}) {
|
|
|
101
108
|
* @category Distributions
|
|
102
109
|
*/
|
|
103
110
|
export function plaplace(q, options = {}) {
|
|
111
|
+
checkOptions(options, PLAPLACE_KEYS, "plaplace"); // generated: option-keys.mjs
|
|
104
112
|
const { mu = 0, sigma = 1, lowerTail = true, logP = false } = options;
|
|
105
113
|
return vectorize(q, (v) => plaplace1(v, mu, sigma, lowerTail, logP));
|
|
106
114
|
}
|
|
@@ -116,6 +124,7 @@ export function plaplace(q, options = {}) {
|
|
|
116
124
|
* @category Distributions
|
|
117
125
|
*/
|
|
118
126
|
export function qlaplace(p, options = {}) {
|
|
127
|
+
checkOptions(options, QLAPLACE_KEYS, "qlaplace"); // generated: option-keys.mjs
|
|
119
128
|
const { mu = 0, sigma = 1, lowerTail = true, logP = false } = options;
|
|
120
129
|
return vectorize(p, (v) => qlaplace1(v, mu, sigma, lowerTail, logP));
|
|
121
130
|
}
|
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
import { vectorize } from "../internal/vectorize.js";
|
|
8
8
|
import { quantileBoundaries } from "../internal/dpq.js";
|
|
9
9
|
import { expNeg, expNegOver, locationScale, log1mExp, standardizeDD } from "../internal/ddexp.js";
|
|
10
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
11
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
12
|
+
const DLOGIS_KEYS = ["location", "scale", "log"];
|
|
13
|
+
const PLOGIS_KEYS = ["location", "scale", "lowerTail", "logP"];
|
|
14
|
+
const QLOGIS_KEYS = ["location", "scale", "lowerTail", "logP"];
|
|
15
|
+
// Generated by `node scripts/option-keys.mjs --write` (end)
|
|
10
16
|
const MIN_NORMAL = 2 ** -1022;
|
|
11
17
|
export function dlogis1(x, location, scale, log) {
|
|
12
18
|
if (Number.isNaN(x) || Number.isNaN(location) || Number.isNaN(scale))
|
|
@@ -84,6 +90,7 @@ export function qlogis1(p, location, scale, lowerTail, logP) {
|
|
|
84
90
|
* @category Distributions
|
|
85
91
|
*/
|
|
86
92
|
export function dlogis(x, options = {}) {
|
|
93
|
+
checkOptions(options, DLOGIS_KEYS, "dlogis"); // generated: option-keys.mjs
|
|
87
94
|
const { location = 0, scale = 1, log = false } = options;
|
|
88
95
|
return vectorize(x, (v) => dlogis1(v, location, scale, log));
|
|
89
96
|
}
|
|
@@ -103,6 +110,7 @@ export function dlogis(x, options = {}) {
|
|
|
103
110
|
* @category Distributions
|
|
104
111
|
*/
|
|
105
112
|
export function plogis(q, options = {}) {
|
|
113
|
+
checkOptions(options, PLOGIS_KEYS, "plogis"); // generated: option-keys.mjs
|
|
106
114
|
const { location = 0, scale = 1, lowerTail = true, logP = false } = options;
|
|
107
115
|
return vectorize(q, (v) => plogis1(v, location, scale, lowerTail, logP));
|
|
108
116
|
}
|
|
@@ -122,6 +130,7 @@ export function plogis(q, options = {}) {
|
|
|
122
130
|
* @category Distributions
|
|
123
131
|
*/
|
|
124
132
|
export function qlogis(p, options = {}) {
|
|
133
|
+
checkOptions(options, QLOGIS_KEYS, "qlogis"); // generated: option-keys.mjs
|
|
125
134
|
const { location = 0, scale = 1, lowerTail = true, logP = false } = options;
|
|
126
135
|
return vectorize(p, (v) => qlogis1(v, location, scale, lowerTail, logP));
|
|
127
136
|
}
|
|
@@ -10,6 +10,11 @@ import { ddExp, expNeg, mulDD } from "../internal/ddexp.js";
|
|
|
10
10
|
import { ddAdd, ddDiv, ddLog, ddMul, ddSub, twoSum } from "../special/dd.js";
|
|
11
11
|
import { erfcxNonNegative } from "../special/erf.js";
|
|
12
12
|
import { pnorm, qnorm } from "./normal.js";
|
|
13
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
14
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
15
|
+
const DLNORM_KEYS = ["meanlog", "sdlog", "log"];
|
|
16
|
+
const PLNORM_KEYS = ["meanlog", "sdlog", "lowerTail", "logP"];
|
|
17
|
+
const QLNORM_KEYS = ["meanlog", "sdlog", "lowerTail", "logP"];
|
|
13
18
|
const LN_SQRT_2PI = 0.918938533204672741780329736406;
|
|
14
19
|
const INV_SQRT_2PI = 0.398942280401432677939946059934;
|
|
15
20
|
const MIN_NORMAL = 2 ** -1022;
|
|
@@ -180,6 +185,7 @@ export function qlnorm1(p, meanlog, sdlog, lowerTail, logP) {
|
|
|
180
185
|
* @category Distributions
|
|
181
186
|
*/
|
|
182
187
|
export function dlnorm(x, options = {}) {
|
|
188
|
+
checkOptions(options, DLNORM_KEYS, "dlnorm"); // generated: option-keys.mjs
|
|
183
189
|
const { meanlog = 0, sdlog = 1, log = false } = options;
|
|
184
190
|
return vectorize(x, (v) => dlnorm1(v, meanlog, sdlog, log));
|
|
185
191
|
}
|
|
@@ -199,6 +205,7 @@ export function dlnorm(x, options = {}) {
|
|
|
199
205
|
* @category Distributions
|
|
200
206
|
*/
|
|
201
207
|
export function plnorm(q, options = {}) {
|
|
208
|
+
checkOptions(options, PLNORM_KEYS, "plnorm"); // generated: option-keys.mjs
|
|
202
209
|
const { meanlog = 0, sdlog = 1, lowerTail = true, logP = false } = options;
|
|
203
210
|
return vectorize(q, (v) => plnorm1(v, meanlog, sdlog, lowerTail, logP));
|
|
204
211
|
}
|
|
@@ -218,6 +225,7 @@ export function plnorm(q, options = {}) {
|
|
|
218
225
|
* @category Distributions
|
|
219
226
|
*/
|
|
220
227
|
export function qlnorm(p, options = {}) {
|
|
228
|
+
checkOptions(options, QLNORM_KEYS, "qlnorm"); // generated: option-keys.mjs
|
|
221
229
|
const { meanlog = 0, sdlog = 1, lowerTail = true, logP = false } = options;
|
|
222
230
|
return vectorize(p, (v) => qlnorm1(v, meanlog, sdlog, lowerTail, logP));
|
|
223
231
|
}
|
|
@@ -10,6 +10,9 @@ import { lchoose } from "../special/choose.js";
|
|
|
10
10
|
import { dbinomRawDD } from "../special/loader.js";
|
|
11
11
|
import { ddAdd, ddDiv } from "../special/dd.js";
|
|
12
12
|
import { ldexp } from "../internal/summary.js";
|
|
13
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
14
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
15
|
+
const DMULTINOM_KEYS = ["size", "log"];
|
|
13
16
|
/**
|
|
14
17
|
* Probability function of the multinomial distribution. Equivalent to R's
|
|
15
18
|
* `dmultinom(x, size = NULL, prob, log = FALSE)`.
|
|
@@ -29,6 +32,7 @@ import { ldexp } from "../internal/summary.js";
|
|
|
29
32
|
* @category Distributions
|
|
30
33
|
*/
|
|
31
34
|
export function dmultinom(x, prob, options = {}) {
|
|
35
|
+
checkOptions(options, DMULTINOM_KEYS, "dmultinom"); // generated: option-keys.mjs
|
|
32
36
|
const log = options.log ?? false;
|
|
33
37
|
const K = prob.length;
|
|
34
38
|
if (x.length !== K)
|
|
@@ -20,6 +20,11 @@ import { qnorm } from "./normal.js";
|
|
|
20
20
|
import { qgamma1 } from "./gamma.js";
|
|
21
21
|
import { ppois1, qpois1 } from "./poisson.js";
|
|
22
22
|
import { probPair } from "./geometric.js";
|
|
23
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
24
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
25
|
+
const DNBINOM_KEYS = ["prob", "mu", "log"];
|
|
26
|
+
const PNBINOM_KEYS = ["prob", "mu", "lowerTail", "logP"];
|
|
27
|
+
const QNBINOM_KEYS = ["prob", "mu", "lowerTail", "logP"];
|
|
23
28
|
function fromMu(size, mu) {
|
|
24
29
|
const s = twoSum(size, mu);
|
|
25
30
|
if (Number.isFinite(s[0]))
|
|
@@ -384,6 +389,7 @@ function which(options) {
|
|
|
384
389
|
* @category Distributions
|
|
385
390
|
*/
|
|
386
391
|
export function dnbinom(x, size, options) {
|
|
392
|
+
checkOptions(options, DNBINOM_KEYS, "dnbinom"); // generated: option-keys.mjs
|
|
387
393
|
const log = options.log ?? false;
|
|
388
394
|
const w = which(options);
|
|
389
395
|
return w.kind === "prob"
|
|
@@ -411,6 +417,7 @@ export function dnbinom(x, size, options) {
|
|
|
411
417
|
* @category Distributions
|
|
412
418
|
*/
|
|
413
419
|
export function pnbinom(q, size, options) {
|
|
420
|
+
checkOptions(options, PNBINOM_KEYS, "pnbinom"); // generated: option-keys.mjs
|
|
414
421
|
const { lowerTail = true, logP = false } = options;
|
|
415
422
|
const w = which(options);
|
|
416
423
|
return w.kind === "prob"
|
|
@@ -438,6 +445,7 @@ export function pnbinom(q, size, options) {
|
|
|
438
445
|
* @category Distributions
|
|
439
446
|
*/
|
|
440
447
|
export function qnbinom(p, size, options) {
|
|
448
|
+
checkOptions(options, QNBINOM_KEYS, "qnbinom"); // generated: option-keys.mjs
|
|
441
449
|
const { lowerTail = true, logP = false } = options;
|
|
442
450
|
const w = which(options);
|
|
443
451
|
return w.kind === "prob"
|
|
@@ -7,6 +7,11 @@ import { erf, erfcxNonNegative } from "../special/erf.js";
|
|
|
7
7
|
import { ndtri, ndtriExp } from "../special/ndtri.js";
|
|
8
8
|
import { vectorize } from "../internal/vectorize.js";
|
|
9
9
|
import { affine, standardizeValue } from "../internal/ddexp.js";
|
|
10
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
11
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
12
|
+
const DNORM_KEYS = ["mean", "sd", "log"];
|
|
13
|
+
const PNORM_KEYS = ["mean", "sd", "lowerTail", "logP"];
|
|
14
|
+
const QNORM_KEYS = ["mean", "sd", "lowerTail", "logP"];
|
|
10
15
|
const SQRT1_2 = Math.SQRT1_2;
|
|
11
16
|
/**
|
|
12
17
|
* exp(-a^2 / 2) (a >= 0) multiplied by scale.
|
|
@@ -176,6 +181,7 @@ function tinySdDensity(a, sd) {
|
|
|
176
181
|
* @category Distributions
|
|
177
182
|
*/
|
|
178
183
|
export function dnorm(x, options = {}) {
|
|
184
|
+
checkOptions(options, DNORM_KEYS, "dnorm"); // generated: option-keys.mjs
|
|
179
185
|
const { mean = 0, sd = 1, log = false } = options;
|
|
180
186
|
return vectorize(x, (v) => dnorm1(v, mean, sd, log));
|
|
181
187
|
}
|
|
@@ -198,6 +204,7 @@ export function dnorm(x, options = {}) {
|
|
|
198
204
|
* @category Distributions
|
|
199
205
|
*/
|
|
200
206
|
export function pnorm(q, options = {}) {
|
|
207
|
+
checkOptions(options, PNORM_KEYS, "pnorm"); // generated: option-keys.mjs
|
|
201
208
|
const { mean = 0, sd = 1, lowerTail = true, logP = false } = options;
|
|
202
209
|
return vectorize(q, (v) => pnorm1(v, mean, sd, lowerTail, logP));
|
|
203
210
|
}
|
|
@@ -218,6 +225,7 @@ export function pnorm(q, options = {}) {
|
|
|
218
225
|
* @category Distributions
|
|
219
226
|
*/
|
|
220
227
|
export function qnorm(p, options = {}) {
|
|
228
|
+
checkOptions(options, QNORM_KEYS, "qnorm"); // generated: option-keys.mjs
|
|
221
229
|
const { mean = 0, sd = 1, lowerTail = true, logP = false } = options;
|
|
222
230
|
return vectorize(p, (v) => qnorm1(v, mean, sd, lowerTail, logP));
|
|
223
231
|
}
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
import { vectorize } from "../internal/vectorize.js";
|
|
9
9
|
import { d0, dt0, dt1, quantileBoundaries } from "../internal/dpq.js";
|
|
10
10
|
import { log1mExp, logRatioDD, standardizeDD } from "../internal/ddexp.js";
|
|
11
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
12
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
13
|
+
const DPARETO_KEYS = ["a", "b", "log"];
|
|
14
|
+
const PPARETO_KEYS = ["a", "b", "lowerTail", "logP"];
|
|
15
|
+
const QPARETO_KEYS = ["a", "b", "lowerTail", "logP"];
|
|
11
16
|
const valid = (a, b) => a > 0 && b > 0 && Number.isFinite(b);
|
|
12
17
|
// a = Inf is taken as the limit (the distribution concentrates at b), as extraDistr does
|
|
13
18
|
const MIN_NORMAL = 2 ** -1022;
|
|
@@ -126,6 +131,7 @@ export function qpareto1(p, a, b, lowerTail, logP) {
|
|
|
126
131
|
* @category Distributions
|
|
127
132
|
*/
|
|
128
133
|
export function dpareto(x, options = {}) {
|
|
134
|
+
checkOptions(options, DPARETO_KEYS, "dpareto"); // generated: option-keys.mjs
|
|
129
135
|
const { a = 1, b = 1, log = false } = options;
|
|
130
136
|
return vectorize(x, (v) => dpareto1(v, a, b, log));
|
|
131
137
|
}
|
|
@@ -141,6 +147,7 @@ export function dpareto(x, options = {}) {
|
|
|
141
147
|
* @category Distributions
|
|
142
148
|
*/
|
|
143
149
|
export function ppareto(q, options = {}) {
|
|
150
|
+
checkOptions(options, PPARETO_KEYS, "ppareto"); // generated: option-keys.mjs
|
|
144
151
|
const { a = 1, b = 1, lowerTail = true, logP = false } = options;
|
|
145
152
|
return vectorize(q, (v) => ppareto1(v, a, b, lowerTail, logP));
|
|
146
153
|
}
|
|
@@ -156,6 +163,7 @@ export function ppareto(q, options = {}) {
|
|
|
156
163
|
* @category Distributions
|
|
157
164
|
*/
|
|
158
165
|
export function qpareto(p, options = {}) {
|
|
166
|
+
checkOptions(options, QPARETO_KEYS, "qpareto"); // generated: option-keys.mjs
|
|
159
167
|
const { a = 1, b = 1, lowerTail = true, logP = false } = options;
|
|
160
168
|
return vectorize(p, (v) => qpareto1(v, a, b, lowerTail, logP));
|
|
161
169
|
}
|
|
@@ -10,6 +10,12 @@ import { dpoisRaw } from "../special/loader.js";
|
|
|
10
10
|
import { logAddExp, logSubExp } from "../internal/ddexp.js";
|
|
11
11
|
import { qnorm } from "./normal.js";
|
|
12
12
|
import { countAtMost, nonInt } from "../internal/integer.js";
|
|
13
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
14
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
15
|
+
const DPOIS_KEYS = ["log"];
|
|
16
|
+
const PPOIS_KEYS = ["lowerTail", "logP"];
|
|
17
|
+
const QPOIS_KEYS = ["lowerTail", "logP"];
|
|
18
|
+
// Generated by `node scripts/option-keys.mjs --write` (end)
|
|
13
19
|
/** Whether x is not an integer (relative tolerance 1e-9 as in R; see src/internal/integer.ts) */
|
|
14
20
|
export const nonInteger = nonInt;
|
|
15
21
|
export function dpois1(x, lambda, log) {
|
|
@@ -102,6 +108,7 @@ export function qpois1(p, lambda, lowerTail, logP) {
|
|
|
102
108
|
* @category Distributions
|
|
103
109
|
*/
|
|
104
110
|
export function dpois(x, lambda, options = {}) {
|
|
111
|
+
checkOptions(options, DPOIS_KEYS, "dpois"); // generated: option-keys.mjs
|
|
105
112
|
const log = options.log ?? false;
|
|
106
113
|
return vectorize(x, (v) => dpois1(v, lambda, log));
|
|
107
114
|
}
|
|
@@ -122,6 +129,7 @@ export function dpois(x, lambda, options = {}) {
|
|
|
122
129
|
* @category Distributions
|
|
123
130
|
*/
|
|
124
131
|
export function ppois(q, lambda, options = {}) {
|
|
132
|
+
checkOptions(options, PPOIS_KEYS, "ppois"); // generated: option-keys.mjs
|
|
125
133
|
const { lowerTail = true, logP = false } = options;
|
|
126
134
|
return vectorize(q, (v) => ppois1(v, lambda, lowerTail, logP));
|
|
127
135
|
}
|
|
@@ -142,6 +150,7 @@ export function ppois(q, lambda, options = {}) {
|
|
|
142
150
|
* @category Distributions
|
|
143
151
|
*/
|
|
144
152
|
export function qpois(p, lambda, options = {}) {
|
|
153
|
+
checkOptions(options, QPOIS_KEYS, "qpois"); // generated: option-keys.mjs
|
|
145
154
|
const { lowerTail = true, logP = false } = options;
|
|
146
155
|
return vectorize(p, (v) => qpois1(v, lambda, lowerTail, logP));
|
|
147
156
|
}
|
|
@@ -10,6 +10,12 @@ import { d0, dt0, dt1, quantileBoundaries } from "../internal/dpq.js";
|
|
|
10
10
|
import { discreteQuantile } from "../internal/discrete.js";
|
|
11
11
|
import { countAtMost, nonInt, roundHalfEven } from "../internal/integer.js";
|
|
12
12
|
import { qnorm } from "./normal.js";
|
|
13
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
14
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
15
|
+
const DSIGNRANK_KEYS = ["log"];
|
|
16
|
+
const PSIGNRANK_KEYS = ["lowerTail", "logP"];
|
|
17
|
+
const QSIGNRANK_KEYS = ["lowerTail", "logP"];
|
|
18
|
+
// Generated by `node scripts/option-keys.mjs --write` (end)
|
|
13
19
|
/** Threshold at which counts are multiplied by 2^-SCALE_STEP to keep them from growing too large */
|
|
14
20
|
const SCALE_LIMIT = 2 ** 900;
|
|
15
21
|
const SCALE_STEP = -900;
|
|
@@ -247,6 +253,7 @@ export function qsignrank1(p, n, lowerTail, logP) {
|
|
|
247
253
|
* @category Distributions
|
|
248
254
|
*/
|
|
249
255
|
export function dsignrank(x, n, options = {}) {
|
|
256
|
+
checkOptions(options, DSIGNRANK_KEYS, "dsignrank"); // generated: option-keys.mjs
|
|
250
257
|
const log = options.log ?? false;
|
|
251
258
|
return vectorize(x, (v) => dsignrank1(v, n, log));
|
|
252
259
|
}
|
|
@@ -269,6 +276,7 @@ export function dsignrank(x, n, options = {}) {
|
|
|
269
276
|
* @category Distributions
|
|
270
277
|
*/
|
|
271
278
|
export function psignrank(q, n, options = {}) {
|
|
279
|
+
checkOptions(options, PSIGNRANK_KEYS, "psignrank"); // generated: option-keys.mjs
|
|
272
280
|
const { lowerTail = true, logP = false } = options;
|
|
273
281
|
return vectorize(q, (v) => psignrank1(v, n, lowerTail, logP));
|
|
274
282
|
}
|
|
@@ -291,6 +299,7 @@ export function psignrank(q, n, options = {}) {
|
|
|
291
299
|
* @category Distributions
|
|
292
300
|
*/
|
|
293
301
|
export function qsignrank(p, n, options = {}) {
|
|
302
|
+
checkOptions(options, QSIGNRANK_KEYS, "qsignrank"); // generated: option-keys.mjs
|
|
294
303
|
const { lowerTail = true, logP = false } = options;
|
|
295
304
|
return vectorize(p, (v) => qsignrank1(v, n, lowerTail, logP));
|
|
296
305
|
}
|
|
@@ -28,7 +28,8 @@ export type DistName = "norm" | "lnorm" | "unif" | "exp" | "gamma" | "chisq" | "
|
|
|
28
28
|
/**
|
|
29
29
|
* Mean, variance, standard deviation, median, mode, skewness and excess kurtosis of a distribution, given by the
|
|
30
30
|
* name of its d/p/q/r functions and their parameters (with the same names and defaults; `gamma` takes `rate` or
|
|
31
|
-
* `scale`, `nbinom` takes `prob` or `mu`). Invalid parameters give NaN throughout.
|
|
31
|
+
* `scale`, `nbinom` takes `prob` or `mu`). Invalid parameters give NaN throughout. The distributions are the central
|
|
32
|
+
* ones: `ncp` of `chisq`, `beta`, `t` and `f` is not taken (an unknown key, a RangeError).
|
|
32
33
|
* Not an R function. R has no function for these summaries; the R references are closed forms checked against
|
|
33
34
|
* numerical moments.
|
|
34
35
|
*
|
|
@@ -28,6 +28,33 @@ import { qtriang } from "./triangular.js";
|
|
|
28
28
|
import { ldexp } from "../internal/summary.js";
|
|
29
29
|
import { midpoint } from "../internal/extremes.js";
|
|
30
30
|
import { splitDouble } from "../linalg/dot.js";
|
|
31
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
32
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
33
|
+
const DIST_SUMMARY_KEYS = {
|
|
34
|
+
arcsine: ["a", "b"],
|
|
35
|
+
beta: ["shape1", "shape2"],
|
|
36
|
+
binom: ["size", "prob"],
|
|
37
|
+
cauchy: ["location", "scale"],
|
|
38
|
+
chisq: ["df"],
|
|
39
|
+
exp: ["rate"],
|
|
40
|
+
f: ["df1", "df2"],
|
|
41
|
+
gamma: ["shape", "rate", "scale"],
|
|
42
|
+
geom: ["prob"],
|
|
43
|
+
hyper: ["m", "n", "k"],
|
|
44
|
+
invgamma: ["alpha", "beta"],
|
|
45
|
+
kumar: ["a", "b"],
|
|
46
|
+
laplace: ["mu", "sigma"],
|
|
47
|
+
lnorm: ["meanlog", "sdlog"],
|
|
48
|
+
logis: ["location", "scale"],
|
|
49
|
+
nbinom: ["size", "prob", "mu"],
|
|
50
|
+
norm: ["mean", "sd"],
|
|
51
|
+
pareto: ["a", "b"],
|
|
52
|
+
pois: ["lambda"],
|
|
53
|
+
t: ["df"],
|
|
54
|
+
triang: ["a", "b", "c"],
|
|
55
|
+
unif: ["min", "max"],
|
|
56
|
+
weibull: ["shape", "scale"],
|
|
57
|
+
};
|
|
31
58
|
const NAN = { mean: NaN, variance: NaN, sd: NaN, median: NaN, mode: NaN, skewness: NaN, kurtosis: NaN };
|
|
32
59
|
/** A point mass at 0: no skewness or kurtosis */
|
|
33
60
|
const POINT_AT_0 = { mean: 0, variance: 0, sd: 0, median: 0, mode: 0, skewness: NaN, kurtosis: NaN };
|
|
@@ -194,7 +221,8 @@ function betaVariance(a, b, s) {
|
|
|
194
221
|
/**
|
|
195
222
|
* Mean, variance, standard deviation, median, mode, skewness and excess kurtosis of a distribution, given by the
|
|
196
223
|
* name of its d/p/q/r functions and their parameters (with the same names and defaults; `gamma` takes `rate` or
|
|
197
|
-
* `scale`, `nbinom` takes `prob` or `mu`). Invalid parameters give NaN throughout.
|
|
224
|
+
* `scale`, `nbinom` takes `prob` or `mu`). Invalid parameters give NaN throughout. The distributions are the central
|
|
225
|
+
* ones: `ncp` of `chisq`, `beta`, `t` and `f` is not taken (an unknown key, a RangeError).
|
|
198
226
|
* Not an R function. R has no function for these summaries; the R references are closed forms checked against
|
|
199
227
|
* numerical moments.
|
|
200
228
|
*
|
|
@@ -207,6 +235,8 @@ function betaVariance(a, b, s) {
|
|
|
207
235
|
* @category Distributions
|
|
208
236
|
*/
|
|
209
237
|
export function distSummary(distribution, params = {}) {
|
|
238
|
+
if (Object.hasOwn(DIST_SUMMARY_KEYS, distribution))
|
|
239
|
+
checkOptions(params, DIST_SUMMARY_KEYS[distribution] ?? [], "distSummary"); // generated: option-keys.mjs
|
|
210
240
|
const P = params;
|
|
211
241
|
switch (distribution) {
|
|
212
242
|
case "norm": {
|
package/dist/distributions/t.js
CHANGED
|
@@ -16,6 +16,12 @@ import { betaIncBothDD, betaIncDD } from "../special/incbet.js";
|
|
|
16
16
|
import { bd0, bd0dd, stirlerr } from "../special/loader.js";
|
|
17
17
|
import { dnorm, pnorm, qnorm } from "./normal.js";
|
|
18
18
|
import { HUGE_DF, dnt1, hugeDfRatio, hugeDfTail, hugeDfTailLog, hugeDfTailQuantile, pnt1, qnt1 } from "./nt.js";
|
|
19
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
20
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
21
|
+
const DT_KEYS = ["log", "ncp"];
|
|
22
|
+
const PT_KEYS = ["lowerTail", "logP", "ncp"];
|
|
23
|
+
const QT_KEYS = ["lowerTail", "logP", "ncp"];
|
|
24
|
+
// Generated by `node scripts/option-keys.mjs --write` (end)
|
|
19
25
|
const LN_SQRT_2PI = 0.918938533204672741780329736406;
|
|
20
26
|
/** -log(sqrt(2 pi)) in double-double (computed with Rmpfr) */
|
|
21
27
|
const LN_SQRT_2PI_DD_NEG = [-0.91893853320467278, 3.8782941580672414e-17];
|
|
@@ -288,6 +294,7 @@ export function qt1(p, df, lowerTail, logP) {
|
|
|
288
294
|
* @category Distributions
|
|
289
295
|
*/
|
|
290
296
|
export function dt(x, df, options = {}) {
|
|
297
|
+
checkOptions(options, DT_KEYS, "dt"); // generated: option-keys.mjs
|
|
291
298
|
const { log = false, ncp } = options;
|
|
292
299
|
if (ncp !== undefined && ncp !== 0)
|
|
293
300
|
return vectorize(x, (v) => dnt1(v, df, ncp, log));
|
|
@@ -312,6 +319,7 @@ export function dt(x, df, options = {}) {
|
|
|
312
319
|
* @category Distributions
|
|
313
320
|
*/
|
|
314
321
|
export function pt(q, df, options = {}) {
|
|
322
|
+
checkOptions(options, PT_KEYS, "pt"); // generated: option-keys.mjs
|
|
315
323
|
const { lowerTail = true, logP = false, ncp } = options;
|
|
316
324
|
if (ncp !== undefined && ncp !== 0)
|
|
317
325
|
return vectorize(q, (v) => pnt1(v, df, ncp, lowerTail, logP));
|
|
@@ -336,6 +344,7 @@ export function pt(q, df, options = {}) {
|
|
|
336
344
|
* @category Distributions
|
|
337
345
|
*/
|
|
338
346
|
export function qt(p, df, options = {}) {
|
|
347
|
+
checkOptions(options, QT_KEYS, "qt"); // generated: option-keys.mjs
|
|
339
348
|
const { lowerTail = true, logP = false, ncp } = options;
|
|
340
349
|
if (ncp !== undefined && ncp !== 0)
|
|
341
350
|
return vectorize(p, (v) => qnt1(v, df, ncp, lowerTail, logP));
|