@numero-uno-jpn/rstats 0.11.0 → 0.12.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 +57 -0
- package/README.ja.md +44 -13
- package/README.md +43 -11
- package/dist/chunks/{chunk-VJ4BDBMU.js → chunk-3VMBBQLV.js} +2 -2
- package/dist/chunks/chunk-4OKAZJJG.js +3 -0
- package/dist/chunks/{chunk-EZAFN5CD.js → chunk-6BH65HGN.js} +1 -1
- package/dist/chunks/chunk-ATC4F4BX.js +2 -0
- package/dist/chunks/{chunk-JWBO5WVN.js → chunk-EDH53DXN.js} +2 -2
- package/dist/chunks/{chunk-Y5CNQ266.js → chunk-EZ2KD5NA.js} +2 -2
- package/dist/chunks/{chunk-Y5PYRAYP.js → chunk-GSPOO2G3.js} +2 -2
- package/dist/chunks/{chunk-F5EDJFEO.js → chunk-K7AZ65H7.js} +2 -2
- package/dist/chunks/{chunk-YSWGDOWK.js → chunk-LEIH4U5X.js} +2 -2
- package/dist/chunks/{chunk-EZWBRCJL.js → chunk-OX3SBG5X.js} +1 -1
- package/dist/chunks/chunk-SGZQDJRR.js +2 -0
- package/dist/chunks/{chunk-C5XTWMGB.js → chunk-UH2N3ZQW.js} +1 -1
- package/dist/chunks/chunk-UV2MZYDQ.js +2 -0
- package/dist/chunks/{chunk-TOGXTCZO.js → chunk-VQHEOBTM.js} +2 -2
- package/dist/chunks/chunk-WJQZZYOI.js +2 -0
- package/dist/chunks/chunk-WKEFHOFR.js +2 -0
- package/dist/chunks/{chunk-CGBNKHNZ.js → chunk-WXC25OPJ.js} +2 -2
- package/dist/chunks/{chunk-5WDJPHYY.js → chunk-XJQKSR52.js} +1 -1
- package/dist/data/grouping.d.ts +39 -15
- package/dist/data/grouping.js +21 -22
- 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/mixed.d.ts +1 -0
- package/dist/entries/mixed.js +2 -0
- 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/testFormula.js +6 -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/mixed.js +3 -0
- 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 +13 -3
- package/dist/models/aovStrata.js +5 -1
- 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/formula.d.ts +26 -1
- package/dist/models/formula.js +125 -9
- 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 +77 -19
- package/dist/models/lm.js +22 -4
- package/dist/models/lmer.d.ts +162 -0
- package/dist/models/lmer.js +457 -0
- package/dist/models/mauchly.d.ts +20 -5
- package/dist/models/mauchly.js +7 -3
- package/dist/models/mixedDeviance.d.ts +44 -0
- package/dist/models/mixedDeviance.js +872 -0
- package/dist/models/mixedStructure.d.ts +82 -0
- package/dist/models/mixedStructure.js +309 -0
- package/dist/models/modelFrame.d.ts +17 -2
- package/dist/models/modelFrame.js +36 -21
- package/dist/models/modelMatrix.d.ts +33 -8
- package/dist/models/modelMatrix.js +21 -5
- 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 +14 -14
- 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 +12 -12
- package/llms.txt +13 -3
- package/package.json +5 -1
- package/dist/chunks/chunk-7GQMKH3Z.js +0 -2
- package/dist/chunks/chunk-AHHS6AC4.js +0 -3
- package/dist/chunks/chunk-ALM3VHFP.js +0 -2
|
@@ -129,6 +129,14 @@ export function qlnorm1(p, meanlog, sdlog, lowerTail, logP) {
|
|
|
129
129
|
* @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
130
130
|
* @param options - `meanlog` and `sdlog` (see {@link LognormalParams}) and `log` (see {@link DensityOptions}).
|
|
131
131
|
* @returns The density (or log density).
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* dlnorm(1); // 0.3989422804014327
|
|
136
|
+
* dlnorm(2, { meanlog: 0.5, sdlog: 0.8 }); // 0.24217677488483338
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* @category Distributions
|
|
132
140
|
*/
|
|
133
141
|
export function dlnorm(x, options = {}) {
|
|
134
142
|
const { meanlog = 0, sdlog = 1, log = false } = options;
|
|
@@ -140,6 +148,14 @@ export function dlnorm(x, options = {}) {
|
|
|
140
148
|
* @param q - Quantile(s): a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
141
149
|
* @param options - `meanlog` and `sdlog` (see {@link LognormalParams}), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
142
150
|
* @returns The probability (or log probability).
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* plnorm(2); // 0.7558914042144173
|
|
155
|
+
* plnorm(2, { meanlog: 0.5, sdlog: 0.8 }); // 0.595390608679215
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @category Distributions
|
|
143
159
|
*/
|
|
144
160
|
export function plnorm(q, options = {}) {
|
|
145
161
|
const { meanlog = 0, sdlog = 1, lowerTail = true, logP = false } = options;
|
|
@@ -151,6 +167,14 @@ export function plnorm(q, options = {}) {
|
|
|
151
167
|
* @param p - Probability (or log probability with `logP`): a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
152
168
|
* @param options - `meanlog` and `sdlog` (see {@link LognormalParams}), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
153
169
|
* @returns The quantile(s).
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* qlnorm(0.5, { meanlog: 1 }); // 2.718281828459045
|
|
174
|
+
* qlnorm([0.05, 0.95]); // [0.19304081669873657, 5.180251602233015]
|
|
175
|
+
* ```
|
|
176
|
+
*
|
|
177
|
+
* @category Distributions
|
|
154
178
|
*/
|
|
155
179
|
export function qlnorm(p, options = {}) {
|
|
156
180
|
const { meanlog = 0, sdlog = 1, lowerTail = true, logP = false } = options;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Options for {@link dmultinom}.
|
|
3
|
+
*
|
|
4
|
+
* @category Distributions
|
|
5
|
+
*/
|
|
2
6
|
export interface MultinomialOptions {
|
|
3
7
|
/** Total number of objects; defaults to the sum of `x` (it must equal it, as in R). */
|
|
4
8
|
size?: number;
|
|
@@ -20,5 +24,7 @@ export interface MultinomialOptions {
|
|
|
20
24
|
* ```ts
|
|
21
25
|
* dmultinom([1, 2, 1], [0.2, 0.5, 0.3]); // 0.18000000000000002
|
|
22
26
|
* ```
|
|
27
|
+
*
|
|
28
|
+
* @category Distributions
|
|
23
29
|
*/
|
|
24
30
|
export declare function dmultinom(x: readonly number[], prob: readonly number[], options?: MultinomialOptions): number;
|
|
@@ -23,6 +23,8 @@ import { ddAdd, ddDiv } from "../special/dd.js";
|
|
|
23
23
|
* ```ts
|
|
24
24
|
* dmultinom([1, 2, 1], [0.2, 0.5, 0.3]); // 0.18000000000000002
|
|
25
25
|
* ```
|
|
26
|
+
*
|
|
27
|
+
* @category Distributions
|
|
26
28
|
*/
|
|
27
29
|
export function dmultinom(x, prob, options = {}) {
|
|
28
30
|
const log = options.log ?? false;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type Vectorizable, type VectorResult } from "../internal/vectorize.js";
|
|
2
2
|
import { type DensityOptions, type TailOptions } from "../internal/dpq.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Parameters of the negative binomial distribution. Give exactly one of `prob` and `mu`.
|
|
5
|
+
*
|
|
6
|
+
* @category Distributions
|
|
7
|
+
*/
|
|
4
8
|
export interface NegBinomialParams {
|
|
5
9
|
/** Probability of success on each trial (`0 < prob <= 1`). Do not combine with `mu`. */
|
|
6
10
|
prob?: number;
|
|
@@ -24,6 +28,14 @@ export declare function qnbinomMu1(p: number, size: number, mu: number, lowerTai
|
|
|
24
28
|
* @param size - Target number of successes (need not be an integer).
|
|
25
29
|
* @param options - `prob` or `mu` (see {@link NegBinomialParams}; exactly one is required) and `log` (see {@link DensityOptions}).
|
|
26
30
|
* @returns The probability (or log probability).
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* dnbinom(3, 5, { prob: 0.5 }); // 0.13671875
|
|
35
|
+
* dnbinom(3, 5, { mu: 4 }); // 0.16261401187793145
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @category Distributions
|
|
27
39
|
*/
|
|
28
40
|
export declare function dnbinom<T extends Vectorizable>(x: T, size: number, options: NegBinomialParams & DensityOptions): VectorResult<T>;
|
|
29
41
|
/**
|
|
@@ -37,6 +49,14 @@ export declare function dnbinom<T extends Vectorizable>(x: T, size: number, opti
|
|
|
37
49
|
* @param size - Target number of successes (need not be an integer).
|
|
38
50
|
* @param options - `prob` or `mu` (see {@link NegBinomialParams}; exactly one is required), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
39
51
|
* @returns The probability (or log probability).
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* pnbinom(3, 5, { prob: 0.5 }); // 0.36328125
|
|
56
|
+
* pnbinom(3, 5, { mu: 4 }); // 0.4899473063232853
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @category Distributions
|
|
40
60
|
*/
|
|
41
61
|
export declare function pnbinom<T extends Vectorizable>(q: T, size: number, options: NegBinomialParams & TailOptions): VectorResult<T>;
|
|
42
62
|
/**
|
|
@@ -50,5 +70,13 @@ export declare function pnbinom<T extends Vectorizable>(q: T, size: number, opti
|
|
|
50
70
|
* @param size - Target number of successes (need not be an integer).
|
|
51
71
|
* @param options - `prob` or `mu` (see {@link NegBinomialParams}; exactly one is required), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
52
72
|
* @returns The quantile(s).
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* qnbinom(0.5, 5, { prob: 0.5 }); // 4
|
|
77
|
+
* qnbinom([0.05, 0.95], 5, { mu: 4 }); // [0, 9]
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @category Distributions
|
|
53
81
|
*/
|
|
54
82
|
export declare function qnbinom<T extends Vectorizable>(p: T, size: number, options: NegBinomialParams & TailOptions): VectorResult<T>;
|
|
@@ -277,6 +277,14 @@ function which(options) {
|
|
|
277
277
|
* @param size - Target number of successes (need not be an integer).
|
|
278
278
|
* @param options - `prob` or `mu` (see {@link NegBinomialParams}; exactly one is required) and `log` (see {@link DensityOptions}).
|
|
279
279
|
* @returns The probability (or log probability).
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```ts
|
|
283
|
+
* dnbinom(3, 5, { prob: 0.5 }); // 0.13671875
|
|
284
|
+
* dnbinom(3, 5, { mu: 4 }); // 0.16261401187793145
|
|
285
|
+
* ```
|
|
286
|
+
*
|
|
287
|
+
* @category Distributions
|
|
280
288
|
*/
|
|
281
289
|
export function dnbinom(x, size, options) {
|
|
282
290
|
const log = options.log ?? false;
|
|
@@ -296,6 +304,14 @@ export function dnbinom(x, size, options) {
|
|
|
296
304
|
* @param size - Target number of successes (need not be an integer).
|
|
297
305
|
* @param options - `prob` or `mu` (see {@link NegBinomialParams}; exactly one is required), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
298
306
|
* @returns The probability (or log probability).
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```ts
|
|
310
|
+
* pnbinom(3, 5, { prob: 0.5 }); // 0.36328125
|
|
311
|
+
* pnbinom(3, 5, { mu: 4 }); // 0.4899473063232853
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* @category Distributions
|
|
299
315
|
*/
|
|
300
316
|
export function pnbinom(q, size, options) {
|
|
301
317
|
const { lowerTail = true, logP = false } = options;
|
|
@@ -315,6 +331,14 @@ export function pnbinom(q, size, options) {
|
|
|
315
331
|
* @param size - Target number of successes (need not be an integer).
|
|
316
332
|
* @param options - `prob` or `mu` (see {@link NegBinomialParams}; exactly one is required), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
317
333
|
* @returns The quantile(s).
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```ts
|
|
337
|
+
* qnbinom(0.5, 5, { prob: 0.5 }); // 4
|
|
338
|
+
* qnbinom([0.05, 0.95], 5, { mu: 4 }); // [0, 9]
|
|
339
|
+
* ```
|
|
340
|
+
*
|
|
341
|
+
* @category Distributions
|
|
318
342
|
*/
|
|
319
343
|
export function qnbinom(p, size, options) {
|
|
320
344
|
const { lowerTail = true, logP = false } = options;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { type Vectorizable, type VectorResult } from "../internal/vectorize.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Options for {@link pnorm} and {@link qnorm}.
|
|
4
|
+
*
|
|
5
|
+
* @category Distributions
|
|
6
|
+
*/
|
|
3
7
|
export interface NormalOptions {
|
|
4
8
|
/** Mean. Default `0`. */
|
|
5
9
|
mean?: number;
|
|
@@ -26,6 +30,8 @@ export interface NormalOptions {
|
|
|
26
30
|
* dnorm([-1, 0, 1]); // [0.24197072451914337, 0.3989422804014327, 0.24197072451914337]
|
|
27
31
|
* dnorm(1, { mean: 1, sd: 2, log: true }); // -1.612085713764618
|
|
28
32
|
* ```
|
|
33
|
+
*
|
|
34
|
+
* @category Distributions
|
|
29
35
|
*/
|
|
30
36
|
export declare function dnorm<T extends Vectorizable>(x: T, options?: {
|
|
31
37
|
mean?: number;
|
|
@@ -47,6 +53,8 @@ export declare function dnorm<T extends Vectorizable>(x: T, options?: {
|
|
|
47
53
|
* pnorm(new Float64Array([-1, 0, 1])); // Float64Array [0.15865525393145707, 0.5, 0.8413447460685429]
|
|
48
54
|
* pnorm(-40, { logP: true }); // -804.6084420137538
|
|
49
55
|
* ```
|
|
56
|
+
*
|
|
57
|
+
* @category Distributions
|
|
50
58
|
*/
|
|
51
59
|
export declare function pnorm<T extends Vectorizable>(q: T, options?: NormalOptions): VectorResult<T>;
|
|
52
60
|
/**
|
|
@@ -62,5 +70,7 @@ export declare function pnorm<T extends Vectorizable>(q: T, options?: NormalOpti
|
|
|
62
70
|
* qnorm(0.975); // 1.959963984540054
|
|
63
71
|
* qnorm(0.05, { mean: 100, sd: 15 }); // 75.32719559572791
|
|
64
72
|
* ```
|
|
73
|
+
*
|
|
74
|
+
* @category Distributions
|
|
65
75
|
*/
|
|
66
76
|
export declare function qnorm<T extends Vectorizable>(p: T, options?: NormalOptions): VectorResult<T>;
|
|
@@ -139,6 +139,8 @@ function dnorm1(x, mean, sd, log) {
|
|
|
139
139
|
* dnorm([-1, 0, 1]); // [0.24197072451914337, 0.3989422804014327, 0.24197072451914337]
|
|
140
140
|
* dnorm(1, { mean: 1, sd: 2, log: true }); // -1.612085713764618
|
|
141
141
|
* ```
|
|
142
|
+
*
|
|
143
|
+
* @category Distributions
|
|
142
144
|
*/
|
|
143
145
|
export function dnorm(x, options = {}) {
|
|
144
146
|
const { mean = 0, sd = 1, log = false } = options;
|
|
@@ -159,6 +161,8 @@ export function dnorm(x, options = {}) {
|
|
|
159
161
|
* pnorm(new Float64Array([-1, 0, 1])); // Float64Array [0.15865525393145707, 0.5, 0.8413447460685429]
|
|
160
162
|
* pnorm(-40, { logP: true }); // -804.6084420137538
|
|
161
163
|
* ```
|
|
164
|
+
*
|
|
165
|
+
* @category Distributions
|
|
162
166
|
*/
|
|
163
167
|
export function pnorm(q, options = {}) {
|
|
164
168
|
const { mean = 0, sd = 1, lowerTail = true, logP = false } = options;
|
|
@@ -177,6 +181,8 @@ export function pnorm(q, options = {}) {
|
|
|
177
181
|
* qnorm(0.975); // 1.959963984540054
|
|
178
182
|
* qnorm(0.05, { mean: 100, sd: 15 }); // 75.32719559572791
|
|
179
183
|
* ```
|
|
184
|
+
*
|
|
185
|
+
* @category Distributions
|
|
180
186
|
*/
|
|
181
187
|
export function qnorm(p, options = {}) {
|
|
182
188
|
const { mean = 0, sd = 1, lowerTail = true, logP = false } = options;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type Vectorizable, type VectorResult } from "../internal/vectorize.js";
|
|
2
2
|
import { type DensityOptions, type TailOptions } from "../internal/dpq.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Shape and scale of the Pareto distribution.
|
|
5
|
+
*
|
|
6
|
+
* @category Distributions
|
|
7
|
+
*/
|
|
4
8
|
export interface ParetoParams {
|
|
5
9
|
/** Shape. Default `1`. */
|
|
6
10
|
a?: number;
|
|
@@ -11,13 +15,41 @@ export declare function dpareto1(x: number, a: number, b: number, log: boolean):
|
|
|
11
15
|
export declare function ppareto1(q: number, a: number, b: number, lowerTail: boolean, logP: boolean): number;
|
|
12
16
|
export declare function qpareto1(p: number, a: number, b: number, lowerTail: boolean, logP: boolean): number;
|
|
13
17
|
/**
|
|
14
|
-
* Density of the Pareto distribution. Equivalent to `extraDistr::dpareto(x, a = 1, b = 1, log = FALSE)
|
|
18
|
+
* Density of the Pareto distribution. Equivalent to `extraDistr::dpareto(x, a = 1, b = 1, log = FALSE)` in R.
|
|
15
19
|
*
|
|
16
20
|
* @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
17
21
|
* @param options - `a` and `b` (see {@link ParetoParams}) and `log` (see {@link DensityOptions}).
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* dpareto(2); // 0.25
|
|
26
|
+
* dpareto(3, { a: 2, b: 1.5 }); // 0.16666666666666666
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @category Distributions
|
|
18
30
|
*/
|
|
19
31
|
export declare function dpareto<T extends Vectorizable>(x: T, options?: ParetoParams & DensityOptions): VectorResult<T>;
|
|
20
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Distribution function of the Pareto distribution. Equivalent to `extraDistr::ppareto(q, a = 1, b = 1, lower.tail, log.p)` in R.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* ppareto(2); // 0.5
|
|
38
|
+
* ppareto(3, { a: 2, b: 1.5 }); // 0.75
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @category Distributions
|
|
42
|
+
*/
|
|
21
43
|
export declare function ppareto<T extends Vectorizable>(q: T, options?: ParetoParams & TailOptions): VectorResult<T>;
|
|
22
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Quantile function of the Pareto distribution. Equivalent to `extraDistr::qpareto(p, a = 1, b = 1, lower.tail, log.p)` in R.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* qpareto(0.5); // 2
|
|
50
|
+
* qpareto(0.9, { a: 2, b: 1.5 }); // 4.74341649025257
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @category Distributions
|
|
54
|
+
*/
|
|
23
55
|
export declare function qpareto<T extends Vectorizable>(p: T, options?: ParetoParams & TailOptions): VectorResult<T>;
|
|
@@ -55,21 +55,49 @@ export function qpareto1(p, a, b, lowerTail, logP) {
|
|
|
55
55
|
return b * Math.exp(-lu / a);
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
* Density of the Pareto distribution. Equivalent to `extraDistr::dpareto(x, a = 1, b = 1, log = FALSE)
|
|
58
|
+
* Density of the Pareto distribution. Equivalent to `extraDistr::dpareto(x, a = 1, b = 1, log = FALSE)` in R.
|
|
59
59
|
*
|
|
60
60
|
* @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
61
61
|
* @param options - `a` and `b` (see {@link ParetoParams}) and `log` (see {@link DensityOptions}).
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* dpareto(2); // 0.25
|
|
66
|
+
* dpareto(3, { a: 2, b: 1.5 }); // 0.16666666666666666
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @category Distributions
|
|
62
70
|
*/
|
|
63
71
|
export function dpareto(x, options = {}) {
|
|
64
72
|
const { a = 1, b = 1, log = false } = options;
|
|
65
73
|
return vectorize(x, (v) => dpareto1(v, a, b, log));
|
|
66
74
|
}
|
|
67
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* Distribution function of the Pareto distribution. Equivalent to `extraDistr::ppareto(q, a = 1, b = 1, lower.tail, log.p)` in R.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* ppareto(2); // 0.5
|
|
81
|
+
* ppareto(3, { a: 2, b: 1.5 }); // 0.75
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @category Distributions
|
|
85
|
+
*/
|
|
68
86
|
export function ppareto(q, options = {}) {
|
|
69
87
|
const { a = 1, b = 1, lowerTail = true, logP = false } = options;
|
|
70
88
|
return vectorize(q, (v) => ppareto1(v, a, b, lowerTail, logP));
|
|
71
89
|
}
|
|
72
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* Quantile function of the Pareto distribution. Equivalent to `extraDistr::qpareto(p, a = 1, b = 1, lower.tail, log.p)` in R.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* qpareto(0.5); // 2
|
|
96
|
+
* qpareto(0.9, { a: 2, b: 1.5 }); // 4.74341649025257
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @category Distributions
|
|
100
|
+
*/
|
|
73
101
|
export function qpareto(p, options = {}) {
|
|
74
102
|
const { a = 1, b = 1, lowerTail = true, logP = false } = options;
|
|
75
103
|
return vectorize(p, (v) => qpareto1(v, a, b, lowerTail, logP));
|
|
@@ -13,6 +13,14 @@ export declare function qpois1(p: number, lambda: number, lowerTail: boolean, lo
|
|
|
13
13
|
* @param lambda - Mean.
|
|
14
14
|
* @param options - `log` (see {@link DensityOptions}).
|
|
15
15
|
* @returns The probability (or log probability).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* dpois(2, 3); // 0.22404180765538775
|
|
20
|
+
* dpois([0, 1, 2], 3); // [0.049787068367863944, 0.14936120510359185, 0.22404180765538775]
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @category Distributions
|
|
16
24
|
*/
|
|
17
25
|
export declare function dpois<T extends Vectorizable>(x: T, lambda: number, options?: DensityOptions): VectorResult<T>;
|
|
18
26
|
/**
|
|
@@ -28,6 +36,8 @@ export declare function dpois<T extends Vectorizable>(x: T, lambda: number, opti
|
|
|
28
36
|
* ppois(2, 3); // 0.4231900811268436
|
|
29
37
|
* ppois(5, 3, { lowerTail: false }); // P[X > 5] = 0.08391794203130346
|
|
30
38
|
* ```
|
|
39
|
+
*
|
|
40
|
+
* @category Distributions
|
|
31
41
|
*/
|
|
32
42
|
export declare function ppois<T extends Vectorizable>(q: T, lambda: number, options?: TailOptions): VectorResult<T>;
|
|
33
43
|
/**
|
|
@@ -37,5 +47,13 @@ export declare function ppois<T extends Vectorizable>(q: T, lambda: number, opti
|
|
|
37
47
|
* @param lambda - Mean.
|
|
38
48
|
* @param options - `lowerTail` and `logP` (see {@link TailOptions}).
|
|
39
49
|
* @returns The quantile(s).
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* qpois(0.5, 3); // 3
|
|
54
|
+
* qpois([0.05, 0.95], 3); // [1, 6]
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @category Distributions
|
|
40
58
|
*/
|
|
41
59
|
export declare function qpois<T extends Vectorizable>(p: T, lambda: number, options?: TailOptions): VectorResult<T>;
|
|
@@ -67,6 +67,14 @@ export function qpois1(p, lambda, lowerTail, logP) {
|
|
|
67
67
|
* @param lambda - Mean.
|
|
68
68
|
* @param options - `log` (see {@link DensityOptions}).
|
|
69
69
|
* @returns The probability (or log probability).
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* dpois(2, 3); // 0.22404180765538775
|
|
74
|
+
* dpois([0, 1, 2], 3); // [0.049787068367863944, 0.14936120510359185, 0.22404180765538775]
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @category Distributions
|
|
70
78
|
*/
|
|
71
79
|
export function dpois(x, lambda, options = {}) {
|
|
72
80
|
const log = options.log ?? false;
|
|
@@ -85,6 +93,8 @@ export function dpois(x, lambda, options = {}) {
|
|
|
85
93
|
* ppois(2, 3); // 0.4231900811268436
|
|
86
94
|
* ppois(5, 3, { lowerTail: false }); // P[X > 5] = 0.08391794203130346
|
|
87
95
|
* ```
|
|
96
|
+
*
|
|
97
|
+
* @category Distributions
|
|
88
98
|
*/
|
|
89
99
|
export function ppois(q, lambda, options = {}) {
|
|
90
100
|
const { lowerTail = true, logP = false } = options;
|
|
@@ -97,6 +107,14 @@ export function ppois(q, lambda, options = {}) {
|
|
|
97
107
|
* @param lambda - Mean.
|
|
98
108
|
* @param options - `lowerTail` and `logP` (see {@link TailOptions}).
|
|
99
109
|
* @returns The quantile(s).
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* qpois(0.5, 3); // 3
|
|
114
|
+
* qpois([0.05, 0.95], 3); // [1, 6]
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* @category Distributions
|
|
100
118
|
*/
|
|
101
119
|
export function qpois(p, lambda, options = {}) {
|
|
102
120
|
const { lowerTail = true, logP = false } = options;
|
|
@@ -12,6 +12,14 @@ export declare function qsignrank1(p: number, n: number, lowerTail: boolean, log
|
|
|
12
12
|
* @param n - Number of observations.
|
|
13
13
|
* @param options - `log` (see {@link DensityOptions}).
|
|
14
14
|
* @returns The probability (or log probability).
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* dsignrank(5, 10); // 0.0029296875
|
|
19
|
+
* dsignrank([0, 1, 2], 4); // [0.0625, 0.0625, 0.0625]
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @category Distributions
|
|
15
23
|
*/
|
|
16
24
|
export declare function dsignrank<T extends Vectorizable>(x: T, n: number, options?: DensityOptions): VectorResult<T>;
|
|
17
25
|
/**
|
|
@@ -23,6 +31,14 @@ export declare function dsignrank<T extends Vectorizable>(x: T, n: number, optio
|
|
|
23
31
|
* @param n - Number of observations.
|
|
24
32
|
* @param options - `lowerTail` and `logP` (see {@link TailOptions}).
|
|
25
33
|
* @returns The probability (or log probability).
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* psignrank(10, 10); // 0.0419921875
|
|
38
|
+
* psignrank(40, 10, { lowerTail: false }); // 0.0966796875
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @category Distributions
|
|
26
42
|
*/
|
|
27
43
|
export declare function psignrank<T extends Vectorizable>(q: T, n: number, options?: TailOptions): VectorResult<T>;
|
|
28
44
|
/**
|
|
@@ -34,5 +50,13 @@ export declare function psignrank<T extends Vectorizable>(q: T, n: number, optio
|
|
|
34
50
|
* @param n - Number of observations.
|
|
35
51
|
* @param options - `lowerTail` and `logP` (see {@link TailOptions}).
|
|
36
52
|
* @returns The quantile(s).
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* qsignrank(0.025, 10); // 9
|
|
57
|
+
* qsignrank([0.25, 0.75], 10); // [21, 34]
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @category Distributions
|
|
37
61
|
*/
|
|
38
62
|
export declare function qsignrank<T extends Vectorizable>(p: T, n: number, options?: TailOptions): VectorResult<T>;
|
|
@@ -181,6 +181,14 @@ export function qsignrank1(p, n, lowerTail, logP) {
|
|
|
181
181
|
* @param n - Number of observations.
|
|
182
182
|
* @param options - `log` (see {@link DensityOptions}).
|
|
183
183
|
* @returns The probability (or log probability).
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* dsignrank(5, 10); // 0.0029296875
|
|
188
|
+
* dsignrank([0, 1, 2], 4); // [0.0625, 0.0625, 0.0625]
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* @category Distributions
|
|
184
192
|
*/
|
|
185
193
|
export function dsignrank(x, n, options = {}) {
|
|
186
194
|
const log = options.log ?? false;
|
|
@@ -195,6 +203,14 @@ export function dsignrank(x, n, options = {}) {
|
|
|
195
203
|
* @param n - Number of observations.
|
|
196
204
|
* @param options - `lowerTail` and `logP` (see {@link TailOptions}).
|
|
197
205
|
* @returns The probability (or log probability).
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* psignrank(10, 10); // 0.0419921875
|
|
210
|
+
* psignrank(40, 10, { lowerTail: false }); // 0.0966796875
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* @category Distributions
|
|
198
214
|
*/
|
|
199
215
|
export function psignrank(q, n, options = {}) {
|
|
200
216
|
const { lowerTail = true, logP = false } = options;
|
|
@@ -209,6 +225,14 @@ export function psignrank(q, n, options = {}) {
|
|
|
209
225
|
* @param n - Number of observations.
|
|
210
226
|
* @param options - `lowerTail` and `logP` (see {@link TailOptions}).
|
|
211
227
|
* @returns The quantile(s).
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```ts
|
|
231
|
+
* qsignrank(0.025, 10); // 9
|
|
232
|
+
* qsignrank([0.25, 0.75], 10); // [21, 34]
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* @category Distributions
|
|
212
236
|
*/
|
|
213
237
|
export function qsignrank(p, n, options = {}) {
|
|
214
238
|
const { lowerTail = true, logP = false } = options;
|
|
@@ -1,25 +1,43 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Result of {@link distSummary}.
|
|
3
|
+
*
|
|
4
|
+
* @category Distributions
|
|
5
|
+
*/
|
|
2
6
|
export interface DistSummary {
|
|
7
|
+
/** Mean (NaN when it does not exist, `Infinity` when it is infinite). */
|
|
3
8
|
mean: number;
|
|
9
|
+
/** Variance (NaN when it does not exist, `Infinity` when it is infinite). */
|
|
4
10
|
variance: number;
|
|
11
|
+
/** Standard deviation, the square root of the variance. */
|
|
5
12
|
sd: number;
|
|
13
|
+
/** Median: the q function at 0.5 (for discrete distributions the smallest x with F(x) >= 0.5). */
|
|
6
14
|
median: number;
|
|
15
|
+
/** Mode: the maximum of the density (NaN when it is not unique; the larger of two adjacent modes). */
|
|
7
16
|
mode: number;
|
|
17
|
+
/** Skewness, E[(X - mean)^3] / sd^3. */
|
|
8
18
|
skewness: number;
|
|
9
19
|
/** Excess kurtosis (0 for the normal distribution). */
|
|
10
20
|
kurtosis: number;
|
|
11
21
|
}
|
|
12
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Distributions known to {@link distSummary} (the names of their d/p/q/r functions).
|
|
24
|
+
*
|
|
25
|
+
* @category Distributions
|
|
26
|
+
*/
|
|
13
27
|
export type DistName = "norm" | "lnorm" | "unif" | "exp" | "gamma" | "chisq" | "beta" | "t" | "f" | "cauchy" | "weibull" | "logis" | "binom" | "pois" | "geom" | "nbinom" | "hyper" | "invgamma" | "kumar" | "pareto" | "triang" | "laplace" | "arcsine";
|
|
14
28
|
/**
|
|
15
29
|
* Mean, variance, standard deviation, median, mode, skewness and excess kurtosis of a distribution, given by the
|
|
16
30
|
* name of its d/p/q/r functions and their parameters (with the same names and defaults; `gamma` takes `rate` or
|
|
17
31
|
* `scale`, `nbinom` takes `prob` or `mu`). Invalid parameters give NaN throughout.
|
|
32
|
+
* Not an R function. R has no function for these summaries; the R references are closed forms checked against
|
|
33
|
+
* numerical moments.
|
|
18
34
|
*
|
|
19
35
|
* @example
|
|
20
36
|
* ```ts
|
|
21
37
|
* distSummary("gamma", { shape: 2.5, rate: 2 }); // { mean: 1.25, variance: 0.625, ..., mode: 0.75, kurtosis: 2.4 }
|
|
22
38
|
* distSummary("binom", { size: 9, prob: 0.5 }).mode; // 5 (4 and 5 are equally likely: the larger)
|
|
23
39
|
* ```
|
|
40
|
+
*
|
|
41
|
+
* @category Distributions
|
|
24
42
|
*/
|
|
25
43
|
export declare function distSummary(distribution: DistName, params?: Record<string, number | undefined>): DistSummary;
|
|
@@ -66,12 +66,16 @@ const has = (o, k) => o[k] !== undefined;
|
|
|
66
66
|
* Mean, variance, standard deviation, median, mode, skewness and excess kurtosis of a distribution, given by the
|
|
67
67
|
* name of its d/p/q/r functions and their parameters (with the same names and defaults; `gamma` takes `rate` or
|
|
68
68
|
* `scale`, `nbinom` takes `prob` or `mu`). Invalid parameters give NaN throughout.
|
|
69
|
+
* Not an R function. R has no function for these summaries; the R references are closed forms checked against
|
|
70
|
+
* numerical moments.
|
|
69
71
|
*
|
|
70
72
|
* @example
|
|
71
73
|
* ```ts
|
|
72
74
|
* distSummary("gamma", { shape: 2.5, rate: 2 }); // { mean: 1.25, variance: 0.625, ..., mode: 0.75, kurtosis: 2.4 }
|
|
73
75
|
* distSummary("binom", { size: 9, prob: 0.5 }).mode; // 5 (4 and 5 are equally likely: the larger)
|
|
74
76
|
* ```
|
|
77
|
+
*
|
|
78
|
+
* @category Distributions
|
|
75
79
|
*/
|
|
76
80
|
export function distSummary(distribution, params = {}) {
|
|
77
81
|
const P = params;
|
|
@@ -17,6 +17,14 @@ export declare function qt1(p: number, df: number, lowerTail: boolean, logP: boo
|
|
|
17
17
|
* @param df - Degrees of freedom.
|
|
18
18
|
* @param options - `ncp` (see {@link NoncentralOption}) and `log` (see {@link DensityOptions}).
|
|
19
19
|
* @returns The density (or log density).
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* dt(0, 5); // 0.37960668982249446
|
|
24
|
+
* dt(1, 5, { ncp: 1 }); // 0.36232483923371867
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @category Distributions
|
|
20
28
|
*/
|
|
21
29
|
export declare function dt<T extends Vectorizable>(x: T, df: number, options?: DensityOptions & NoncentralOption): VectorResult<T>;
|
|
22
30
|
/**
|
|
@@ -34,6 +42,8 @@ export declare function dt<T extends Vectorizable>(x: T, df: number, options?: D
|
|
|
34
42
|
* pt(2.1, 10, { lowerTail: false }); // 0.031038622101109286
|
|
35
43
|
* pt(1, 5, { ncp: 1 }); // 0.48092614124210525
|
|
36
44
|
* ```
|
|
45
|
+
*
|
|
46
|
+
* @category Distributions
|
|
37
47
|
*/
|
|
38
48
|
export declare function pt<T extends Vectorizable>(q: T, df: number, options?: TailOptions & NoncentralOption): VectorResult<T>;
|
|
39
49
|
/**
|
|
@@ -45,5 +55,13 @@ export declare function pt<T extends Vectorizable>(q: T, df: number, options?: T
|
|
|
45
55
|
* @param df - Degrees of freedom.
|
|
46
56
|
* @param options - `ncp` (see {@link NoncentralOption}), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
47
57
|
* @returns The quantile(s).
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* qt(0.975, 10); // 2.228138851986274
|
|
62
|
+
* qt([0.025, 0.975], 5); // [-2.5705818356363155, 2.5705818356363146]
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @category Distributions
|
|
48
66
|
*/
|
|
49
67
|
export declare function qt<T extends Vectorizable>(p: T, df: number, options?: TailOptions & NoncentralOption): VectorResult<T>;
|
package/dist/distributions/t.js
CHANGED
|
@@ -188,6 +188,14 @@ export function qt1(p, df, lowerTail, logP) {
|
|
|
188
188
|
* @param df - Degrees of freedom.
|
|
189
189
|
* @param options - `ncp` (see {@link NoncentralOption}) and `log` (see {@link DensityOptions}).
|
|
190
190
|
* @returns The density (or log density).
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```ts
|
|
194
|
+
* dt(0, 5); // 0.37960668982249446
|
|
195
|
+
* dt(1, 5, { ncp: 1 }); // 0.36232483923371867
|
|
196
|
+
* ```
|
|
197
|
+
*
|
|
198
|
+
* @category Distributions
|
|
191
199
|
*/
|
|
192
200
|
export function dt(x, df, options = {}) {
|
|
193
201
|
const { log = false, ncp } = options;
|
|
@@ -210,6 +218,8 @@ export function dt(x, df, options = {}) {
|
|
|
210
218
|
* pt(2.1, 10, { lowerTail: false }); // 0.031038622101109286
|
|
211
219
|
* pt(1, 5, { ncp: 1 }); // 0.48092614124210525
|
|
212
220
|
* ```
|
|
221
|
+
*
|
|
222
|
+
* @category Distributions
|
|
213
223
|
*/
|
|
214
224
|
export function pt(q, df, options = {}) {
|
|
215
225
|
const { lowerTail = true, logP = false, ncp } = options;
|
|
@@ -226,6 +236,14 @@ export function pt(q, df, options = {}) {
|
|
|
226
236
|
* @param df - Degrees of freedom.
|
|
227
237
|
* @param options - `ncp` (see {@link NoncentralOption}), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
228
238
|
* @returns The quantile(s).
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```ts
|
|
242
|
+
* qt(0.975, 10); // 2.228138851986274
|
|
243
|
+
* qt([0.025, 0.975], 5); // [-2.5705818356363155, 2.5705818356363146]
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
246
|
+
* @category Distributions
|
|
229
247
|
*/
|
|
230
248
|
export function qt(p, df, options = {}) {
|
|
231
249
|
const { lowerTail = true, logP = false, ncp } = options;
|