@ac-kit/math-stats 0.6.0 → 0.7.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.
Files changed (141) hide show
  1. package/CHANGELOG.md +123 -0
  2. package/README.md +43 -2
  3. package/dist/_digamma.d.ts +10 -0
  4. package/dist/_digamma.d.ts.map +1 -0
  5. package/dist/_digamma.js +38 -0
  6. package/dist/_digamma.js.map +1 -0
  7. package/dist/_dilogarithm.d.ts +14 -0
  8. package/dist/_dilogarithm.d.ts.map +1 -0
  9. package/dist/_dilogarithm.js +77 -0
  10. package/dist/_dilogarithm.js.map +1 -0
  11. package/dist/_incomplete-gamma-shape-derivative.d.ts +17 -0
  12. package/dist/_incomplete-gamma-shape-derivative.d.ts.map +1 -0
  13. package/dist/_incomplete-gamma-shape-derivative.js +90 -0
  14. package/dist/_incomplete-gamma-shape-derivative.js.map +1 -0
  15. package/dist/_logistic.d.ts +14 -0
  16. package/dist/_logistic.d.ts.map +1 -0
  17. package/dist/_logistic.js +29 -0
  18. package/dist/_logistic.js.map +1 -0
  19. package/dist/_normal-tail.d.ts +43 -0
  20. package/dist/_normal-tail.d.ts.map +1 -0
  21. package/dist/_normal-tail.js +124 -0
  22. package/dist/_normal-tail.js.map +1 -0
  23. package/dist/_rank-test.d.ts +71 -0
  24. package/dist/_rank-test.d.ts.map +1 -0
  25. package/dist/_rank-test.js +130 -0
  26. package/dist/_rank-test.js.map +1 -0
  27. package/dist/average.js +2 -2
  28. package/dist/average.js.map +1 -1
  29. package/dist/bootstrap.d.ts +67 -0
  30. package/dist/bootstrap.d.ts.map +1 -0
  31. package/dist/bootstrap.js +154 -0
  32. package/dist/bootstrap.js.map +1 -0
  33. package/dist/censored-logistic-distribution.d.ts +23 -0
  34. package/dist/censored-logistic-distribution.d.ts.map +1 -0
  35. package/dist/censored-logistic-distribution.js +63 -0
  36. package/dist/censored-logistic-distribution.js.map +1 -0
  37. package/dist/censored-shifted-gamma-distribution.d.ts +23 -0
  38. package/dist/censored-shifted-gamma-distribution.d.ts.map +1 -0
  39. package/dist/censored-shifted-gamma-distribution.js +73 -0
  40. package/dist/censored-shifted-gamma-distribution.js.map +1 -0
  41. package/dist/confidence-interval.d.ts +53 -0
  42. package/dist/confidence-interval.d.ts.map +1 -1
  43. package/dist/confidence-interval.js +73 -0
  44. package/dist/confidence-interval.js.map +1 -1
  45. package/dist/correlation.d.ts +41 -0
  46. package/dist/correlation.d.ts.map +1 -1
  47. package/dist/correlation.js +168 -2
  48. package/dist/correlation.js.map +1 -1
  49. package/dist/descriptive.d.ts +129 -0
  50. package/dist/descriptive.d.ts.map +1 -0
  51. package/dist/descriptive.js +289 -0
  52. package/dist/descriptive.js.map +1 -0
  53. package/dist/forecast/_forecast-checks.d.ts +30 -0
  54. package/dist/forecast/_forecast-checks.d.ts.map +1 -0
  55. package/dist/forecast/_forecast-checks.js +119 -0
  56. package/dist/forecast/_forecast-checks.js.map +1 -0
  57. package/dist/forecast/_score-kernels.d.ts +63 -0
  58. package/dist/forecast/_score-kernels.d.ts.map +1 -0
  59. package/dist/forecast/_score-kernels.js +264 -0
  60. package/dist/forecast/_score-kernels.js.map +1 -0
  61. package/dist/forecast/brier-score.d.ts +102 -0
  62. package/dist/forecast/brier-score.d.ts.map +1 -0
  63. package/dist/forecast/brier-score.js +163 -0
  64. package/dist/forecast/brier-score.js.map +1 -0
  65. package/dist/forecast/crps-closed-form.d.ts +64 -0
  66. package/dist/forecast/crps-closed-form.d.ts.map +1 -0
  67. package/dist/forecast/crps-closed-form.js +106 -0
  68. package/dist/forecast/crps-closed-form.js.map +1 -0
  69. package/dist/forecast/crps-ensemble.d.ts +53 -0
  70. package/dist/forecast/crps-ensemble.d.ts.map +1 -0
  71. package/dist/forecast/crps-ensemble.js +121 -0
  72. package/dist/forecast/crps-ensemble.js.map +1 -0
  73. package/dist/forecast/emos.d.ts +158 -0
  74. package/dist/forecast/emos.d.ts.map +1 -0
  75. package/dist/forecast/emos.js +397 -0
  76. package/dist/forecast/emos.js.map +1 -0
  77. package/dist/forecast/exceedance-probability.d.ts +54 -0
  78. package/dist/forecast/exceedance-probability.d.ts.map +1 -0
  79. package/dist/forecast/exceedance-probability.js +125 -0
  80. package/dist/forecast/exceedance-probability.js.map +1 -0
  81. package/dist/forecast/log-score.d.ts +18 -0
  82. package/dist/forecast/log-score.d.ts.map +1 -0
  83. package/dist/forecast/log-score.js +19 -0
  84. package/dist/forecast/log-score.js.map +1 -0
  85. package/dist/forecast/logistic-regression.d.ts +123 -0
  86. package/dist/forecast/logistic-regression.d.ts.map +1 -0
  87. package/dist/forecast/logistic-regression.js +282 -0
  88. package/dist/forecast/logistic-regression.js.map +1 -0
  89. package/dist/forecast/rank-histogram.d.ts +32 -0
  90. package/dist/forecast/rank-histogram.d.ts.map +1 -0
  91. package/dist/forecast/rank-histogram.js +63 -0
  92. package/dist/forecast/rank-histogram.js.map +1 -0
  93. package/dist/forecast/reliability-diagram.d.ts +70 -0
  94. package/dist/forecast/reliability-diagram.d.ts.map +1 -0
  95. package/dist/forecast/reliability-diagram.js +126 -0
  96. package/dist/forecast/reliability-diagram.js.map +1 -0
  97. package/dist/forecast/roc-curve.d.ts +58 -0
  98. package/dist/forecast/roc-curve.d.ts.map +1 -0
  99. package/dist/forecast/roc-curve.js +124 -0
  100. package/dist/forecast/roc-curve.js.map +1 -0
  101. package/dist/index.d.ts +21 -0
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js +21 -0
  104. package/dist/index.js.map +1 -1
  105. package/dist/mann-whitney-u.d.ts +27 -0
  106. package/dist/mann-whitney-u.d.ts.map +1 -0
  107. package/dist/mann-whitney-u.js +94 -0
  108. package/dist/mann-whitney-u.js.map +1 -0
  109. package/dist/multiple-regression.d.ts +123 -0
  110. package/dist/multiple-regression.d.ts.map +1 -0
  111. package/dist/multiple-regression.js +208 -0
  112. package/dist/multiple-regression.js.map +1 -0
  113. package/dist/principal-components.d.ts +66 -0
  114. package/dist/principal-components.d.ts.map +1 -0
  115. package/dist/principal-components.js +105 -0
  116. package/dist/principal-components.js.map +1 -0
  117. package/dist/quantile.d.ts +97 -9
  118. package/dist/quantile.d.ts.map +1 -1
  119. package/dist/quantile.js +298 -44
  120. package/dist/quantile.js.map +1 -1
  121. package/dist/regression.d.ts +46 -0
  122. package/dist/regression.d.ts.map +1 -1
  123. package/dist/regression.js +99 -1
  124. package/dist/regression.js.map +1 -1
  125. package/dist/sample.d.ts +29 -0
  126. package/dist/sample.d.ts.map +1 -0
  127. package/dist/sample.js +39 -0
  128. package/dist/sample.js.map +1 -0
  129. package/dist/t-digest.d.ts +136 -0
  130. package/dist/t-digest.d.ts.map +1 -0
  131. package/dist/t-digest.js +424 -0
  132. package/dist/t-digest.js.map +1 -0
  133. package/dist/truncated-normal-distribution.d.ts +28 -0
  134. package/dist/truncated-normal-distribution.d.ts.map +1 -0
  135. package/dist/truncated-normal-distribution.js +198 -0
  136. package/dist/truncated-normal-distribution.js.map +1 -0
  137. package/dist/wilcoxon-signed-rank.d.ts +42 -0
  138. package/dist/wilcoxon-signed-rank.d.ts.map +1 -0
  139. package/dist/wilcoxon-signed-rank.js +117 -0
  140. package/dist/wilcoxon-signed-rank.js.map +1 -0
  141. package/package.json +14 -10
