peeksafe 0.0.0-stage → 0.1.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 (66) hide show
  1. package/CHANGELOG.md +146 -0
  2. package/LICENSE +190 -0
  3. package/NOTICE +78 -0
  4. package/README.md +492 -2
  5. package/RESEARCH-NOTES.md +274 -0
  6. package/dist/baseline.d.ts +45 -0
  7. package/dist/baseline.d.ts.map +1 -0
  8. package/dist/baseline.js +49 -0
  9. package/dist/baseline.js.map +1 -0
  10. package/dist/check.d.ts +64 -0
  11. package/dist/check.d.ts.map +1 -0
  12. package/dist/check.js +172 -0
  13. package/dist/check.js.map +1 -0
  14. package/dist/cluster.d.ts +328 -0
  15. package/dist/cluster.d.ts.map +1 -0
  16. package/dist/cluster.js +598 -0
  17. package/dist/cluster.js.map +1 -0
  18. package/dist/errors.d.ts +87 -0
  19. package/dist/errors.d.ts.map +1 -0
  20. package/dist/errors.js +143 -0
  21. package/dist/errors.js.map +1 -0
  22. package/dist/evidence.d.ts +15 -0
  23. package/dist/evidence.d.ts.map +1 -0
  24. package/dist/evidence.js +30 -0
  25. package/dist/evidence.js.map +1 -0
  26. package/dist/frontier.d.ts +269 -0
  27. package/dist/frontier.d.ts.map +1 -0
  28. package/dist/frontier.js +460 -0
  29. package/dist/frontier.js.map +1 -0
  30. package/dist/gate.d.ts +173 -0
  31. package/dist/gate.d.ts.map +1 -0
  32. package/dist/gate.js +196 -0
  33. package/dist/gate.js.map +1 -0
  34. package/dist/index.d.ts +60 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +79 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/plan.d.ts +248 -0
  39. package/dist/plan.d.ts.map +1 -0
  40. package/dist/plan.js +482 -0
  41. package/dist/plan.js.map +1 -0
  42. package/dist/rand.d.ts +17 -0
  43. package/dist/rand.d.ts.map +1 -0
  44. package/dist/rand.js +92 -0
  45. package/dist/rand.js.map +1 -0
  46. package/dist/stats.d.ts +397 -0
  47. package/dist/stats.d.ts.map +1 -0
  48. package/dist/stats.js +1245 -0
  49. package/dist/stats.js.map +1 -0
  50. package/dist/stop.d.ts +163 -0
  51. package/dist/stop.d.ts.map +1 -0
  52. package/dist/stop.js +262 -0
  53. package/dist/stop.js.map +1 -0
  54. package/package.json +64 -4
  55. package/src/baseline.ts +72 -0
  56. package/src/check.ts +238 -0
  57. package/src/cluster.ts +830 -0
  58. package/src/errors.ts +208 -0
  59. package/src/evidence.ts +62 -0
  60. package/src/frontier.ts +782 -0
  61. package/src/gate.ts +358 -0
  62. package/src/index.ts +206 -0
  63. package/src/plan.ts +778 -0
  64. package/src/rand.ts +121 -0
  65. package/src/stats.ts +1579 -0
  66. package/src/stop.ts +452 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,146 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project uses
