@mark1russell7/rigor-statistics 0.1.14 → 0.1.16
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/README.md +2 -1
- package/build/index.d.ts +19 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +28 -3
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -106,7 +106,8 @@ The default expansion has one product for each pair of levels of two dimensions.
|
|
|
106
106
|
| --- | --- |
|
|
107
107
|
| `mean`, `sd`, `median`, `summarize` | The descriptive statistics. `sd` is the sample standard deviation. |
|
|
108
108
|
| `quantile(values, p, method)`, `quantileSorted` | The `p` quantile, with the `"linear"` method (type 7, the default), the `"nearest-rank"` method (type 1) or the `"higher"` method (`sorted[Math.ceil(p * (n - 1))]`, as NumPy). |
|
|
109
|
-
| `bootstrap(data, statistic, options)` | A percentile bootstrap interval of any statistic. The options are `runs`, `level` or `ends`, `seed` and `
|
|
109
|
+
| `bootstrap(data, statistic, options)` | A percentile bootstrap interval of any statistic. The options are `runs`, `level` or `ends`, `seed`, `method` and `against`. |
|
|
110
|
+
| The option `against` | The interval also gives `pAbove` and `pBelow`, the bootstrap p of each side of the value, from the same draws. The smallest p is 1 / (`finite` + 1). Give `holm` enough runs: with m tests at level a, `runs` is more than m / a. |
|
|
110
111
|
| `bootstrapMedian`, `bootstrapClusters` | The interval of the median, and a bootstrap that draws whole clusters (boards, seeds, sites). |
|
|
111
112
|
| `bootstrapTwo(a, b, statistic, options)` | A bootstrap interval of a statistic of two independent samples, for example two arms of a benchmark. Each run draws all of `a`, then all of `b`. |
|
|
112
113
|
| `bootstrapMedianRatio(numerator, denominator, options)` | The interval of `median(numerator) / median(denominator)`. It is the uncertainty of the ratio, not the spread of the samples. |
|
package/build/index.d.ts
CHANGED
|
@@ -93,8 +93,22 @@ interface BootstrapOptions {
|
|
|
93
93
|
* not 0.025, so a copy that writes 0.025 needs this option to give the same numbers.
|
|
94
94
|
*/
|
|
95
95
|
readonly ends?: readonly [number, number];
|
|
96
|
+
/**
|
|
97
|
+
* The value of a claim to test, for example 0 for "no difference". With this option, the interval also gives `pAbove`
|
|
98
|
+
* and `pBelow` from the same draws, so the ends do not change. The default is no value and no p.
|
|
99
|
+
*/
|
|
100
|
+
readonly against?: number;
|
|
101
|
+
}
|
|
102
|
+
/** The two bootstrap p of the option `against`. The smallest p is 1 / (finite + 1), so a family correction needs enough runs. */
|
|
103
|
+
interface SideP {
|
|
104
|
+
/** The value of the option `against`. */
|
|
105
|
+
readonly against: number;
|
|
106
|
+
/** The p of the claim "the statistic is above `against`": (1 + the finite runs at or below `against`) / (finite + 1). */
|
|
107
|
+
readonly pAbove: number;
|
|
108
|
+
/** The p of the claim "the statistic is below `against`": (1 + the finite runs at or above `against`) / (finite + 1). */
|
|
109
|
+
readonly pBelow: number;
|
|
96
110
|
}
|
|
97
|
-
interface Interval {
|
|
111
|
+
interface Interval extends Partial<SideP> {
|
|
98
112
|
/** The statistic of all the data. */
|
|
99
113
|
readonly estimate: number;
|
|
100
114
|
readonly low: number;
|
|
@@ -1024,11 +1038,14 @@ interface OptionFloorOptions {
|
|
|
1024
1038
|
* with `df = 2 n - 2`. The count is on both sides of that form, so the function takes the first count that meets it.
|
|
1025
1039
|
*
|
|
1026
1040
|
* The function assumes independent values, unpaired groups of equal size, equal `sigma`, and a Bonferroni family.
|
|
1041
|
+
* Holm gives each test a level of `alpha / tests` or more. Thus for a Holm family the count is an upper bound, not the exact count.
|
|
1042
|
+
* The tests read the power by simulation: 2,000 draws at the floor for 1, 5 and 67 tests, from the fixed seeds `rigor-statistics/optionFloor/at/<tests>`.
|
|
1043
|
+
* Each read gives 0.78 or more, and one count below the floor gives less.
|
|
1027
1044
|
* A value of `sigma` from an older run gives a count for that run. Read `sigma` again on the new values.
|
|
1028
1045
|
*
|
|
1029
1046
|
* @param options - The spread, the difference, the family and the targets.
|
|
1030
1047
|
* @returns A whole number of 2 or more.
|
|
1031
1048
|
*/
|
|
1032
1049
|
export declare function optionFloor(options: OptionFloorOptions): number;
|
|
1033
|
-
export type { BootstrapOptions, CalibrationLevel, CategoricalDimension, CompareOptions, Comparison, ContinuousDimension, Corrected, CountInterval, Effect, Forecast, Interval, LeastSquaresFit, LeastSquaresOptions, MedianInterval, ModeOptions, NoiseOptions, NoiseState, NoiseVerdict, OptionFloorOptions, OrdinalDimension, ParsedResponseRecord, PermutationOptions, PermutationResult, Proportion, QuantileInterval, QuantileMethod, ResponseAbsentPoint, ResponseBand, ResponseCurvePoint, ResponseData, ResponseDimension, ResponseDimensionBase, ResponseFactor, ResponseFault, ResponseFitOptions, ResponseFold, ResponseFoldError, ResponseHeldOutError, ResponseInputValue, ResponseMeasure, ResponseModel, ResponseModelBase, ResponsePoint, ResponseReason, ResponseRecord, ResponseSlice, ResponseSliceOptions, ResponseSlicePoint, ResponseSurface, ResponseSurfaceAbsentPoint, ResponseSurfaceOptions, ResponseSurfacePoint, ResponseTableCell, ResponseValue, ResponseViewOptions, ResponseWhen, RidgeInput, RidgeInputBase, RidgeLevelInput, RidgeNumberInput, RidgeOptions, RidgeRankInput, RidgeResponseModel, RidgeTerm, SmoothLaw, SmoothLawScore, Summary, TableResponseModel, TwoSamplePermutationOptions, TwoSamplePermutationResult };
|
|
1050
|
+
export type { BootstrapOptions, CalibrationLevel, CategoricalDimension, CompareOptions, Comparison, ContinuousDimension, Corrected, CountInterval, Effect, Forecast, Interval, LeastSquaresFit, LeastSquaresOptions, MedianInterval, ModeOptions, NoiseOptions, NoiseState, NoiseVerdict, OptionFloorOptions, OrdinalDimension, ParsedResponseRecord, PermutationOptions, PermutationResult, Proportion, QuantileInterval, QuantileMethod, ResponseAbsentPoint, ResponseBand, ResponseCurvePoint, ResponseData, ResponseDimension, ResponseDimensionBase, ResponseFactor, ResponseFault, ResponseFitOptions, ResponseFold, ResponseFoldError, ResponseHeldOutError, ResponseInputValue, ResponseMeasure, ResponseModel, ResponseModelBase, ResponsePoint, ResponseReason, ResponseRecord, ResponseSlice, ResponseSliceOptions, ResponseSlicePoint, ResponseSurface, ResponseSurfaceAbsentPoint, ResponseSurfaceOptions, ResponseSurfacePoint, ResponseTableCell, ResponseValue, ResponseViewOptions, ResponseWhen, RidgeInput, RidgeInputBase, RidgeLevelInput, RidgeNumberInput, RidgeOptions, RidgeRankInput, RidgeResponseModel, RidgeTerm, SideP, SmoothLaw, SmoothLawScore, Summary, TableResponseModel, TwoSamplePermutationOptions, TwoSamplePermutationResult };
|
|
1034
1051
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/describe.ts","../src/regression.ts","../src/bootstrap.ts","../src/distribution.ts","../src/ridge.ts","../src/response.ts","../src/response-parse.ts","../src/response-fit.ts","../src/tests.ts","../src/rank.ts","../src/discrete.ts","../src/compare.ts","../src/power.ts"],"mappings":";;;;;;KAOY;;wBAmBI,OAAO;wBAIP,KAAK;;;;;wBAgBL,GAAG;;;;;;;wBAgBH,eAAe,iCAAiC,WAAW,SAAQ;;wBAkBnE,SAAS,2BAA2B,WAAW,SAAQ;;;;;wBASvD,OAAO;;UAQN;WACN;WACA;;WAEA;WACA;;WAEA;WACA;;WAEA;WACA;;WAEA;;wBAGK,UAAU,4BAA4B;;;;;;UC3GrC;;WAEN;;UAGM;;WAEN;;WAEA;;;;;WAKA;;WAEA;;WAEA;;;;;;;;;;;wBAkBK,aAAa,mCAAmC,sBAAsB,UAAS,sBAA2B;UC/BzG;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;;;;;WAMT;;UAGM;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/describe.ts","../src/regression.ts","../src/bootstrap.ts","../src/distribution.ts","../src/ridge.ts","../src/response.ts","../src/response-parse.ts","../src/response-fit.ts","../src/tests.ts","../src/rank.ts","../src/discrete.ts","../src/compare.ts","../src/power.ts"],"mappings":";;;;;;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AAc;;WAEd;WACA,cAAc;;;;;;;;wBAST,cAAc,2BAA2B,UAAS,iBAAsB;;UA6CvE;WACN;WACA;;;wBASK,MAAM,oBAAoB;;UAQzB;WACN;WACA;WACA;;WAEA;;WAEA,UAAU;;;wBAIL,YAAY,oBAAoB,aAAa;;;;;;;wBChJ7C,UAAU,WAAW;;UAgBpB;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;;;;;;;;;wBAiBK,YAAY,SAAS"}
|
package/build/index.js
CHANGED
|
@@ -273,17 +273,37 @@ function settings(name, options) {
|
|
|
273
273
|
if (!(lowEnd >= 0 && lowEnd < highEnd && highEnd <= 1)) throw new RangeError(`${name}: the ends are 0 <= low < high <= 1, not ${lowEnd} and ${highEnd}.`);
|
|
274
274
|
const level = options.ends ? highEnd - lowEnd : options.level ?? .95;
|
|
275
275
|
if (!(level > 0 && level < 1)) throw new RangeError(`${name}: level is more than 0 and less than 1, not ${level}.`);
|
|
276
|
+
const against = options.against;
|
|
277
|
+
if (against !== void 0 && !Number.isFinite(against)) throw new RangeError(`${name}: against is a finite number, not ${against}.`);
|
|
276
278
|
return {
|
|
277
279
|
runs,
|
|
278
280
|
lowEnd,
|
|
279
281
|
highEnd,
|
|
280
282
|
level,
|
|
281
|
-
method: options.method ?? "linear"
|
|
283
|
+
method: options.method ?? "linear",
|
|
284
|
+
against
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/** This function gives the two p of the option `against`, or nothing without the option. With no finite run, each p is 1. */
|
|
288
|
+
function sides(values, against) {
|
|
289
|
+
if (against === void 0) return {};
|
|
290
|
+
let atOrBelow = 0;
|
|
291
|
+
let atOrAbove = 0;
|
|
292
|
+
for (const v of values) {
|
|
293
|
+
if (v <= against) atOrBelow++;
|
|
294
|
+
if (v >= against) atOrAbove++;
|
|
295
|
+
}
|
|
296
|
+
const n = values.length + 1;
|
|
297
|
+
return {
|
|
298
|
+
against,
|
|
299
|
+
pAbove: (1 + atOrBelow) / n,
|
|
300
|
+
pBelow: (1 + atOrAbove) / n
|
|
282
301
|
};
|
|
283
302
|
}
|
|
284
303
|
/** The interval of the finite statistics of the runs. When no run is finite, low and high are equal to the estimate. */
|
|
285
304
|
function ends(values, estimate, s, seed) {
|
|
286
305
|
const { runs, level } = s;
|
|
306
|
+
const p = sides(values, s.against);
|
|
287
307
|
if (values.length === 0) return {
|
|
288
308
|
estimate,
|
|
289
309
|
low: estimate,
|
|
@@ -291,7 +311,8 @@ function ends(values, estimate, s, seed) {
|
|
|
291
311
|
level,
|
|
292
312
|
runs,
|
|
293
313
|
finite: 0,
|
|
294
|
-
seed
|
|
314
|
+
seed,
|
|
315
|
+
...p
|
|
295
316
|
};
|
|
296
317
|
const v = sorted(values);
|
|
297
318
|
return {
|
|
@@ -301,7 +322,8 @@ function ends(values, estimate, s, seed) {
|
|
|
301
322
|
level,
|
|
302
323
|
runs,
|
|
303
324
|
finite: v.length,
|
|
304
|
-
seed
|
|
325
|
+
seed,
|
|
326
|
+
...p
|
|
305
327
|
};
|
|
306
328
|
}
|
|
307
329
|
/**
|
|
@@ -2851,6 +2873,9 @@ function tQuantile(p, df) {
|
|
|
2851
2873
|
* with `df = 2 n - 2`. The count is on both sides of that form, so the function takes the first count that meets it.
|
|
2852
2874
|
*
|
|
2853
2875
|
* The function assumes independent values, unpaired groups of equal size, equal `sigma`, and a Bonferroni family.
|
|
2876
|
+
* Holm gives each test a level of `alpha / tests` or more. Thus for a Holm family the count is an upper bound, not the exact count.
|
|
2877
|
+
* The tests read the power by simulation: 2,000 draws at the floor for 1, 5 and 67 tests, from the fixed seeds `rigor-statistics/optionFloor/at/<tests>`.
|
|
2878
|
+
* Each read gives 0.78 or more, and one count below the floor gives less.
|
|
2854
2879
|
* A value of `sigma` from an older run gives a count for that run. Read `sigma` again on the new values.
|
|
2855
2880
|
*
|
|
2856
2881
|
* @param options - The spread, the difference, the family and the targets.
|