@@ -0,0 +1,126 @@
1
+ import { bisectRightNumbers } from "@ac-kit/algo";
2
+ import { assertInteger, describeValue } from "@ac-kit/core";
3
+ import { writeQuantile } from "../quantile.js";
4
+ import { assertBinary_, assertProbabilities_, assertSameLength_, probabilityBins_, weightTotal_, } from "./_forecast-checks.js";
5
+ /**
6
+ * The reliability diagram of probability forecasts against binary outcomes
7
+ * (Murphy and Winkler 1977): for each bin, the mean forecast probability
8
+ * against the observed frequency of the event, which lie on the diagonal for
9
+ * reliable forecasts. Columnar: one `Float64Array` per quantity.
10
+ *
11
+ * **Consistency bars** (Bröcker and Smith 2007) show how far from the diagonal
12
+ * a reliable forecast's points still stray by chance, given how few cases each
13
+ * bin holds. Each surrogate data set redraws `n` forecasts from the given ones
14
+ * (by their weights) and each outcome as a Bernoulli trial of its own forecast
15
+ * — reliable by construction — and records, per bin, the observed frequency
16
+ * minus the mean forecast. A bar is the bin's mean forecast plus the `(1 ±
17
+ * level)/2` quantiles of that deviation, so it surrounds the diagonal at the
18
+ * point's abscissa; a point outside its bar is evidence of miscalibration at
19
+ * that level.
20
+ *
21
+ * O(n log n + resamples · n log n) time (one binary search per weighted draw),
22
+ * O(bins · resamples) memory.
23
+ *
24
+ * @param probabilities The forecast probabilities, in `[0, 1]`.
25
+ * @param outcomes The binary outcomes, `0` or `1`.
26
+ * @param options Binning, case weights, consistency resampling.
27
+ * @returns The diagram's columns.
28
+ * @throws {RangeError} When the lengths differ, a probability lies outside `[0,
29
+ * 1]`, an outcome is not `0` or `1`, or an option is out of range.
30
+ */
31
+ export function reliabilityDiagram(probabilities, outcomes, options) {
32
+ const routine = "reliabilityDiagram";
33
+ const count = probabilities.length;
34
+ assertSameLength_(routine, "probabilities", count, "outcomes", outcomes.length);
35
+ assertProbabilities_(routine, probabilities);
36
+ assertBinary_(routine, outcomes);
37
+ const weights = options?.weights ?? null;
38
+ const total = weightTotal_(routine, weights, count);
39
+ const bins = probabilityBins_(routine, options?.bins ?? 10, probabilities);
40
+ const binCount = bins.count;
41
+ const weight = new Float64Array(binCount);
42
+ const meanForecast = new Float64Array(binCount);
43
+ const observedFrequency = new Float64Array(binCount);
44
+ const consistencyLower = new Float64Array(binCount).fill(Number.NaN);
45
+ const consistencyUpper = new Float64Array(binCount).fill(Number.NaN);
46
+ const binOf = new Int32Array(count);
47
+ for (let index = 0; index < count; index++) {
48
+ const caseWeight = weights === null ? 1 : weights[index];
49
+ const bin = bins.binOf(probabilities[index]);
50
+ binOf[index] = bin;
51
+ weight[bin] += caseWeight;
52
+ meanForecast[bin] += caseWeight * probabilities[index];
53
+ observedFrequency[bin] += caseWeight * outcomes[index];
54
+ }
55
+ for (let bin = 0; bin < binCount; bin++) {
56
+ meanForecast[bin] /= weight[bin];
57
+ observedFrequency[bin] /= weight[bin];
58
+ }
59
+ const consistency = options?.consistency ?? null;
60
+ if (consistency !== null && count > 0) {
61
+ const resamples = consistency.resamples ?? 1000;
62
+ const level = consistency.level ?? 0.9;
63
+ assertInteger(resamples, "resamples", 1);
64
+ if (!(level > 0 && level < 1)) {
65
+ throw new RangeError(`${routine}: level must be in (0, 1), got ${describeValue(level)}`);
66
+ }
67
+ const random = consistency.random;
68
+ // Cumulative weights, to draw a case in proportion to its weight.
69
+ const cumulative = new Float64Array(count);
70
+ let running = 0;
71
+ for (let index = 0; index < count; index++) {
72
+ running += weights === null ? 1 : weights[index];
73
+ cumulative[index] = running;
74
+ }
75
+ const deviations = new Float64Array(binCount * resamples);
76
+ const filled = new Int32Array(binCount);
77
+ const drawnWeight = new Float64Array(binCount);
78
+ const drawnForecast = new Float64Array(binCount);
79
+ const drawnEvents = new Float64Array(binCount);
80
+ for (let resample = 0; resample < resamples; resample++) {
81
+ drawnWeight.fill(0);
82
+ drawnForecast.fill(0);
83
+ drawnEvents.fill(0);
84
+ for (let draw = 0; draw < count; draw++) {
85
+ const chosen = Math.min(bisectRightNumbers(cumulative, random() * total), count - 1);
86
+ const forecast = probabilities[chosen];
87
+ const bin = binOf[chosen];
88
+ drawnWeight[bin] += 1;
89
+ drawnForecast[bin] += forecast;
90
+ if (random() < forecast) {
91
+ drawnEvents[bin] += 1;
92
+ }
93
+ }
94
+ for (let bin = 0; bin < binCount; bin++) {
95
+ const drawn = drawnWeight[bin];
96
+ if (drawn > 0) {
97
+ deviations[bin * resamples + filled[bin]] =
98
+ (drawnEvents[bin] - drawnForecast[bin]) / drawn;
99
+ filled[bin] += 1;
100
+ }
101
+ }
102
+ }
103
+ const tail = (1 - level) / 2;
104
+ for (let bin = 0; bin < binCount; bin++) {
105
+ const from = bin * resamples;
106
+ const to = from + filled[bin];
107
+ if (to > from && weight[bin] > 0) {
108
+ deviations.subarray(from, to).sort();
109
+ writeQuantile(consistencyLower, bin, deviations, tail, from, to);
110
+ writeQuantile(consistencyUpper, bin, deviations, 1 - tail, from, to);
111
+ consistencyLower[bin] += meanForecast[bin];
112
+ consistencyUpper[bin] += meanForecast[bin];
113
+ }
114
+ }
115
+ }
116
+ return {
117
+ binLower: bins.lower,
118
+ binUpper: bins.upper,
119
+ weight,
120
+ meanForecast,
121
+ observedFrequency,
122
+ consistencyLower,
123
+ consistencyUpper,
124
+ };
125
+ }
126
+ //# sourceMappingURL=reliability-diagram.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reliability-diagram.js","sourceRoot":"","sources":["../../src/forecast/reliability-diagram.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAiB,MAAM,cAAc,CAAC;AAE3E,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACN,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,GACZ,MAAM,uBAAuB,CAAC;AAiD/B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,kBAAkB,CACjC,aAAgC,EAChC,QAA2B,EAC3B,OAAmC;IAEnC,MAAM,OAAO,GAAG,oBAAoB,CAAC;IACrC,MAAM,KAAK,GAAG,aAAa,CAAC,MAAM,CAAC;IAEnC,iBAAiB,CAChB,OAAO,EACP,eAAe,EACf,KAAK,EACL,UAAU,EACV,QAAQ,CAAC,MAAM,CACf,CAAC;IACF,oBAAoB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC7C,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,IAAI,CAAC;IACzC,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,gBAAgB,CAAC,OAAO,EAAE,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relative operating characteristic (ROC) curve, columnar: point `j` is the
4
+ * warning rule "the event when the probability is at least `thresholds[j]`".
5
+ * The first point, at threshold `+∞`, warns never (`0, 0`); the last, at the
6
+ * lowest forecast, always (`1, 1`).
7
+ */
8
+ export type RocCurve = {
9
+ /**
10
+ * The decision thresholds, descending: `+∞`, then each distinct forecast (or
11
+ * the given thresholds, then `−∞`).
12
+ */
13
+ readonly thresholds: Float64Array;
14
+ /** The hit rate (probability of detection) of each rule. */
15
+ readonly hitRate: Float64Array;
16
+ /** The false alarm rate (probability of false detection) of each rule. */
17
+ readonly falseAlarmRate: Float64Array;
18
+ /**
19
+ * The area under the curve by the trapezoidal rule: the probability that a
20
+ * random event got a higher forecast than a random non-event, ties counting
21
+ * half (the Mann–Whitney statistic). `0.5` is no discrimination; `NaN`
22
+ * without both events and non-events.
23
+ */
24
+ readonly area: number;
25
+ };
26
+ /** Options of {@link rocCurve}. */
27
+ export type RocCurveOptions = ForecastWeightsOptions & {
28
+ /**
29
+ * The decision thresholds, distinct and not `NaN`, in any order: the curve
30
+ * then has a point at `+∞`, one per threshold (descending) and one at `−∞`.
31
+ * `null` or absent: every distinct forecast value (the empirical curve).
32
+ */
33
+ readonly thresholds?: ArrayLike<number> | null;
34
+ };
35
+ /**
36
+ * The ROC curve of probability forecasts against binary outcomes (Mason 1982):
37
+ * the hit rate against the false alarm rate of every threshold rule, at each
38
+ * distinct forecast value, and the area under it. It measures discrimination
39
+ * alone, blind to calibration; pair it with a {@link reliabilityDiagram}.
40
+ *
41
+ * With `thresholds`, the curve has only the rules a user can act on (the
42
+ * probabilities `k/m` an `m`-member ensemble can issue, or a few warning
43
+ * levels): its area, closed to `(1, 1)` by a last point at threshold `−∞`, is
44
+ * then the trapezoidal area of those points, below the empirical one.
45
+ *
46
+ * O(n log n + t) time, O(n + t) memory.
47
+ *
48
+ * @param probabilities The forecast probabilities, in `[0, 1]`.
49
+ * @param outcomes The binary outcomes, `0` or `1`.
50
+ * @param options Case weights and decision thresholds.
51
+ * @returns The curve; its rates are `NaN` without events (hit rate) or
52
+ * non-events (false alarm rate).
53
+ * @throws {RangeError} When the lengths differ, a probability lies outside `[0,
54
+ * 1]`, an outcome is not `0` or `1`, the weights are invalid, or a threshold
55
+ * is `NaN` or repeated.
56
+ */
57
+ export declare function rocCurve(probabilities: ArrayLike<number>, outcomes: ArrayLike<number>, options?: RocCurveOptions): RocCurve;
58
+ //# sourceMappingURL=roc-curve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roc-curve.d.ts","sourceRoot":"","sources":["../../src/forecast/roc-curve.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC;IAClC,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,0EAA0E;IAC1E,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC;IACtC;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,mCAAmC;AACnC,MAAM,MAAM,eAAe,GAAG,sBAAsB,GAAG;IACtD;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CAC/C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,QAAQ,CACvB,aAAa,EAAE,SAAS,CAAC,MAAM,CAAC,EAChC,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,EAC3B,OAAO,CAAC,EAAE,eAAe,GACvB,QAAQ,CA4HV"}
@@ -0,0 +1,124 @@
1
+ import { describeValue } from "@ac-kit/core";
2
+ import { assertBinary_, assertProbabilities_, assertSameLength_, weightTotal_, } from "./_forecast-checks.js";
3
+ /**
4
+ * The ROC curve of probability forecasts against binary outcomes (Mason 1982):
5
+ * the hit rate against the false alarm rate of every threshold rule, at each
6
+ * distinct forecast value, and the area under it. It measures discrimination
7
+ * alone, blind to calibration; pair it with a {@link reliabilityDiagram}.
8
+ *
9
+ * With `thresholds`, the curve has only the rules a user can act on (the
10
+ * probabilities `k/m` an `m`-member ensemble can issue, or a few warning
11
+ * levels): its area, closed to `(1, 1)` by a last point at threshold `−∞`, is
12
+ * then the trapezoidal area of those points, below the empirical one.
13
+ *
14
+ * O(n log n + t) time, O(n + t) memory.
15
+ *
16
+ * @param probabilities The forecast probabilities, in `[0, 1]`.
17
+ * @param outcomes The binary outcomes, `0` or `1`.
18
+ * @param options Case weights and decision thresholds.
19
+ * @returns The curve; its rates are `NaN` without events (hit rate) or
20
+ * non-events (false alarm rate).
21
+ * @throws {RangeError} When the lengths differ, a probability lies outside `[0,
22
+ * 1]`, an outcome is not `0` or `1`, the weights are invalid, or a threshold
23
+ * is `NaN` or repeated.
24
+ */
25
+ export function rocCurve(probabilities, outcomes, options) {
26
+ const count = probabilities.length;
27
+ assertSameLength_("rocCurve", "probabilities", count, "outcomes", outcomes.length);
28
+ assertProbabilities_("rocCurve", probabilities);
29
+ assertBinary_("rocCurve", outcomes);
30
+ const weights = options?.weights ?? null;
31
+ weightTotal_("rocCurve", weights, count);
32
+ const order = new Uint32Array(count);
33
+ for (let index = 0; index < count; index++) {
34
+ order[index] = index;
35
+ }
36
+ order.sort((left, right) => probabilities[right] - probabilities[left]);
37
+ let events = 0;
38
+ let nonEvents = 0;
39
+ let distinct = 0;
40
+ for (let position = 0; position < count; position++) {
41
+ const index = order[position];
42
+ const weight = weights === null ? 1 : weights[index];
43
+ if (outcomes[index] === 1) {
44
+ events += weight;
45
+ }
46
+ else {
47
+ nonEvents += weight;
48
+ }
49
+ if (position === 0 ||
50
+ probabilities[index] !== probabilities[order[position - 1]]) {
51
+ distinct++;
52
+ }
53
+ }
54
+ const given = options?.thresholds ?? null;
55
+ let thresholds;
56
+ if (given === null) {
57
+ thresholds = new Float64Array(distinct + 1);
58
+ let point = 0;
59
+ for (let position = 0; position < count; position++) {
60
+ const index = order[position];
61
+ if (position === count - 1 ||
62
+ probabilities[order[position + 1]] !== probabilities[index]) {
63
+ thresholds[++point] = probabilities[index];
64
+ }
65
+ }
66
+ }
67
+ else {
68
+ thresholds = new Float64Array(given.length + 2);
69
+ thresholds.set(Float64Array.from(given).sort().reverse(), 1);
70
+ thresholds[given.length + 1] = Number.NEGATIVE_INFINITY;
71
+ for (let point = 1; point <= given.length; point++) {
72
+ const threshold = thresholds[point];
73
+ if (threshold !== threshold ||
74
+ (point > 1 && threshold === thresholds[point - 1])) {
75
+ throw new RangeError(`rocCurve: thresholds must be distinct and not NaN, got ${describeValue(threshold)}`);
76
+ }
77
+ }
78
+ }
79
+ thresholds[0] = Number.POSITIVE_INFINITY;
80
+ const points = thresholds.length;
81
+ const hitRate = new Float64Array(points);
82
+ const falseAlarmRate = new Float64Array(points);
83
+ let hits = 0;
84
+ let falseAlarms = 0;
85
+ let position = 0;
86
+ let area = 0;
87
+ // Rule j warns on every forecast at or above thresholds[j].
88
+ for (let point = 1; point < points; point++) {
89
+ const threshold = thresholds[point];
90
+ while (position < count) {
91
+ const index = order[position];
92
+ if (!(probabilities[index] >= threshold)) {
93
+ break;
94
+ }
95
+ const weight = weights === null ? 1 : weights[index];
96
+ if (outcomes[index] === 1) {
97
+ hits += weight;
98
+ }
99
+ else {
100
+ falseAlarms += weight;
101
+ }
102
+ position++;
103
+ }
104
+ hitRate[point] = hits / events;
105
+ falseAlarmRate[point] = falseAlarms / nonEvents;
106
+ area +=
107
+ (falseAlarmRate[point] - falseAlarmRate[point - 1]) *
108
+ 0.5 *
109
+ (hitRate[point] + hitRate[point - 1]);
110
+ }
111
+ if (!(events > 0)) {
112
+ hitRate.fill(Number.NaN);
113
+ }
114
+ if (!(nonEvents > 0)) {
115
+ falseAlarmRate.fill(Number.NaN);
116
+ }
117
+ return {
118
+ thresholds,
119
+ hitRate,
120
+ falseAlarmRate,
121
+ area: events > 0 && nonEvents > 0 ? area : Number.NaN,
122
+ };
123
+ }
124
+ //# sourceMappingURL=roc-curve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roc-curve.js","sourceRoot":"","sources":["../../src/forecast/roc-curve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EACN,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,GACZ,MAAM,uBAAuB,CAAC;AAsC/B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,QAAQ,CACvB,aAAgC,EAChC,QAA2B,EAC3B,OAAyB;IAEzB,MAAM,KAAK,GAAG,aAAa,CAAC,MAAM,CAAC;IAEnC,iBAAiB,CAChB,UAAU,EACV,eAAe,EACf,KAAK,EACL,UAAU,EACV,QAAQ,CAAC,MAAM,CACf,CAAC;IACF,oBAAoB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAChD,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACpC,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,IAAI,CAAC;IAEzC,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;IAErC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;QAC5C,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAE,GAAG,aAAa,CAAC,IAAI,CAAE,CAAC,CAAC;IAE1E,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB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G,CAAC,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG;KACrD,CAAC;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -4,15 +4,29 @@ export * from "./average.js";
4
4
  export * from "./bimodality-coefficient.js";