5
+ [semantic versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## Unreleased
8
+
9
+ ## 0.1.0 (2026-10-20)
10
+
11
+ First release. There is no earlier version to compare against, so this section
12
+ describes what the package contains rather than what changed.
13
+
14
+ ### Added
15
+
16
+ - `gate()`, the decision: given per-case candidate and baseline counts, which
17
+ cases regressed, at a false discovery rate you name. Valid at any stopping
18
+ time, so it does not matter when or why you stopped a case.
19
+ - `shouldStop(observed, baseline, options)`: the per-case stopping decision, returning
20
+ `regressed` | `settled` | `futile` | `impossible` | `budget` | `continue` with the evidence
21
+ behind it. This is the loop every caller was writing by hand. `futilityConfidence` is any
22
+ value strictly between 0 and 1.
23
+ - Paired cases in `gate`: a case may carry `paired: { bothPass, worse, better, bothFail }` instead
24
+ of candidate counts and a stored baseline, and is decided by `pairedLogE` in the same e-BH family
25
+ as the unpaired cases. Its null is exact, so it has no ceiling and is valid at every rate by
26
+ construction. The runs need not share a seed: independent runs paired in order are still valid.
27
+ Within 200 pairs, a 10-case suite at 75% losing 15 points is certified 43.5% of the time with
28
+ independent runs and 74.5% with half the pairs seeded, against 50.2% for the default statistic
29
+ with a 240-run stored baseline and 22.3% for `universal`.
30
+ - `shouldStopPaired(counts, options)`: `shouldStop` for a paired case. `settled` comes from an
31
+ e-value against "dropped by at least `mde`", so a case that really dropped that far is settled
32
+ with probability at most `1 - futilityConfidence` however often you ask.
33
+ - `pairedCertifyProbability(options)`: the exact power and type I error of a paired case, at
34
+ separate baseline and candidate rates and a `coupling` for shared seeds.
35
+ - `universalTwoSampleLogE` and `evidence: 'universal'` on `gate`, `shouldStop`, `typeOneError` and
36
+ `certifyProbability`: a two-sample e-value valid at every rate by construction, for anyone who
37
+ wants a proof rather than a computation. It needs roughly four times the baseline runs to match
38
+ the default's power, so the default stays. `universalCeilingLogE` bounds it for `shouldStop`.
39
+ - `certifyProbability(options)`: the exact probability a case is certified at separate baseline
40
+ and candidate rates, which is the power when the candidate is lower.
41
+ - `typeOneError(options)`: the exact probability that a case which did not move is ever
42
+ certified, at a rate, baseline size and bar you name. The README's error-control grid is built
43
+ on it, and it is what to run when your suite sits outside that grid.
44
+ - `GateResult.headline`: one line an operator can read, naming the two things a PASS can hide
45
+ (cases with no baseline, and cases whose baseline is too thin to certify an `mde`-sized drop).
46
+ - Planning: `makePlan`, `planCase`, `affordabilityGrid` answer how many runs a
47
+ suite needs before anything is spent, including the two ways the answer can be
48
+ "no budget does this". An effect larger than the rate is arithmetically
49
+ impossible; an effect under the evidence ceiling is impossible at any
50
+ *candidate* budget and needs more baseline runs instead.
51
+ - The frontier: `computeFrontier` and `enumerateFrontier`, what is certifiable
52
+ inside a budget.
53
+ - The statistical core, exported so callers can check the arithmetic or build a
54
+ different gate: special functions, intervals, the SPRT, two-sample and paired
55
+ e-values, e-BH, power, and the evidence ceiling with its closed form.
56
+ - Cluster-robust suite inference (`clusteredEffect`, CR2 with small-cluster
57
+ degrees of freedom, a random-effects cross-check, and a diagnostic for a
58
+ grouping key that collapses the suite).
59
+ - `RESEARCH-NOTES.md`, a literature check on what in this work is novel and what
60
+ is not. Two of the four claims the prototype made turned out to be documented
61
+ elsewhere, and the prose says so.
62
+ - `PlanCase.design`: the design to run each case with, the one of unpaired and paired that
63
+ decides it within `runsPerCaseCeiling` in fewer runs (unpaired on a tie), or `null` when neither
64
+ does. `PlanCase.pairCoupling` is the coupling its paired figures were priced at.
65
+ - `makePlan(cases, baseline, cfg, pilots)`: an optional map of per-case pilot pair tables. A case
66
+ with one is priced at its measured `pairPhi` (floored at 0) instead of `cfg.pairCoupling`; an
67
+ empty table is ignored. In the README example a case at 75% on a 240-run baseline pairs at the
68
+ assumed 0.9 (118 runs against 164) and stays unpaired at a measured 0.6 (206 runs).
69
+
70
+ ### Notes
71
+
72
+ - Zero runtime dependencies, verified in CI against a packed tarball rather than
73
+ against `package.json`.
74
+ - The package ships `src/` next to `dist/`, so the source and declaration maps resolve and
75
+ go-to-definition lands on the TypeScript rather than on compiled output.
76
+ - Extracted from an internal prototype and reduced to the statistical core. The
77
+ runner, graders, store, CI adapters and CLI were deliberately left behind:
78
+ this library takes counts and returns statistics, and has no opinion about how
79
+ you run evals.
80
+ - The default two-sample e-value has mean exactly 1 averaged over the shared rate, not at every
81
+ fixed rate, so its error control is computed rather than inferred. `test/error-control.test.ts`
82
+ computes the type I error exactly over a grid of baselines, rates and `mde`, and runs
83
+ `shouldStop` and `gate` end to end on simulated suites. At the defaults the worst cell found is
84
+ 0.75 of alpha. `gate` and `shouldStop` refuse an `altConcentration` above 16
85
+ (`MAX_ALT_CONCENTRATION`, exported) with the default statistic, with `PEEKSAFE_E_CONFIG`, because a
86
+ concentrated alternative is the one known way it exceeds alpha inside the checked range: 1.04
87
+ times alpha at 32. At 16 the worst checked cell is 0.91 of alpha. `universal` takes any positive
88
+ value, and `typeOneError` and `certifyProbability` still compute any concentration, so a corner
89
+ can be inspected.
90
+ - The alternative's Beta shapes are floored at 1 rather than anywhere below it, because a shape
91
+ under 1 piles the alternative's mass onto a rate of zero, which is where a thin baseline at a
92
+ very low rate already sits. That corner is the one that costs the most error: a 30-run baseline
93
+ at 0.5% with `mde` 0.05, and an `altConcentration` of 2 with a 5-run baseline, are both under a
94
+ tenth of alpha, pinned in `test/error-control.test.ts`.
95
+ - `settled` is the part an e-value cannot give you on its own: a healthy case never accumulates
96
+ evidence that it is healthy, so it would run to your cap forever. The evidence ceiling stops it
97
+ once the counts have ruled out a certifiable drop.
98
+ - `futile` is kept separate from `settled` because they call for opposite actions: a thin baseline
99
+ is a defect to fix, a settled case is a pass.
100
+ - Futility is judged at the most pessimistic rate the counts still permit, not at the point
101
+ estimate, so it fires late and cannot abandon a case that was about to be certified. A
102
+ catastrophic regression is never stopped early at any sample size.
103
+ - An improvement is never certified as a regression. The Bayes factor behind `twoSampleLogE` has a
104
+ wider alternative than null, so on its own it also grows for a candidate far above its baseline:
105
+ 96/96 against 30/60 scores e^19.5 uncapped. The statistic is therefore capped at 1 whenever the
106
+ candidate's observed rate is at or above the baseline's, and `test/error-control.test.ts` checks
107
+ improved candidates stay under alpha. `pairedLogE` has the same property from a proof rather than
108
+ a cap: its alternative is truncated to "worse more often than not", which makes it an e-value for
109
+ every candidate that did not get worse. `test/paired.test.ts` computes it exactly.
110
+ - A case whose baseline passes at or below `mde` cannot drop by `mde` at all, so `gate` marks it
111
+ `impossible` and does not test it, `makePlan` reports it the same way, and `shouldStop` stops it
112
+ at once with the reason `impossible`. Testing such a case would mean testing it against an
113
+ alternative clamped onto a rate near zero, where the case already sits, and a type I error above
114
+ the nominal level.
115
+ - `PeeksafeErrorCode` lists only the five codes the library throws, and `test/exports.test.ts`
116
+ fails if a code is listed that no source file throws. Refusals are consistent across entry
117
+ points: a duplicate case id is `PEEKSAFE_E_CASE_DUPLICATE` from `toBaselineMap` as well as from
118
+ `gate`, a non-positive `altConcentration` is `PEEKSAFE_E_CONFIG` from `certifyProbability` and
119
+ `typeOneError` as well as from `gate` and `shouldStop`, and `costShares` refuses a `basis` it
120
+ does not recognise rather than quoting one it does. An omitted `basis` is `typical`.
121
+ - A reported `evalue` is clamped to `Number.MAX_VALUE`, because `exp()` of a log e-value past about
122
+ 709 overflows and a strong regression goes well past that: 0/1000 against 990/1000 has a log
123
+ e-value near 1291. `gate` and `shouldStop` both report it through the same clamp, and no decision
124
+ depends on the number.
125
+ - `PlanCase.baselineRunsNeeded` scans for the smallest baseline that clears the bar rather than
126
+ bisecting for one, because the evidence ceiling is not monotone in the baseline size: holding the
127
+ rate fixed still forces an integer success count, so a larger baseline can carry less evidence
128
+ than a smaller one and a bisection returns whichever crossing it happened to bracket.
129
+ `test/budget.test.ts` checks the answer against a scan over a grid of baselines and effects.
130
+ - The expected-cost half of the planner is Wald's approximation, and it errs low. `sprtExpectedN`
131
+ evaluates the operating characteristic exactly, `(1 - B^h) / (A^h - B^h)` at the tilt `h` solving
132
+ `E_p[lambda^h] = 1`, which is `-1` at `p1` and `+1` at `p0` and so agrees with both hypotheses,
133
+ with the limit `-log A * log B / E_p[(log lambda)^2]` taken where the drift vanishes. The
134
+ expected sample number built on it still treats the test as stopping exactly on a wall where a
135
+ real one overshoots it, so it under-states the true expected sample number and every cost built
136
+ on it. No decision depends on this: it is the pricing half of the planner, not the gate.
137
+ - `randomEffectsMean` reports the grand mean with a standard error of 0 and a zero-width interval
138
+ on a suite where every case moved by the same amount, which is what a pull request that moved
139
+ nothing produces, and what `clusterRobustMean` and `iidMean` already answer for the same data.
140
+ `compareEstimators` then reads a ratio of 1 and reports that the two estimators agree.
141
+ - `makePlan`, `affordabilityGrid` and `computeFrontier` refuse error rates with `alpha + beta >= 1`
142
+ with `PEEKSAFE_E_CONFIG`, because the sequential test decides before it sees a run there and
143
+ every case would be priced at `minTrials`. `PlanCase.fixedNPerArm` prices the fixed-N comparator
144
+ at the plan's own `alpha` and `beta`; the defaults are 0.05 and 0.1.
145
+ - `probabilityMoved` refuses an `mde` outside (0, 1) and a `nodes` that is not a positive integer
146
+ with `PEEKSAFE_E_STAT_DOMAIN`.
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Alexis Rico
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,78 @@
1
+ peeksafe
2
+ Copyright 2026 Alexis Rico
3
+
4
+ Licensed under the Apache License, Version 2.0. See LICENSE.
5
+
6
+ --------------------------------------------------------------------------------
7
+ Third-party code
8
+ --------------------------------------------------------------------------------
9
+
10
+ None. peeksafe has zero runtime dependencies, vendors no source, and ships no
11
+ code it did not write. `.github/workflows/ci.yml` asserts the first of those on
12
+ every pull request by packing the tarball, installing it into an empty project,
13
+ and failing if `pnpm ls` resolves more than two packages.
14
+
15
+ Development dependencies (the devDependencies in package.json) are not
16
+ redistributed and are not part of the published package.
17
+
18
+ --------------------------------------------------------------------------------
19
+ Algorithms and published constants
20
+ --------------------------------------------------------------------------------
21
+
22
+ Everything statistical here is implemented from published closed forms and
23
+ recurrences rather than ported from an existing implementation. Mathematical
24
+ methods and tabulated constants are not anybody's intellectual property, but
25
+ naming their sources is both good manners and the fastest way for a reader to
26
+ check the arithmetic.
27
+
28
+ Regularized incomplete beta Continued fraction: Abramowitz & Stegun,
29
+ src/stats.ts Handbook of Mathematical Functions, 26.5.8.
30
+ Evaluated by the modified Lentz algorithm:
31
+ Lentz (1976), amended by Thompson & Barnett
32
+ (1986).
33
+
34
+ log Γ(x) Lanczos approximation, g = 7, n = 9. The
35
+ src/stats.ts coefficient set is the widely reprinted one
36
+ originating with Lanczos (1964).
37
+
38
+ Φ⁻¹(p) Peter Acklam's algorithm for the inverse
39
+ src/stats.ts normal CDF, refined here by one Halley
40
+ step. Acklam released it for unrestricted
41
+ use.
42
+
43
+ Lower incomplete gamma Standard series and continued-fraction
44
+ src/stats.ts expansions, Abramowitz & Stegun 6.5.
45
+
46
+ Linear congruential generator Multiplier 1664525, increment 1013904223,
47
+ src/rand.ts modulus 2^32. Tabulated parameters from
48
+ Knuth, The Art of Computer Programming,
49
+ volume 2.
50
+
51
+ 32-bit avalanche (mix32) The `lowbias32` multipliers from Chris
52
+ src/rand.ts Wellons' hash function prospector, placed
53
+ by the author in the public domain.
54
+
55
+ hash32 FNV-1a. Public domain by the authors'
56
+ src/rand.ts explicit statement.
57
+
58
+ --------------------------------------------------------------------------------
59
+ Statistical methods
60
+ --------------------------------------------------------------------------------
61
+
62
+ The procedures peeksafe implements are established results. README.md is
63
+ explicit about which of this library's claims are new and which are not, and
64
+ RESEARCH-NOTES.md records an adversarial literature check that withdrew two of
65
+ four originally-claimed novelties.
66
+
67
+ e-values and testing by betting Shafer; Grünwald, de Heide & Koolen (Safe
68
+ Testing); Waudby-Smith & Ramdas.
69
+ e-BH Wang & Ramdas, False discovery rate control
70
+ with e-values (2022).
71
+ Stopped e-BH Wang, Dandapanthula & Ramdas (2025).
72
+ Benjamini-Hochberg Benjamini & Hochberg (1995).
73
+ Sequential probability ratio Wald, Sequential Analysis (1945).
74
+ McNemar's test McNemar (1947).
75
+ Cluster-robust variance (CR2) Liang & Zeger (1986); Bell & McCaffrey
76
+ (2002).
77
+ Bayes factor asymptotics Kass & Raftery (1995).
78
+ Spectrum bias Ransohoff & Feinstein (1978).