@mark1russell7/rigor-statistics 0.1.21 → 0.1.23

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @mark1russell7/rigor-statistics
2
2
 
3
- The statistics of measured work. It gives quantiles, bootstrap intervals, the sign test, the paired permutation test, Wilson intervals and the Holm correction. It gives the interval of a median from order statistics, and the central interval of a binomial count. It also gives least squares, rank correlation, the comparison with a baseline beyond the noise, and the Brier score and the log-loss of predictions. It rates items from pairwise results with Elo, Glicko-2 and a Bradley-Terry fit. It fits response records that a browser can evaluate from plain JSON.
3
+ The statistics of measured work. It gives quantiles, bootstrap intervals, the sign test, the paired permutation test, Wilson intervals and the Holm correction. It gives the interval of a median from order statistics, and the central interval of a binomial count. It also gives least squares, rank correlation, the comparison with a baseline beyond the noise, and the Brier score and the log-loss of predictions. It rates items from pairwise results with Elo, Glicko-2 and a Bradley-Terry fit. It fits response records that a browser can evaluate from plain JSON, and it gives the Sobol indices of their models.
4
4
 
5
5
  ```sh
6
6
  npm install @mark1russell7/rigor-statistics
@@ -100,6 +100,28 @@ A measure with `null` has no value. To tell why, declare the reasons in the fiel
100
100
 
101
101
  The default expansion has one product for each pair of levels of two dimensions. Two dimensions with 76 and 33 levels thus give 2508 products, and the limit `RESPONSE_MAX_TERMS` refuses them. With the option `interactions: "seen"`, a ridge fit keeps only the terms that are not 0 at one point or more. This choice looks only at the inputs of the points. A term with no point has the weight 0, so the choice does not change a prediction. The limit applies after the choice.
102
102
 
103
+ ### The Sobol indices of a model
104
+
105
+ `sobolIndices(record, measure, options)` tells how much of the variance of a fitted model comes from each dimension. The first-order index `first` is the share of one dimension alone. The total index `total` also includes its interactions.
106
+
107
+ ```ts
108
+ import { sobolIndices } from "@mark1russell7/rigor-statistics";
109
+
110
+ const sobol = sobolIndices(record, "ms", { n: 4096, seed: 1 });
111
+ sobol.indices; // [{ dimension: "size", first: 0.71, total: 0.74 }, ...]
112
+ sobol.variance; // the variance of the prediction over the input distribution
113
+ sobol.evaluations; // n * (dimensions + 2) evaluations of the model
114
+ ```
115
+
116
+ - Each dimension is independent and uniform over its range or its levels. A dimension with `log` is uniform in log space.
117
+ - A conditional dimension gets an independent draw. The model gets `null` for it where `whenHolds` fails.
118
+ - The method is Monte Carlo with the matrices A, B and AB_i of Saltelli (2010). The first-order index uses the estimator of Saltelli (2010), and the total index uses the estimator of Jansen (1999).
119
+ - A constant model has the variance 0. Then each index is 0, not NaN.
120
+ - The option `scale: "model"` gives the indices on the scale of the model, for example the logarithm of a measure with a log scale.
121
+ - The option `interval` adds a percentile bootstrap interval over the N rows to each index.
122
+
123
+ A test examines models with known indices. At N = 16384, the root mean square error of an index is approximately 0.01.
124
+
103
125
  ## Rate items from pairwise results
104
126
 
105
127
  A pairwise result is a comparison of two items: the first item wins, the second item wins, or a tie. Each function of this section is pure, so a log of results gives the same ratings each time.
@@ -142,6 +164,7 @@ logLoss([{ p: p.a, hit: true }]); // the probability of the obser
142
164
  | `bootstrap(data, statistic, options)` | A percentile bootstrap interval of any statistic. The options are `runs`, `level` or `ends`, `seed`, `method` and `against`. |
143
165
  | 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. |
144
166
  | `bootstrapMedian`, `bootstrapClusters` | The interval of the median, and a bootstrap that draws whole clusters (boards, seeds, sites). |
167
+ | `bootstrapStrata(strata, statistic, options)` | A stratified bootstrap. Each run draws inside each stratum, so each sample keeps the size of each stratum. |
145
168
  | `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`. |
146
169
  | `bootstrapMedianRatio(numerator, denominator, options)` | The interval of `median(numerator) / median(denominator)`. It is the uncertainty of the ratio, not the spread of the samples. |
147
170
  | `sampleTotalInterval(values, { population, scale })` | The interval of the total of a population from a uniform sample of `m` of its `n` items without replacement. The deviations get the finite population correction `sqrt(1 - m / n)`. `scale` is `n / m` by default. When `m` is `n`, the interval is the estimate. For a small `m`, the interval is too narrow: at `m = 8` of `n = 40`, the coverage is 0.865. For a total over pairs, use `uStatisticInterval`. |
@@ -151,6 +174,7 @@ logLoss([{ p: p.a, hit: true }]); // the probability of the obser
151
174
  | `ridgeSolve(gram, moment, lambda, { free })` | The ridge coefficients from the normal equations `X'X` and `X'y`, with a Cholesky factorization. The `free` coefficients have no penalty. A matrix that is not positive definite gives NaN coefficients. |
152
175
  | `signTest(better, worse, sides)`, `signTestPower(n, level)` | The sign test, and the fewest wins out of `n` that the test calls significant. |
153
176
  | `pairedPermutation(candidate, baseline, options)` | The paired permutation test (random sign flips). It uses the size of each difference. |
177
+ | `signFlipTest(terms, options)` | The sign-flip test of a sum of terms, for example a weighted mean of differences. Up to `exactMax` terms (16), it reads each sign set, so the p is exact. |
154
178
  | `twoSamplePermutation(a, b, options)` | The two-sample permutation test (a split of the pooled values). It reads each split when their count is `runs` or less, so the p is exact. It compares groups of different sizes, and its default statistic is the difference of the medians. |
155
179
  | `wilson(k, n, z)` | The Wilson interval of a proportion. |
156
180
  | `wilsonSampleSize(target, expected, z, max)` | The smallest number of trials at which the Wilson lower end reaches the target, at the expected proportion. |
@@ -179,6 +203,7 @@ logLoss([{ p: p.a, hit: true }]); // the probability of the obser
179
203
  | `parseResponseRecord(value)` | The examination of unknown data. It gives the record, or one fault with a path for each error. |
180
204
  | `predictResponse(model, inputs)`, `heldOutError(record, measure)` | The value of a model at one set of inputs, and the error of the folds of a measure. |
181
205
  | `heldOutErrorAt(record, measure, ids)` | The held-out error of a chosen set of points, from the predictions of the option `outOfFold`. |
206
+ | `sobolIndices(record, measure, options)` | The first-order and the total Sobol index of each dimension, for the model of a measure. The default N is 4096. |
182
207
  | `responseCells(record, vary, steps)` | The number of fitted places of a view, level axes included. It lets a caller bound the time of a view before the view starts. |
183
208
  | `whenHolds(dimension, values)` | True when a place has the condition of a dimension. A dimension with no `when` is always present. |
184
209
  | `sliceResponse(record, measure, options)`, `surfaceResponse(record, measure, options)` | A fitted curve over one dimension, or a fitted surface over two, with the matching measured points, the matching points with no value, a band and the distance to the nearest measurement. |
@@ -264,6 +289,8 @@ The tests prove that these functions give the same numbers as the copies in the
264
289
  | `bootstrapMedian` of packing | `bootstrapMedian(sortedValues, { runs, level, seed })`. Give the values sorted, because packing draws from the sorted list. |
265
290
  | `bootstrapMedian` of highways | `bootstrap(values, (s) => quantile(s, 0.5), { runs, level, seed })` |
266
291
  | `bootstrap` of layout-contract | `bootstrapClusters(rows, (r) => r.cluster, statistic, { runs, seed, ends: [0.025, 0.975] })` |
292
+ | The stratified bootstrap of `verdict` of layout-contract | `bootstrapStrata(families, meanOfMeans, { runs, seed: deriveSeed(seed, "verdict.stratified"), ends })` |
293
+ | The permutation test of `verdict` of layout-contract | `signFlipTest(terms, { exactMax, runs, seed: deriveSeed(seed, "verdict.permutation") })` |
267
294
  | `signTestP` of packing | `signTest(better, worse)` |
268
295
  | `signTestPower` of highways | `signTestPower(n, level)` |
269
296
  | `wilson` of packing | `wilson(k, n, z)`. packing rounds the ends to 4 places at the call. |
package/build/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import "@mark1russell7/rigor-generators";
1
2
  /**
2
3
  * The descriptive statistics: the mean, the standard deviation, the median, the quantiles and a summary of a list.
3
4
  * Each function throws a RangeError for an empty list or for a value that is NaN. Thus a missing value cannot make a
@@ -154,6 +155,14 @@ export declare function bootstrapMedian(values: readonly number[], options?: Boo
154
155
  * are in the order of their first row.
155
156
  */
156
157
  export declare function bootstrapClusters<T>(rows: readonly T[], cluster: (row: T) => string, statistic: (rows: readonly T[]) => number, options?: BootstrapOptions): Interval;
158
+ /**
159
+ * A stratified bootstrap: each run draws, inside each stratum, as many items as the stratum has, with replacement.
160
+ * So each sample keeps the size of each stratum. Use it when the strata are fixed by the design, for example the
161
+ * families of the inputs of a benchmark. The draws of one run go through the strata in the order of the list. With one
162
+ * stratum, the draws are equal to the draws of `bootstrap` with the same seed. The estimate is the statistic of all
163
+ * the strata. A run whose statistic is not finite does not count.
164
+ */
165
+ export declare function bootstrapStrata<T>(strata: readonly (readonly T[])[], statistic: (samples: readonly (readonly T[])[]) => number, options?: BootstrapOptions): Interval;
157
166
  interface SampleTotalOptions extends BootstrapOptions {
158
167
  /** The number of items in the whole population, `n`. It is a whole number, and it is not less than the sample. */
159
168
  readonly population: number;
@@ -757,6 +766,86 @@ export declare const RESPONSE_MAX_TERMS = 1024;
757
766
  * or less on a log scale with no `logFloor`. It throws for more than `RESPONSE_MAX_TERMS` terms.
758
767
  */
759
768
  export declare function fitResponse(data: ResponseData, options?: ResponseFitOptions): ResponseRecord;
769
+ /** The options of `sobolIndices`. */
770
+ interface SobolOptions {
771
+ /** The number N of rows of each base matrix. The default is 4096. */
772
+ readonly n?: number;
773
+ /** The seed of the draws. The default is 1. */
774
+ readonly seed?: number | string;
775
+ /**
776
+ * The scale of the output. The value `measure` uses `predictResponse`. The value `model` uses the scale of the
777
+ * model, so a model with a log scale gives the indices of the logarithm. The default is `measure`.
778
+ */
779
+ readonly scale?: "measure" | "model";
780
+ /**
781
+ * With this option, each index also gets a percentile bootstrap interval over the N rows. Each run draws N rows
782
+ * with replacement, and it calculates all the indices from these rows. The default is no interval.
783
+ */
784
+ readonly interval?: BootstrapOptions;
785
+ }
786
+ /** The two Sobol indices of one dimension. */
787
+ interface SobolIndex {
788
+ /** The id of the dimension. */
789
+ readonly dimension: string;
790
+ /** The first-order index S_i: the estimator of Saltelli (2010). */
791
+ readonly first: number;
792
+ /** The total index ST_i: the estimator of Jansen (1999). */
793
+ readonly total: number;
794
+ /** The bootstrap interval of `first`. Only the option `interval` writes this field. */
795
+ readonly firstInterval?: Interval;
796
+ /** The bootstrap interval of `total`. Only the option `interval` writes this field. */
797
+ readonly totalInterval?: Interval;
798
+ }
799
+ /** The result of `sobolIndices`. */
800
+ interface SobolIndices {
801
+ /** The id of the measure. */
802
+ readonly measure: string;
803
+ /** The scale of the output. */
804
+ readonly scale: "measure" | "model";
805
+ /** The number N of rows of each base matrix. */
806
+ readonly n: number;
807
+ /** The number of model evaluations: N * (d + 2). */
808
+ readonly evaluations: number;
809
+ /** The seed as a 32-bit number. */
810
+ readonly seed: number;
811
+ /** The mean of the outputs of A and B. */
812
+ readonly mean: number;
813
+ /** The variance of the outputs of A and B, with the divisor 2N. */
814
+ readonly variance: number;
815
+ /** The indices of each dimension of the record, in the order of the record. */
816
+ readonly indices: readonly SobolIndex[];
817
+ }
818
+ /**
819
+ * This function gives the first-order and the total Sobol index of each dimension of a record, for the model of
820
+ * `measure`. The indices are of the prediction of the model, not of the measured points.
821
+ *
822
+ * The input distribution:
823
+ * - Each dimension is independent of the other dimensions.
824
+ * - A continuous dimension is uniform over its range. With `log`, the logarithm of the value is uniform.
825
+ * - An ordinal or a categorical dimension is uniform over its levels.
826
+ * - A conditional dimension gets an independent draw. The model gets `null` for it where `whenHolds` fails for the drawn parent.
827
+ *
828
+ * Thus the inputs stay independent, and the indices have their usual meaning. A parent gets the effect of the absence of its child.
829
+ *
830
+ * The estimators:
831
+ * - The first-order index is `mean(f(B) * (f(AB_i) - f(A))) / V` (Saltelli, 2010).
832
+ * - The total index is `mean((f(A) - f(AB_i)) ** 2) / 2 / V` (Jansen, 1999).
833
+ * - V is the variance of the outputs of A and B together.
834
+ * - The variance uses the outputs of A and B less their mean. The first-order sum uses `f(B)` less that mean.
835
+ * - The total sum uses differences of outputs, so it uses no mean.
836
+ * - This step keeps the estimators unbiased, and it decreases their error when the mean is large.
837
+ *
838
+ * A model with a constant output has the variance 0. Then each index is 0, not NaN. An estimate can be a little
839
+ * below 0 or above 1, from the Monte Carlo error. The function does not clip it.
840
+ *
841
+ * The draws fill A row by row, then B row by row. Each row has one draw for each dimension, in the order of the
842
+ * record. Thus the same seed gives the same indices. The model can ignore a dimension. Then that dimension gets 0 for both
843
+ * indices exactly, unless it is the parent of a dimension that the model reads.
844
+ *
845
+ * The function throws a RangeError when the record has no model of `measure`, and when N is not a whole number of 2 or more.
846
+ * `predictResponse` throws for a value that the model refuses, for example a level that the model does not know.
847
+ */
848
+ export declare function sobolIndices(record: Pick<ResponseRecord, "dimensions" | "models">, measure: string, options?: SobolOptions): SobolIndices;
760
849
  /**
761
850
  * The sign test of paired results: `better` inputs where the candidate wins and `worse` where it loses. The ties
762
851
  * do not count. One-sided (the default), it is the p of `better` wins or more if the two are equal. Two-sided, it is
@@ -821,6 +910,40 @@ interface PermutationResult {
821
910
  * the size of each difference, which the sign test does not. A pair with a difference of 0 adds nothing.
822
911
  */
823
912
  export declare function pairedPermutation(candidate: readonly number[], baseline: readonly number[], options?: PermutationOptions): PermutationResult;
913
+ /** The default of the option `exactMax` of `signFlipTest`. */
914
+ export declare const SIGN_FLIP_EXACT_MAX = 16;
915
+ /** The largest value of the option `exactMax` of `signFlipTest`: 2^24 sign sets. */
916
+ export declare const SIGN_FLIP_EXACT_LIMIT = 24;
917
+ /** The options of `signFlipTest`. */
918
+ interface SignFlipOptions {
919
+ /** The largest count of terms for which the test reads each of the `2^n` sign sets. The default is 16. The most is 24. */
920
+ readonly exactMax?: number;
921
+ /** The count of random sign sets above `exactMax`. The default is 10 000. */
922
+ readonly runs?: number;
923
+ /** The default is 1. */
924
+ readonly seed?: number | string;
925
+ }
926
+ /** The result of `signFlipTest`. */
927
+ interface SignFlipResult {
928
+ /** The absolute value of the sum of the terms. */
929
+ readonly observed: number;
930
+ /** The two-sided p. */
931
+ readonly p: number;
932
+ /** This field is true when the test read each sign set, so the p has no noise from the draws. */
933
+ readonly exact: boolean;
934
+ /** The count of the sign sets that the test read: `2^n` when it is exact, otherwise the count of the draws. */
935
+ readonly runs: number;
936
+ }
937
+ /**
938
+ * The sign-flip test of a sum of terms. Under the null, each term has the sign + or - with equal chance. The statistic
939
+ * is the absolute value of the sum. A weighted mean of paired differences is such a sum: give the terms `w[i] * d[i]`.
940
+ *
941
+ * Up to `exactMax` terms, the test reads each sign set. The p is the share of the sets that are as far from 0 or
942
+ * farther. The observed set is one of them. Above `exactMax`, the test draws `runs` sets, and the p is (1 + the extreme
943
+ * draws) / (1 + runs). A sum within `1e-12` of the sum of the absolute terms counts as extreme, so rounding does not
944
+ * hide a tie.
945
+ */
946
+ export declare function signFlipTest(terms: readonly number[], options?: SignFlipOptions): SignFlipResult;
824
947
  /** The options of `twoSamplePermutation`. */
825
948
  interface TwoSamplePermutationOptions {
826
949
  /** The largest number of splits that the test reads. The default is 10 000. */
@@ -1473,5 +1596,5 @@ interface BradleyTerryFit {
1473
1596
  * outcome, a bad weight and a bad option.
1474
1597
  */
1475
1598
  export declare function bradleyTerry(items: number, comparisons: readonly PairComparison[], options?: BradleyTerryOptions): BradleyTerryFit;
1476
- export type { BinomialSide, BootstrapOptions, BradleyTerryFit, BradleyTerryOptions, CalibrationLevel, CategoricalDimension, CompareOptions, Comparison, ContinuousDimension, Corrected, CountInterval, CoverageBar, CoverageCell, CoverageMinSample, CoverageReason, CoverageStep, Effect, EloOptions, EloUpdate, Forecast, Glicko2Game, Glicko2Options, Glicko2Rating, Interval, Kappa, LeastSquaresFit, LeastSquaresOptions, MedianInterval, ModeOptions, NoiseOptions, NoiseState, NoiseVerdict, OptionFloorOptions, OrdinalDimension, PairComparison, PairOutcome, PairProbabilities, ParsedResponseRecord, PermutationOptions, PermutationResult, Proportion, QuantileInterval, QuantileMethod, RatingScale, 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, SampleTotalOptions, SideP, SmoothLaw, SmoothLawScore, Summary, TableResponseModel, TieModel, TwoSamplePermutationOptions, TwoSamplePermutationResult, UStatisticInterval, UStatisticMean, UStatisticMethod, UStatisticOptions };
1599
+ export type { BinomialSide, BootstrapOptions, BradleyTerryFit, BradleyTerryOptions, CalibrationLevel, CategoricalDimension, CompareOptions, Comparison, ContinuousDimension, Corrected, CountInterval, CoverageBar, CoverageCell, CoverageMinSample, CoverageReason, CoverageStep, Effect, EloOptions, EloUpdate, Forecast, Glicko2Game, Glicko2Options, Glicko2Rating, Interval, Kappa, LeastSquaresFit, LeastSquaresOptions, MedianInterval, ModeOptions, NoiseOptions, NoiseState, NoiseVerdict, OptionFloorOptions, OrdinalDimension, PairComparison, PairOutcome, PairProbabilities, ParsedResponseRecord, PermutationOptions, PermutationResult, Proportion, QuantileInterval, QuantileMethod, RatingScale, 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, SampleTotalOptions, SideP, SignFlipOptions, SignFlipResult, SmoothLaw, SmoothLawScore, SobolIndex, SobolIndices, SobolOptions, Summary, TableResponseModel, TieModel, TwoSamplePermutationOptions, TwoSamplePermutationResult, UStatisticInterval, UStatisticMean, UStatisticMethod, UStatisticOptions };
1477
1600
  //# sourceMappingURL=index.d.ts.map
@@ -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/agreement.ts","../src/rank.ts","../src/discrete.ts","../src/compare.ts","../src/power.ts","../src/coverage.ts","../src/u-statistic.ts","../src/rating.ts","../src/bradley-terry.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;UC7BzG;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;;;;;WAMT;;;;;WAKA;;;UAIM;;WAEN;;WAEA;;WAEA;;UAGM,iBAAiB,QAAQ;;WAE/B;WACA;WACA;WACA;WACA;;WAEA;;WAEA;;;;;;wBAOK,UAAU,GAAG,eAAe,KAAK,YAAY,iBAAiB,gBAAgB,UAAS,mBAAwB;;;;;;;;wBAsB/G,aAAa,GAAG,GAC9B,YAAY,KACZ,YAAY,KACZ,YAAY,YAAY,KAAK,YAAY,gBACzC,UAAS,mBACR;;;;;;wBAwBa,qBAAqB,8BAA8B,gCAAgC,UAAS,mBAAwB;;;;;;;wBAUpH,sBACd,mCACA,sBACA,UAAS,mBAAmB,sBAC3B;;wBAoGa,gBAAgB,2BAA2B,UAAS,mBAAwB;;;;;;wBAS5E,kBAAkB,GAChC,eAAe,KACf,UAAU,KAAK,cACf,YAAY,eAAe,gBAC3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AEN;;WAEA;;WAEA,QAAQ;;WAER;;WAEA,kBAAkB,aAAa;;;UAIzB;;WAEN;WACA;WACA;;;UAIM;;WAEN;WACA;WACA;WACA;;WAEA;;WAEA,WAAW;;WAEX,MAAM;;WAEN;;WAEA;;WAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmFK,mBAAmB,2BAA2B,SAAS,oBAAoB;;;;;;;UCrI1E;;WAEN;;WAEA;;WAEA;;;UAIM,mBAAmB;;WAEzB;;;UAIM;;WAEN;;WAEA;;WAEA;;;;;;wBAyBK,YAAY,YAAY,YAAY,UAAS;;;;;;wBAY7C,UAAU,YAAY,YAAY,eAAe,UAAS,aAAkB;;UAU3E;WACN;;WAEA;;WAEA;;;UAIM;WACN;WACA;;WAEA;;;UAIM;;WAEN;;WAEA;;;;;;;wBAmBK,cAAc,QAAQ,eAAe,gBAAgB,eAAe,UAAS,iBAAsB;;;;;wBAuEnG,YAAY,QAAQ,gBAAgB;;UAQnC;;WAEN;;WAEA;;WAEA;;;;;;;wBAuBK,kBAAkB,YAAY,YAAY,eAAU;;;;;wBAWpD,iBAAiB,kBAAkB,UAAS;;wBAO5C,iBAAiB,gBAAgB,UAAS;;KCtO9C;;UAGK;WACN;WACA;WACA,SAAS;;WAET;;;KAIC;;UAGK;;WAEN;;WAEA;;;;;WAKA,OAAO;;;;;WAKP;;WAEA;;WAEA;;;UAIM;;WAEN;;;;;WAKA;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;wBA6CK,aAAa,eAAe,sBAAsB,kBAAkB,UAAS,sBAA2B"}
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/response-sobol.ts","../src/tests.ts","../src/agreement.ts","../src/rank.ts","../src/discrete.ts","../src/comp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EA;;WAEA;;WAEA;;WAEA;;;;;;;wBA6CK,aAAa,eAAe,sBAAsB,kBAAkB,UAAS,sBAA2B"}
package/build/index.js CHANGED
@@ -388,6 +388,26 @@ function bootstrapClusters(rows, cluster, statistic, options = {}) {
388
388
  };
389
389
  }
390
390
  /**
391
+ * A stratified bootstrap: each run draws, inside each stratum, as many items as the stratum has, with replacement.
392
+ * So each sample keeps the size of each stratum. Use it when the strata are fixed by the design, for example the
393
+ * families of the inputs of a benchmark. The draws of one run go through the strata in the order of the list. With one
394
+ * stratum, the draws are equal to the draws of `bootstrap` with the same seed. The estimate is the statistic of all
395
+ * the strata. A run whose statistic is not finite does not count.
396
+ */
397
+ function bootstrapStrata(strata, statistic, options = {}) {
398
+ if (strata.length === 0) throw new RangeError("bootstrapStrata: there is no stratum.");
399
+ for (const [i, stratum] of strata.entries()) if (stratum.length === 0) throw new RangeError(`bootstrapStrata: the stratum ${i} is empty.`);
400
+ const samples = strata.map((stratum) => new Array(stratum.length));
401
+ return percentile("bootstrapStrata", options, (r) => {
402
+ for (const [k, stratum] of strata.entries()) {
403
+ const sample = samples[k];
404
+ const n = stratum.length;
405
+ for (let i = 0; i < n; i++) sample[i] = stratum[r.below(n)];
406
+ }
407
+ return statistic(samples);
408
+ }, () => statistic(strata));
409
+ }
410
+ /**
391
411
  * A bootstrap interval of the total of a population from a uniform sample of `m` of its `n` items, drawn without
392
412
  * replacement. The estimate is `scale * sum(values)`. Each run draws `m` values with replacement, as `bootstrap`
393
413
  * does. The deviation of each run from the sum of the sample gets the factor `scale * sqrt(1 - m / n)`, the finite
@@ -2242,6 +2262,168 @@ function fitResponse(data, options = {}) {
2242
2262
  folds: foldRecords
2243
2263
  };
2244
2264
  }
2265
+ // src/response-sobol.ts
2266
+ /**
2267
+ * The Sobol indices of a fitted model of a record of the format `response-records/1`. The first-order index of a
2268
+ * dimension is the share of the variance of the prediction that the dimension causes alone. The total index also
2269
+ * includes each interaction of the dimension with the other dimensions.
2270
+ *
2271
+ * The method is Monte Carlo with two independent matrices A and B of N rows, and one matrix `AB_i` for each dimension `i`.
2272
+ * `AB_i` is A with the column `i` of B (Saltelli and others, 2010). The first-order index uses the estimator of Saltelli
2273
+ * (2010), and the total index uses the estimator of Jansen (1999). The model gets N * (d + 2) evaluations for d dimensions.
2274
+ *
2275
+ * This file uses no Node import, no clock and no `Math.random`, the same as `response.ts`.
2276
+ */
2277
+ /** This function draws one value of a dimension. Each dimension uses the same number of draws: one. */
2278
+ function drawValue(dimension, r) {
2279
+ if (dimension.kind !== "continuous") return dimension.levels[r.below(dimension.levels.length)];
2280
+ const [low, high] = dimension.range;
2281
+ if (dimension.log !== true) return r.range(low, high);
2282
+ const value = 10 ** r.range(Math.log10(low), Math.log10(high));
2283
+ return Math.min(high, Math.max(low, value));
2284
+ }
2285
+ /** This function draws a matrix of `n` rows, row by row, with one draw for each dimension in the order of the record. */
2286
+ function drawMatrix(dimensions, n, r) {
2287
+ return Array.from({ length: n }, () => dimensions.map((d) => drawValue(d, r)));
2288
+ }
2289
+ /** This function gives the inputs of a row. A conditional dimension gets `null` where its condition fails. */
2290
+ function inputsOf(dimensions, row) {
2291
+ const drawn = {};
2292
+ dimensions.forEach((d, i) => {
2293
+ drawn[d.id] = row[i];
2294
+ });
2295
+ const inputs = {};
2296
+ for (const d of dimensions) inputs[d.id] = whenHolds(d, drawn) ? drawn[d.id] : null;
2297
+ return inputs;
2298
+ }
2299
+ /**
2300
+ * This function gives the variance and the indices from the rows `rows`. A variance of 0 gives each index as 0.
2301
+ * The value `constant` is true when each output is equal to the first output.
2302
+ */
2303
+ function estimate(outputs, rows, n, constant) {
2304
+ const d = outputs.ab.length;
2305
+ const at = (j) => rows === null ? j : rows[j];
2306
+ let sum = 0;
2307
+ for (let j = 0; j < n; j++) sum += outputs.a[at(j)] + outputs.b[at(j)];
2308
+ const mean = sum / (2 * n);
2309
+ let square = 0;
2310
+ for (let j = 0; j < n; j++) {
2311
+ const ea = outputs.a[at(j)] - mean;
2312
+ const eb = outputs.b[at(j)] - mean;
2313
+ square += ea * ea + eb * eb;
2314
+ }
2315
+ const variance = constant ? 0 : square / (2 * n);
2316
+ const first = [];
2317
+ const total = [];
2318
+ for (let i = 0; i < d; i++) {
2319
+ const abi = outputs.ab[i];
2320
+ let s = 0;
2321
+ let t = 0;
2322
+ for (let j = 0; j < n; j++) {
2323
+ const fa = outputs.a[at(j)];
2324
+ const fb = outputs.b[at(j)];
2325
+ const fab = abi[at(j)];
2326
+ s += (fb - mean) * (fab - fa);
2327
+ t += (fa - fab) * (fa - fab);
2328
+ }
2329
+ first.push(variance > 0 ? s / n / variance : 0);
2330
+ total.push(variance > 0 ? t / (2 * n) / variance : 0);
2331
+ }
2332
+ return {
2333
+ mean,
2334
+ variance,
2335
+ first,
2336
+ total
2337
+ };
2338
+ }
2339
+ /**
2340
+ * This function gives the first-order and the total Sobol index of each dimension of a record, for the model of
2341
+ * `measure`. The indices are of the prediction of the model, not of the measured points.
2342
+ *
2343
+ * The input distribution:
2344
+ * - Each dimension is independent of the other dimensions.
2345
+ * - A continuous dimension is uniform over its range. With `log`, the logarithm of the value is uniform.
2346
+ * - An ordinal or a categorical dimension is uniform over its levels.
2347
+ * - A conditional dimension gets an independent draw. The model gets `null` for it where `whenHolds` fails for the drawn parent.
2348
+ *
2349
+ * Thus the inputs stay independent, and the indices have their usual meaning. A parent gets the effect of the absence of its child.
2350
+ *
2351
+ * The estimators:
2352
+ * - The first-order index is `mean(f(B) * (f(AB_i) - f(A))) / V` (Saltelli, 2010).
2353
+ * - The total index is `mean((f(A) - f(AB_i)) ** 2) / 2 / V` (Jansen, 1999).
2354
+ * - V is the variance of the outputs of A and B together.
2355
+ * - The variance uses the outputs of A and B less their mean. The first-order sum uses `f(B)` less that mean.
2356
+ * - The total sum uses differences of outputs, so it uses no mean.
2357
+ * - This step keeps the estimators unbiased, and it decreases their error when the mean is large.
2358
+ *
2359
+ * A model with a constant output has the variance 0. Then each index is 0, not NaN. An estimate can be a little
2360
+ * below 0 or above 1, from the Monte Carlo error. The function does not clip it.
2361
+ *
2362
+ * The draws fill A row by row, then B row by row. Each row has one draw for each dimension, in the order of the
2363
+ * record. Thus the same seed gives the same indices. The model can ignore a dimension. Then that dimension gets 0 for both
2364
+ * indices exactly, unless it is the parent of a dimension that the model reads.
2365
+ *
2366
+ * The function throws a RangeError when the record has no model of `measure`, and when N is not a whole number of 2 or more.
2367
+ * `predictResponse` throws for a value that the model refuses, for example a level that the model does not know.
2368
+ */
2369
+ function sobolIndices(record, measure, options = {}) {
2370
+ const model = record.models.find((m) => m.measure === measure);
2371
+ if (model === void 0) throw new RangeError(`sobolIndices: the record has no model of the measure "${measure}".`);
2372
+ const n = options.n ?? 4096;
2373
+ if (!Number.isSafeInteger(n) || n < 2) throw new RangeError(`sobolIndices: n is a whole number of 2 or more, not ${n}.`);
2374
+ const scale = options.scale ?? "measure";
2375
+ const dimensions = record.dimensions;
2376
+ const d = dimensions.length;
2377
+ const r = random(options.seed ?? 1);
2378
+ const a = drawMatrix(dimensions, n, r);
2379
+ const b = drawMatrix(dimensions, n, r);
2380
+ const f = (row) => {
2381
+ const inputs = inputsOf(dimensions, row);
2382
+ return scale === "model" ? predictScaled(model, inputs) : predictResponse(model, inputs);
2383
+ };
2384
+ const fa = Float64Array.from(a, f);
2385
+ const fb = Float64Array.from(b, f);
2386
+ const outputs = {
2387
+ a: fa,
2388
+ b: fb,
2389
+ ab: dimensions.map((_, i) => Float64Array.from(a, (row, j) => f(row.map((v, k) => k === i ? b[j][i] : v))))
2390
+ };
2391
+ const first = fa[0];
2392
+ const constant = fa.every((v) => v === first) && fb.every((v) => v === first);
2393
+ const all = estimate(outputs, null, n, constant);
2394
+ let intervals;
2395
+ if (options.interval !== void 0) {
2396
+ const rows = new Array(n);
2397
+ const flat = (e) => [...e.first, ...e.total];
2398
+ intervals = percentiles("sobolIndices", options.interval, 2 * d, (rr) => {
2399
+ for (let j = 0; j < n; j++) rows[j] = rr.below(n);
2400
+ return flat(estimate(outputs, rows, n, constant));
2401
+ }, () => flat(all));
2402
+ }
2403
+ const indices = dimensions.map((dimension, i) => {
2404
+ const index = {
2405
+ dimension: dimension.id,
2406
+ first: all.first[i],
2407
+ total: all.total[i]
2408
+ };
2409
+ if (intervals === void 0) return index;
2410
+ return {
2411
+ ...index,
2412
+ firstInterval: intervals[i],
2413
+ totalInterval: intervals[d + i]
2414
+ };
2415
+ });
2416
+ return {
2417
+ measure,
2418
+ scale,
2419
+ n,
2420
+ evaluations: n * (d + 2),
2421
+ seed: r.seed,
2422
+ mean: constant ? first : all.mean,
2423
+ variance: all.variance,
2424
+ indices
2425
+ };
2426
+ }
2245
2427
  // src/tests.ts
2246
2428
  /**
2247
2429
  * The tests of a difference: the sign test, the paired permutation test, the Wilson interval of a proportion and
@@ -2375,6 +2557,57 @@ function pairedPermutation(candidate, baseline, options = {}) {
2375
2557
  runs
2376
2558
  };
2377
2559
  }
2560
+ /** The default of the option `exactMax` of `signFlipTest`. */
2561
+ const SIGN_FLIP_EXACT_MAX = 16;
2562
+ /** The largest value of the option `exactMax` of `signFlipTest`: 2^24 sign sets. */
2563
+ const SIGN_FLIP_EXACT_LIMIT = 24;
2564
+ /**
2565
+ * The sign-flip test of a sum of terms. Under the null, each term has the sign + or - with equal chance. The statistic
2566
+ * is the absolute value of the sum. A weighted mean of paired differences is such a sum: give the terms `w[i] * d[i]`.
2567
+ *
2568
+ * Up to `exactMax` terms, the test reads each sign set. The p is the share of the sets that are as far from 0 or
2569
+ * farther. The observed set is one of them. Above `exactMax`, the test draws `runs` sets, and the p is (1 + the extreme
2570
+ * draws) / (1 + runs). A sum within `1e-12` of the sum of the absolute terms counts as extreme, so rounding does not
2571
+ * hide a tie.
2572
+ */
2573
+ function signFlipTest(terms, options = {}) {
2574
+ const exactMax = options.exactMax ?? 16;
2575
+ if (!Number.isInteger(exactMax) || exactMax < 0 || exactMax > 24) throw new RangeError(`signFlipTest: exactMax is a whole number from 0 to 24, not ${exactMax}.`);
2576
+ for (const [i, t] of terms.entries()) if (!Number.isFinite(t)) throw new RangeError(`signFlipTest: the term ${i} is ${t}, not a finite number.`);
2577
+ const n = terms.length;
2578
+ const observed = Math.abs(terms.reduce((sum, t) => sum + t, 0));
2579
+ const slack = 1e-12 * terms.reduce((sum, t) => sum + Math.abs(t), 0);
2580
+ if (n <= exactMax) {
2581
+ const total = 2 ** n;
2582
+ let hits = 0;
2583
+ for (let mask = 0; mask < total; mask++) {
2584
+ let sum = 0;
2585
+ for (let i = 0; i < n; i++) sum += mask & 1 << i ? -terms[i] : terms[i];
2586
+ if (Math.abs(sum) >= observed - slack) hits++;
2587
+ }
2588
+ return {
2589
+ observed,
2590
+ p: hits / total,
2591
+ exact: true,
2592
+ runs: total
2593
+ };
2594
+ }
2595
+ const runs = options.runs ?? 1e4;
2596
+ if (!Number.isSafeInteger(runs) || runs < 1) throw new RangeError(`signFlipTest: runs is a whole number of 1 or more, not ${runs}.`);
2597
+ const r = random(options.seed ?? 1);
2598
+ let hits = 0;
2599
+ for (let run = 0; run < runs; run++) {
2600
+ let sum = 0;
2601
+ for (let i = 0; i < n; i++) sum += r.next() < .5 ? -terms[i] : terms[i];
2602
+ if (Math.abs(sum) >= observed - slack) hits++;
2603
+ }
2604
+ return {
2605
+ observed,
2606
+ p: (1 + hits) / (1 + runs),
2607
+ exact: false,
2608
+ runs
2609
+ };
2610
+ }
2378
2611
  /** This function gives the count of the ways to choose `k` of `n`, or Infinity when the count is over `limit`. */
2379
2612
  function choices(n, k, limit) {
2380
2613
  const small = Math.min(k, n - k);
@@ -3708,6 +3941,6 @@ function inverseDiagonal(hessian, k) {
3708
3941
  }
3709
3942
  return out;
3710
3943
  }
3711
- export { KENDALL_EXACT, RESPONSE_LAMBDAS, RESPONSE_MAX_POWER, RESPONSE_MAX_TERMS, RESPONSE_RECORDS_SCHEMA, U_STATISTIC_TIGHT_MIN_SAMPLE, Z95, bestSmoothLaw, binomialInterval, binomialTest, bootstrap, bootstrapClusters, bootstrapLeastSquares, bootstrapMedian, bootstrapMedianRatio, bootstrapTwo, bradleyTerry, brier, calibration, cohenKappa, compareRatios, coverageMinSample, eloExpected, eloUpdate, fitResponse, glicko2Idle, glicko2Update, heldOutError, heldOutErrorAt, holm, kendallTau, leastSquares, logLoss, mean, median, medianInterval, modeCount, negativeBinomialInterval, noiseFloor, noiseVerdict, optionFloor, pairProbabilities, pairedPermutation, parseResponseRecord, partialConjunction, predictResponse, quantile, quantileInterval, quantileSamples, quantileSorted, ranks, ratingToStrength, responseCells, ridgeSolve, sampleTotalInterval, sd, signTest, signTestPower, sliceResponse, smoothLawScores, sorted, spearman, strengthToRating, summarize, surfaceResponse, tQuantile, twoSamplePermutation, uStatisticInterval, whenHolds, wilson, wilsonSampleSize };
3944
+ export { KENDALL_EXACT, RESPONSE_LAMBDAS, RESPONSE_MAX_POWER, RESPONSE_MAX_TERMS, RESPONSE_RECORDS_SCHEMA, SIGN_FLIP_EXACT_LIMIT, SIGN_FLIP_EXACT_MAX, U_STATISTIC_TIGHT_MIN_SAMPLE, Z95, bestSmoothLaw, binomialInterval, binomialTest, bootstrap, bootstrapClusters, bootstrapLeastSquares, bootstrapMedian, bootstrapMedianRatio, bootstrapStrata, bootstrapTwo, bradleyTerry, brier, calibration, cohenKappa, compareRatios, coverageMinSample, eloExpected, eloUpdate, fitResponse, glicko2Idle, glicko2Update, heldOutError, heldOutErrorAt, holm, kendallTau, leastSquares, logLoss, mean, median, medianInterval, modeCount, negativeBinomialInterval, noiseFloor, noiseVerdict, optionFloor, pairProbabilities, pairedPermutation, parseResponseRecord, partialConjunction, predictResponse, quantile, quantileInterval, quantileSamples, quantileSorted, ranks, ratingToStrength, responseCells, ridgeSolve, sampleTotalInterval, sd, signFlipTest, signTest, signTestPower, sliceResponse, smoothLawScores, sobolIndices, sorted, spearman, strengthToRating, summarize, surfaceResponse, tQuantile, twoSamplePermutation, uStatisticInterval, whenHolds, wilson, wilsonSampleSize };
3712
3945
 
3713
3946
  //# sourceMappingURL=index.js.map