5
5
  export * from "./beta-distribution.js";
6
6
  export * from "./binomial-distribution.js";
7
+ export * from "./bootstrap.js";
8
+ export * from "./censored-logistic-distribution.js";
9
+ export * from "./censored-shifted-gamma-distribution.js";
7
10
  export * from "./chi-squared-distribution.js";
8
11
  export * from "./chi-squared-test.js";
9
12
  export * from "./combine-independent-estimates.js";
10
13
  export * from "./confidence-interval.js";
11
14
  export * from "./correlation.js";
15
+ export * from "./descriptive.js";
12
16
  export * from "./dispersion.js";
13
17
  export * from "./distribution.js";
14
18
  export * from "./exponential-distribution.js";
15
19
  export * from "./f-distribution.js";
20
+ export * from "./forecast/brier-score.js";
21
+ export * from "./forecast/crps-closed-form.js";
22
+ export * from "./forecast/crps-ensemble.js";
23
+ export * from "./forecast/emos.js";
24
+ export * from "./forecast/exceedance-probability.js";
25
+ export * from "./forecast/log-score.js";
26
+ export * from "./forecast/logistic-regression.js";
27
+ export * from "./forecast/rank-histogram.js";
28
+ export * from "./forecast/reliability-diagram.js";
29
+ export * from "./forecast/roc-curve.js";
16
30
  export * from "./gamma-distribution.js";
17
31
  export * from "./geometric-distribution.js";
18
32
  export * from "./hartigan-dip.js";
@@ -23,25 +37,32 @@ export * from "./hypergeometric-distribution.js";
23
37
  export * from "./kmeans.js";
24
38
  export * from "./kmedoids.js";
25
39
  export * from "./log-normal-distribution.js";
40
+ export * from "./mann-whitney-u.js";
41
+ export * from "./multiple-regression.js";
26
42
  export * from "./negative-binomial-distribution.js";
27
43
  export * from "./normal-distribution.js";
28
44
  export * from "./normal-quantile.js";
29
45
  export * from "./one-way-anova.js";
30
46
  export * from "./outliers.js";
31
47
  export * from "./poisson-distribution.js";
48
+ export * from "./principal-components.js";
32
49
  export * from "./quantile.js";
33
50
  export * from "./random-effects.js";
34
51
  export * from "./regression.js";
35
52
  export * from "./running-statistics.js";
53
+ export * from "./sample.js";
36
54
  export * from "./satterthwaite-degrees-of-freedom.js";
37
55
  export * from "./sliding-median.js";
38
56
  export * from "./student-t-distribution.js";
39
57
  export * from "./sum.js";
58
+ export * from "./t-digest.js";
40
59
  export * from "./t-test.js";
41
60
  export * from "./trend.js";
61
+ export * from "./truncated-normal-distribution.js";
42
62
  export * from "./two-cluster-split.js";
43
63
  export * from "./uncertainty.js";
44
64
  export * from "./uniform-distribution.js";
45
65
  export * from "./variance-of-sample-median.js";
46
66
  export * from "./welch-t-statistic.js";
67
+ export * from "./wilcoxon-signed-rank.js";
47
68
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kCAAkC,CAAC;AACjD,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;A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bimodality-coefficient.js";
5
5
  export * from "./beta-distribution.js";
6
6
  export * from "./binomial-distribution.js";
7
+ export * from "./bootstrap.js";
8
+ export * from "./censored-logistic-distribution.js";
9
+ export * from "./censored-shifted-gamma-distribution.js";
7
10
  export * from "./chi-squared-distribution.js";
8
11
  export * from "./chi-squared-test.js";
9
12
  export * from "./combine-independent-estimates.js";
10
13
  export * from "./confidence-interval.js";
11
14
  export * from "./correlation.js";
15
+ export * from "./descriptive.js";
12
16
  export * from "./dispersion.js";
13
17
  export * from "./distribution.js";
14
18
  export * from "./exponential-distribution.js";
15
19
  export * from "./f-distribution.js";
20
+ export * from "./forecast/brier-score.js";
21
+ export * from "./forecast/crps-closed-form.js";
22
+ export * from "./forecast/crps-ensemble.js";
23
+ export * from "./forecast/emos.js";
24
+ export * from "./forecast/exceedance-probability.js";
25
+ export * from "./forecast/log-score.js";
26
+ export * from "./forecast/logistic-regression.js";
27
+ export * from "./forecast/rank-histogram.js";
28
+ export * from "./forecast/reliability-diagram.js";
29
+ export * from "./forecast/roc-curve.js";
16
30
  export * from "./gamma-distribution.js";
17
31
  export * from "./geometric-distribution.js";
18
32
  export * from "./hartigan-dip.js";
@@ -23,25 +37,32 @@ export * from "./hypergeometric-distribution.js";
23
37
  export * from "./kmeans.js";
24
38
  export * from "./kmedoids.js";
25
39
  export * from "./log-normal-distribution.js";
40
+ export * from "./mann-whitney-u.js";
41
+ export * from "./multiple-regression.js";
26
42
  export * from "./negative-binomial-distribution.js";
27
43
  export * from "./normal-distribution.js";
28
44
  export * from "./normal-quantile.js";
29
45
  export * from "./one-way-anova.js";
30
46
  export * from "./outliers.js";
31
47
  export * from "./poisson-distribution.js";
48
+ export * from "./principal-components.js";
32
49
  export * from "./quantile.js";
33
50
  export * from "./random-effects.js";
34
51
  export * from "./regression.js";
35
52
  export * from "./running-statistics.js";
53
+ export * from "./sample.js";
36
54
  export * from "./satterthwaite-degrees-of-freedom.js";
37
55
  export * from "./sliding-median.js";
38
56
  export * from "./student-t-distribution.js";
39
57
  export * from "./sum.js";
58
+ export * from "./t-digest.js";
40
59
  export * from "./t-test.js";
41
60
  export * from "./trend.js";
61
+ export * from "./truncated-normal-distribution.js";
42
62
  export * from "./two-cluster-split.js";
43
63
  export * from "./uncertainty.js";
44
64
  export * from "./uniform-distribution.js";
45
65
  export * from "./variance-of-sample-median.js";
46
66
  export * from "./welch-t-statistic.js";
67
+ export * from "./wilcoxon-signed-rank.js";
47
68
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kCAAkC,CAAC;AACjD,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qCAAqC,CAAC;AACpD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc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Ac,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kCAAkC,CAAC;AACjD,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qCAAqC,CAAC;AACpD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,uCAAuC,CAAC;AACtD,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { type RankTestOptions, type RankTestResult } from "./_rank-test.js";
2
+ export type { RankTestMethod, RankTestOptions, RankTestResult, } from "./_rank-test.js";
3
+ /**
4
+ * The Mann–Whitney U test (Wilcoxon's rank-sum test, the same test under its
5
+ * other name — `jStat` and `simple-statistics` call it `wilcoxonRankSum`): do
6
+ * values of `a` tend to be larger or smaller than values of `b`, with no
7
+ * assumption on the shape of their distributions? The non-parametric
8
+ * counterpart of the two-sample `tTest`.
9
+ *
10
+ * The statistic is `U = R₁ − n₁(n₁ + 1)/2`, `R₁` the sum of the ranks of `a` in
11
+ * the pooled sample (ties averaged): the number of pairs `(aᵢ, bⱼ)` with `aᵢ >
12
+ * bⱼ`, ties counting one half. It is SciPy's `mannwhitneyu` statistic and R's
13
+ * `wilcox.test` `W`; `U` for `b` is `n₁·n₂ − U`. `"greater"` tests whether `a`
14
+ * is stochastically larger.
15
+ *
16
+ * The exact p-value is that of the permutation distribution of `R₁` given the
17
+ * pooled ranks, exact with ties too; the asymptotic one uses the variance
18
+ * `n₁n₂/12 · ((n + 1) − Σ(t³ − t)/(n(n − 1)))`. See `RankTestMethod`.
19
+ *
20
+ * @param a The first sample. Not modified.
21
+ * @param b The second sample. Not modified.
22
+ * @param options The alternative, method and continuity correction.
23
+ * @returns `U` for `a`, its z-score and the p-value.
24
+ * @throws {RangeError} When a sample is empty or holds `NaN`.
25
+ */
26
+ export declare function mannWhitneyU(a: readonly number[], b: readonly number[], options?: RankTestOptions): RankTestResult;
27
+ //# sourceMappingURL=mann-whitney-u.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mann-whitney-u.d.ts","sourceRoot":"","sources":["../src/mann-whitney-u.ts"],"names":[],"mappings":"AAEA,OAAO,EAKN,KAAK,eAAe,EACpB,KAAK,cAAc,EAGnB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACX,cAAc,EACd,eAAe,EACf,cAAc,GACd,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAC3B,CAAC,EAAE,SAAS,MAAM,EAAE,EACpB,CAAC,EAAE,SAAS,MAAM,EAAE,EACpB,OAAO,CAAC,EAAE,eAAe,GACvB,cAAc,CAwFhB"}
@@ -0,0 +1,94 @@
1
+ import { rankBy } from "@ac-kit/algo";
2
+ import { assertRankTestSample_, exactPValue_, normalPValue_, RANK_TEST_EXACT_LIMIT_, rankTestZ_, subsetSumDistribution_, } from "./_rank-test.js";
3
+ /**
4
+ * The Mann–Whitney U test (Wilcoxon's rank-sum test, the same test under its
5
+ * other name — `jStat` and `simple-statistics` call it `wilcoxonRankSum`): do
6
+ * values of `a` tend to be larger or smaller than values of `b`, with no
7
+ * assumption on the shape of their distributions? The non-parametric
8
+ * counterpart of the two-sample `tTest`.
9
+ *
10
+ * The statistic is `U = R₁ − n₁(n₁ + 1)/2`, `R₁` the sum of the ranks of `a` in
11
+ * the pooled sample (ties averaged): the number of pairs `(aᵢ, bⱼ)` with `aᵢ >
12
+ * bⱼ`, ties counting one half. It is SciPy's `mannwhitneyu` statistic and R's
13
+ * `wilcox.test` `W`; `U` for `b` is `n₁·n₂ − U`. `"greater"` tests whether `a`
14
+ * is stochastically larger.
15
+ *
16
+ * The exact p-value is that of the permutation distribution of `R₁` given the
17
+ * pooled ranks, exact with ties too; the asymptotic one uses the variance
18
+ * `n₁n₂/12 · ((n + 1) − Σ(t³ − t)/(n(n − 1)))`. See `RankTestMethod`.
19
+ *
20
+ * @param a The first sample. Not modified.
21
+ * @param b The second sample. Not modified.
22
+ * @param options The alternative, method and continuity correction.
23
+ * @returns `U` for `a`, its z-score and the p-value.
24
+ * @throws {RangeError} When a sample is empty or holds `NaN`.
25
+ */
26
+ export function mannWhitneyU(a, b, options) {
27
+ const sizeA = a.length;
28
+ const sizeB = b.length;
29
+ if (sizeA === 0 || sizeB === 0) {
30
+ throw new RangeError("mannWhitneyU: both samples must be non-empty");
31
+ }
32
+ assertRankTestSample_(a, "a", "mannWhitneyU");
33
+ assertRankTestSample_(b, "b", "mannWhitneyU");
34
+ const alternative = options?.alternative ?? "two-sided";
35
+ const requested = options?.method ?? "auto";
36
+ const count = sizeA + sizeB;
37
+ const pooled = [...a, ...b];
38
+ const ranks = rankBy(pooled, (value) => value);
39
+ // Doubled ranks are integers, the weights of the exact distribution.
40
+ const doubled = new Float64Array(count);
41
+ let doubledSumA = 0;
42
+ for (let index = 0; index < count; index++) {
43
+ doubled[index] = 2 * ranks[index];
44
+ if (index < sizeA) {
45
+ doubledSumA += doubled[index];
46
+ }
47
+ }
48
+ const statistic = doubledSumA / 2 - (sizeA * (sizeA + 1)) / 2;
49
+ let tieTerm = 0;
50
+ const sortedRanks = Float64Array.from(ranks).sort();
51
+ let run = 1;
52
+ for (let index = 1; index <= count; index++) {
53
+ if (index < count && sortedRanks[index] === sortedRanks[index - 1]) {
54
+ run++;
55
+ }
56
+ else {
57
+ tieTerm += run * run * run - run;
58
+ run = 1;
59
+ }
60
+ }
61
+ const deviation = Math.sqrt(((sizeA * sizeB) / 12) * (count + 1 - tieTerm / (count * (count - 1))));
62
+ const zScore = rankTestZ_(statistic, (sizeA * sizeB) / 2, deviation, alternative, options?.continuity ?? true);
63
+ const method = requested === "auto"
64
+ ? sizeA < RANK_TEST_EXACT_LIMIT_ && sizeB < RANK_TEST_EXACT_LIMIT_
65
+ ? "exact"
66
+ : "asymptotic"
67
+ : requested;
68
+ if (method === "exact") {
69
+ // Over the smaller sample's subsets, then mirrored for the other one.
70
+ const smallerIsA = sizeA <= sizeB;
71
+ const distribution = subsetSumDistribution_(doubled, smallerIsA ? sizeA : sizeB);
72
+ const observed = smallerIsA
73
+ ? doubledSumA
74
+ : count * (count + 1) - doubledSumA;
75
+ const mirrored = alternative === "greater"
76
+ ? "less"
77
+ : alternative === "less"
78
+ ? "greater"
79
+ : alternative;
80
+ return {
81
+ statistic,
82
+ zScore,
83
+ pValue: exactPValue_(distribution, observed, smallerIsA ? alternative : mirrored),
84
+ method,
85
+ };
86
+ }
87
+ return {
88
+ statistic,
89
+ zScore,
90
+ pValue: normalPValue_(zScore, alternative),
91
+ method,
92
+ };
93
+ }
94
+ //# sourceMappingURL=mann-whitney-u.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mann-whitney-u.js","sourceRoot":"","sources":["../src/mann-whitney-u.ts"],"names":[],"m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