@mark1russell7/stack-endurance 0.8.30 → 0.8.32
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 +13 -3
- package/build/index.d.ts +91 -15
- package/build/index.d.ts.map +1 -1
- package/build/index.js +170 -24
- package/build/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -148,11 +148,21 @@ Two groups of cuts that share no minimal set are independent, so the independent
|
|
|
148
148
|
- The rank is by level, as the take order. It compares the sum of the changes of the first level, then of the next level, and so on. The largest sum comes first. Two equal inputs go in the order of their keys.
|
|
149
149
|
- `chance` gives the chance that the draw gets its need through the event (`lasts` of `caseOutlook`), before and after the step. It also gives the values at the two ends of the sampling bands of the cuts, before and after the step. The change of the chance is the change of the point values.
|
|
150
150
|
- `chance.interval` gives the 95% interval of the change (`ChanceInterval`: `se`, `low` and `high`). Since 0.8.27 (M2-sensitivity-interval).
|
|
151
|
-
-
|
|
151
|
+
- Each cut that the stop of the draw uses (`stopCuts`) must have sums (`Cut.sums` of the core) or counts (`Cut.counts`) with no fault. Else the interval is absent.
|
|
152
152
|
- Since 0.8.30, the sums give the interval with no counts. When a cut has good sums and good counts, the sums come first. The two give the same interval.
|
|
153
|
-
-
|
|
153
|
+
- With one cut, the change is a weighted sum of the chances of the Kaplan-Meier curve at up to four days. A read between two points of the curve has a weight on each point.
|
|
154
154
|
- `survivalCombination` of rigor-statistics gives the Greenwood error of the sum. The covariance of the chances at two days `a <= b` is `S(a) * S(b) * V(a)`.
|
|
155
|
-
-
|
|
155
|
+
- With two or more cuts, the curves of the stop are not smooth functions of the curves of the cuts. Thus the interval comes from a parametric bootstrap. Since 0.8.31.
|
|
156
|
+
- Each run of the bootstrap draws the curve of each cut (`survivalBootstrap` of rigor-statistics). Then it makes the event curve of the stop again (`stopRebuild`) and reads the change.
|
|
157
|
+
- `interval` is for `change.event`. `interval.runs` gives the count of runs. The option `runs` sets it, and the default is `SENSITIVITY_RUNS`, 1000.
|
|
158
|
+
- The seed is the hash of the case, the need and the input. Thus the same query gives the same interval.
|
|
159
|
+
- At a kink of the event curve, as for two cuts with equal curves, the coverage of the interval is near 89%, not 95%.
|
|
160
|
+
- `chance.intervals` gives the 95% interval of the change of each curve of the stop: `event`, `independent` and `upper` (`CurveIntervals`). Since 0.8.32 (M2-interval-independent-upper).
|
|
161
|
+
- `intervals.event` is equal to `interval`.
|
|
162
|
+
- With one cut, the three changes are equal, so the three intervals are the interval of the delta method.
|
|
163
|
+
- With two or more cuts, one bootstrap gives the three intervals (`survivalBootstrapMany` of rigor-statistics). Each run makes the three curves of the stop again (`StopRebuild.curvesWith`) from the same drawn curves.
|
|
164
|
+
- The draws are the draws of 0.8.31, so the event interval does not change.
|
|
165
|
+
- The upper curve has a kink where the sum of the chances of the cuts reaches 1. There, its coverage can be less than 95%.
|
|
156
166
|
|
|
157
167
|
An example on the sample:
|
|
158
168
|
|
package/build/index.d.ts
CHANGED
|
@@ -433,6 +433,36 @@ export declare function stopCurves(caseCuts: CaseCuts, draw: Draw, options?: Sto
|
|
|
433
433
|
* @throws RangeError for a bad `maxSets` or `maxWork`
|
|
434
434
|
*/
|
|
435
435
|
export declare function stopCuts(caseCuts: CaseCuts, draw: Draw, options?: StopCurveOptions): readonly number[] | undefined;
|
|
436
|
+
/**
|
|
437
|
+
* The cuts of the stop of a draw, and a function that gives the curves of the stop for other curves of these cuts. Since 0.8.31.
|
|
438
|
+
* A parametric bootstrap draws the curve of each used cut, and `curvesWith` gives the curves of the stop of each draw.
|
|
439
|
+
*/
|
|
440
|
+
export interface StopRebuild {
|
|
441
|
+
/** The cuts that the stop uses, as indexes in `caseCuts.cuts`: the result of `stopCuts`. */
|
|
442
|
+
readonly used: readonly number[];
|
|
443
|
+
/** The curves of the stop (`stopCurves`) with the curves of the cuts in the case. */
|
|
444
|
+
readonly curves: StopCurves;
|
|
445
|
+
/**
|
|
446
|
+
* This function gives the curves of the stop when each used cut has the curve at its place in `used`. Each other cut keeps its curve.
|
|
447
|
+
* The minimal sets, the budgets and the bound are those of `curves`. Each curve must be good for `checkEndurance`.
|
|
448
|
+
*/
|
|
449
|
+
readonly curvesWith: (curves: readonly Survival[]) => StopCurves;
|
|
450
|
+
/** This function gives only the `event` curve of `curvesWith`. It does not calculate the other two curves, so it costs less. */
|
|
451
|
+
readonly eventWith: (curves: readonly Survival[]) => Survival;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* This function gives the cuts of the stop of a draw and the curves of the stop for other curves of these cuts. Since 0.8.31.
|
|
455
|
+
*
|
|
456
|
+
* - The sets of cuts come from the needs and the parts of the case, not from the curves. Thus one search of the sets serves each call of `curvesWith`.
|
|
457
|
+
* - `curvesWith` uses the same functions as `stopCurves`: `eventStop`, `independentStop` and `upperStop`.
|
|
458
|
+
* - The result is `undefined` when `stopCurves` gives `undefined`.
|
|
459
|
+
*
|
|
460
|
+
* @param caseCuts - The case
|
|
461
|
+
* @param draw - The draw
|
|
462
|
+
* @param options - The stack or the parts that are also down, and the budgets: as for `stopCurves`
|
|
463
|
+
* @throws RangeError for a bad `maxSets` or `maxWork`
|
|
464
|
+
*/
|
|
465
|
+
export declare function stopRebuild(caseCuts: CaseCuts, draw: Draw, options?: StopCurveOptions): StopRebuild | undefined;
|
|
436
466
|
/** The shortfall of each level, in user-days, and the draws that the query cannot read. */
|
|
437
467
|
export interface Shortfall {
|
|
438
468
|
/**
|
|
@@ -727,23 +757,49 @@ export declare const SAMPLE_ENDURANCE_STACK: Stack;
|
|
|
727
757
|
export declare const SAMPLE_ENDURANCE: EnduranceLayer;
|
|
728
758
|
/** The default step of `enduranceSensitivity`: 1 unit of each input. */
|
|
729
759
|
export declare const SENSITIVITY_STEP = 1;
|
|
730
|
-
/**
|
|
760
|
+
/**
|
|
761
|
+
* The default count of the runs of the bootstrap of the interval of a stop of two or more cuts (`SensitivityOptions.runs`). Since 0.8.31.
|
|
762
|
+
* One call on a test layer of one store, one draw and two cuts of 10 points each took approximately 40 ms at this default.
|
|
763
|
+
* The time is near the runs times the inputs whose step changes the days.
|
|
764
|
+
*/
|
|
765
|
+
export declare const SENSITIVITY_RUNS = 1e3;
|
|
766
|
+
/** The options of `enduranceSensitivity`: the options of a case, the horizon of the chance, the step and the runs of the bootstrap. */
|
|
731
767
|
export interface SensitivityOptions extends CaseOptions, ShortfallOptions {
|
|
732
768
|
/** The step of each input, a number more than 0, in the unit of the input. The default is `SENSITIVITY_STEP`. */
|
|
733
769
|
readonly step?: number | undefined;
|
|
770
|
+
/**
|
|
771
|
+
* The count of the runs of the bootstrap of the interval of a stop of two or more cuts, a whole number from 1. Since 0.8.31.
|
|
772
|
+
* The default is `SENSITIVITY_RUNS`. The cost of the interval of each draw and each input is near this count times one `eventStop`.
|
|
773
|
+
*/
|
|
774
|
+
readonly runs?: number | undefined;
|
|
734
775
|
}
|
|
735
776
|
/** The kind of an input: the amount of a store, the rate of a draw, or a parameter of a converter. */
|
|
736
777
|
export type SensitivityKind = "store" | "draw" | "converter";
|
|
737
778
|
/**
|
|
738
|
-
* The 95% interval of the change of the chance (`SensitivityChance.change`), from the sampling error of the
|
|
739
|
-
*
|
|
740
|
-
*
|
|
779
|
+
* The 95% interval of the change of the chance (`SensitivityChance.change`), from the sampling error of the curves of the cuts. Since 0.8.27.
|
|
780
|
+
*
|
|
781
|
+
* - With one cut, the ends are the change minus and plus `Z95` times `se`. It is a Wald interval.
|
|
782
|
+
* Near the ends of the range, its coverage can be less than 95%.
|
|
783
|
+
* - With two or more cuts, the ends come from a parametric bootstrap of the curves of the cuts (since 0.8.31). Refer to `enduranceSensitivity`.
|
|
784
|
+
* - The ends are clamped to 0 to 1, or to -1 to 0 for a change down.
|
|
741
785
|
*/
|
|
742
786
|
export interface ChanceInterval {
|
|
743
|
-
/**
|
|
787
|
+
/**
|
|
788
|
+
* The standard error of the change. With one cut, it is the Greenwood standard error.
|
|
789
|
+
* It includes the covariance of the chances of the curve at the days before and after the step.
|
|
790
|
+
* With two or more cuts, it is the width of the bootstrap interval before the clamp, divided by `2 * Z95`.
|
|
791
|
+
*/
|
|
744
792
|
readonly se: number;
|
|
745
793
|
readonly low: number;
|
|
746
794
|
readonly high: number;
|
|
795
|
+
/** The count of the runs of the bootstrap, for a stop of two or more cuts. With one cut, it is absent. Since 0.8.31. */
|
|
796
|
+
readonly runs?: number | undefined;
|
|
797
|
+
}
|
|
798
|
+
/** The 95% interval of the change of the chance for each curve of the stop (`SensitivityChance.intervals`). Since 0.8.32. */
|
|
799
|
+
export interface CurveIntervals {
|
|
800
|
+
readonly event: ChanceInterval;
|
|
801
|
+
readonly independent: ChanceInterval;
|
|
802
|
+
readonly upper: ChanceInterval;
|
|
747
803
|
}
|
|
748
804
|
/**
|
|
749
805
|
* The change in the chance that a draw gets its need through the event (`DrawOutlook.lasts`), for one input.
|
|
@@ -757,15 +813,26 @@ export interface SensitivityChance {
|
|
|
757
813
|
/** The chance after the step minus the chance before it, for each curve. It is the change of the point values. */
|
|
758
814
|
readonly change: CurveValues;
|
|
759
815
|
/**
|
|
760
|
-
* The 95% interval of `change
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
* Without sums and counts, the interval is also absent. Since 0.8.30, the sums give the interval with no counts.
|
|
816
|
+
* The 95% interval of `change.event`. Since 0.8.27.
|
|
817
|
+
* Each cut that the stop of the draw uses must have sums (`Cut.sums`) or counts (`Cut.counts`) with no fault.
|
|
818
|
+
* Without sums and counts, the interval is absent. Since 0.8.30, the sums give the interval with no counts.
|
|
764
819
|
*
|
|
765
|
-
* With
|
|
766
|
-
*
|
|
820
|
+
* - With one cut, the three curves of the stop are the curve of the cut, so the three changes are equal.
|
|
821
|
+
* The interval comes from the delta method (`survivalCombination`).
|
|
822
|
+
* - With two or more cuts, the curves of the stop are not smooth functions of the curves of the cuts. Thus the delta method does not apply.
|
|
823
|
+
* The interval comes from a parametric bootstrap of the curves of the cuts (since 0.8.31).
|
|
824
|
+
* - It is equal to `intervals.event`. `intervals` also gives the intervals of the independent and upper curves.
|
|
767
825
|
*/
|
|
768
826
|
readonly interval?: ChanceInterval | undefined;
|
|
827
|
+
/**
|
|
828
|
+
* The 95% interval of the change of each curve of the stop. It is present when `interval` is present. Since 0.8.32.
|
|
829
|
+
*
|
|
830
|
+
* - With one cut, the three changes are equal. Thus the three intervals are the interval of the delta method.
|
|
831
|
+
* - With two or more cuts, one bootstrap gives the three intervals. Each run makes the three curves of the stop from the same drawn curves.
|
|
832
|
+
* - When `StopCurves.independentUpper` is true, the independent curve is the upper curve. Then their intervals are equal.
|
|
833
|
+
* - Each interval has the rules of `interval`, and the same kink caveat. The upper curve has a kink where the sum of the chances reaches 1.
|
|
834
|
+
*/
|
|
835
|
+
readonly intervals?: CurveIntervals | undefined;
|
|
769
836
|
/** The values before the step at the two ends of the sampling bands of the cuts (`DrawOutlook.band`). */
|
|
770
837
|
readonly beforeBand?: DrawBand | undefined;
|
|
771
838
|
/** The values after the step at the two ends of the sampling bands of the cuts. */
|
|
@@ -836,10 +903,19 @@ export interface Sensitivity {
|
|
|
836
903
|
* - The days are exact for the inputs. `chance` is the chance that a draw gets its need through the event. It comes
|
|
837
904
|
* from `caseOutlook` with the share `take`, before and after the step, with the bands of the cuts. The change of the
|
|
838
905
|
* chance is the change of the point values.
|
|
839
|
-
* - The change has a 95% interval (`SensitivityChance.interval`) when the stop of the draw
|
|
840
|
-
* A
|
|
841
|
-
*
|
|
842
|
-
*
|
|
906
|
+
* - The change has a 95% interval (`SensitivityChance.interval`) when each cut of the stop of the draw (`stopCuts`) has sums or counts.
|
|
907
|
+
* A cut with no sums and no counts, or with only reads that have a fault, gives no interval.
|
|
908
|
+
* - With one cut, the interval comes from the delta method of the Greenwood sums.
|
|
909
|
+
* - With two or more cuts, the interval comes from a parametric bootstrap of the curves of the cuts (`survivalBootstrap` of rigor-statistics).
|
|
910
|
+
* Each run draws each curve, makes the event curve of the stop from the drawn curves, and reads the change. The draws of the cuts are independent.
|
|
911
|
+
* - `intervals` gives the interval of the change of each of the three curves. One bootstrap gives the three, from the same runs (since 0.8.32).
|
|
912
|
+
* - The bootstrap is correct only for large samples. At a kink of a curve, its coverage is less than 95%.
|
|
913
|
+
* An example is two cuts with equal curves under a maximum: the coverage of a percentile interval is near 0.89 there.
|
|
914
|
+
* - The seed of the bootstrap is the hash of the case, the need and the input. The same query gives the same interval.
|
|
915
|
+
*
|
|
916
|
+
* The cost is one `enduranceOf` and one `caseOutlook` for each input, and one `stopRebuild` for each draw of the base.
|
|
917
|
+
* With two or more cuts, the intervals of each draw and each input add `runs` draws of the curves and `runs` uses of `StopRebuild.curvesWith`.
|
|
918
|
+
* The function is pure.
|
|
843
919
|
*
|
|
844
920
|
* @param layer - The endurance layer
|
|
845
921
|
* @param caseCuts - The case
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["CutBound"],"sources":["../src/converter.ts","../src/supply.ts","../src/calendar.ts","../src/endurance.ts","../src/joint.ts","../src/best.ts","../src/shortfall.ts","../src/check.ts","../src/join.ts","../src/sample.ts","../src/sensitivity.ts","../src/buy.ts"],"mappings":";;;;;;wBAegB,SAAS,WAAW;;wBAwBpB,SAAS,WAAW;;wBAKpB,aAAa,WAAW;;wBAKxB,cAAc,YAAY,SAAS,aAAa;;wBAOhD,QAAQ,QAAQ,wCAAwC,aAAa;;wBCnDrE,WAAW,MAAM,MAAM,UAAU;;UAKhC;WACN;WACA;WACA;WACA;;;UAIM;;WAEN,OAAO;WACP,UAAU;;WAEV,eAAe;;WAEf;;WAEA,OAAO;;;wBCZF,QAAQ,OAAO,SAAS;;;;;wBASxB,WAAW,OAAO,SAAS;;iBCX1B;;WAEN,IAAI;;WAEJ,QAAQ;;WAER;;;;;;WAMA,QAAQ;;;;;;WAMR;;;qBAIE;;;;;wBAMG,YAAY,UAAU,UAAU,SAAS,KAAK,iCAAiC;;;;;;;wBAqB/E,aAAa,OAAO,gBAAgB,IAAI,SAAS,eAAc,sBAAkC;;;;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,YAAY,kDAAkD,mBAAyC;;;;;iBAiKvI;WACN,OAAO;;WAEP,aAAa;WACb,OAAO;;;;;WAKP;;WAEA;;;;;;WAMA,OAAOA;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["CutBound"],"sources":["../src/converter.ts","../src/supply.ts","../src/calendar.ts","../src/endurance.ts","../src/joint.ts","../src/best.ts","../src/shortfall.ts","../src/check.ts","../src/join.ts","../src/sample.ts","../src/sensitivity.ts","../src/buy.ts"],"mappings":";;;;;;wBAegB,SAAS,WAAW;;wBAwBpB,SAAS,WAAW;;wBAKpB,aAAa,WAAW;;wBAKxB,cAAc,YAAY,SAAS,aAAa;;wBAOhD,QAAQ,QAAQ,wCAAwC,aAAa;;wBCnDrE,WAAW,MAAM,MAAM,UAAU;;UAKhC;WACN;WACA;WACA;WACA;;;UAIM;;WAEN,OAAO;WACP,UAAU;;WAEV,eAAe;;WAEf;;WAEA,OAAO;;;wBCZF,QAAQ,OAAO,SAAS;;;;;wBASxB,WAAW,OAAO,SAAS;;iBCX1B;;WAEN,IAAI;;WAEJ,QAAQ;;WAER;;;;;;WAMA,QAAQ;;;;;;WAMR;;;qBAIE;;;;;wBAMG,YAAY,UAAU,UAAU,SAAS,KAAK,iCAAiC;;;;;;;wBAqB/E,aAAa,OAAO,gBAAgB,IAAI,SAAS,eAAc,sBAAkC;;;;;wBAejG,UAAU,OAAO,gBAAgB,UAAU,UAAU,cAAc,sBAAsB;;;;;;;;wBAyMzF,QAAQ,QAAQ,KAAK,wBAAwB,OAAO,SAAS;;;;;wBAqG7D,aAAa,OAAO,gBAAgB,cAAc,qBAAqB,SAAS,cAAc;;;;;;wBAkB9F,UAAU,OAAO,gBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA8C/C,YAAY,OAAO,gBAAgB,UAAU,UAAU,SAAS,cAAc;;iBC/a7E;WACN;WACA,IAAI;;;;;WAKJ;;WAEA;;WAEA;;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, neg, sign, sub, toNumber } from "@mark1russell7/rational";
|
|
5
5
|
import { solveLexicographic } from "@mark1russell7/linear";
|
|
6
6
|
import { pathSetReliability, stronglyConnectedComponents } from "@mark1russell7/collections/graph";
|
|
7
|
-
import {
|
|
7
|
+
import { canonicalJson, seedOf } from "@mark1russell7/rigor-generators";
|
|
8
|
+
import { Z95, greenwoodRead, kaplanMeier, survivalBootstrapMany, survivalCombination } from "@mark1russell7/rigor-statistics";
|
|
8
9
|
// src/fit.ts
|
|
9
10
|
/** The relative tolerance of a take and of a fit. */
|
|
10
11
|
const TOLERANCE = 1e-13;
|
|
@@ -2550,23 +2551,35 @@ function stopReadWith(caseCuts, draw, options, stoppedOf) {
|
|
|
2550
2551
|
const unsourced = given.flatMap((curve, index) => curve === void 0 ? [index] : []);
|
|
2551
2552
|
if (unsourced.length > 0 && (sets === void 0 || sets.some((set) => set.some((index) => unsourced.includes(index))))) return void 0;
|
|
2552
2553
|
const kept = given.flatMap((curve, index) => curve === void 0 ? [] : [index]);
|
|
2553
|
-
const
|
|
2554
|
+
const base = kept.map((index) => given[index] ?? []);
|
|
2554
2555
|
const keptStops = (cuts) => stops(cuts.map((index) => kept[index] ?? -1));
|
|
2555
2556
|
const keptSets = sets?.map((set) => set.map((index) => kept.indexOf(index)));
|
|
2556
|
-
const
|
|
2557
|
-
const independent = independentStop(curves, keptSets, budgetsOf(options).maxWork);
|
|
2557
|
+
const { maxWork } = budgetsOf(options);
|
|
2558
2558
|
const used = sets === void 0 ? kept : kept.filter((index) => sets.some((set) => set.includes(index)));
|
|
2559
2559
|
const bound = weakestBound(used.map((index) => caseCuts.cuts[relevant[index] ?? -1]?.bound ?? "law"));
|
|
2560
|
-
|
|
2561
|
-
curves
|
|
2560
|
+
const curvesOf = (curves) => {
|
|
2561
|
+
const upper = upperStop(curves, keptSets);
|
|
2562
|
+
const independent = independentStop(curves, keptSets, maxWork);
|
|
2563
|
+
return {
|
|
2562
2564
|
event: eventStop(curves, keptStops),
|
|
2563
2565
|
independent: independent ?? upper,
|
|
2564
2566
|
upper,
|
|
2565
2567
|
coarse: keptSets === void 0,
|
|
2566
2568
|
independentUpper: independent === void 0,
|
|
2567
2569
|
bound
|
|
2568
|
-
}
|
|
2569
|
-
|
|
2570
|
+
};
|
|
2571
|
+
};
|
|
2572
|
+
const places = used.map((index) => kept.indexOf(index));
|
|
2573
|
+
const changed = (curves) => {
|
|
2574
|
+
const out = [...base];
|
|
2575
|
+
for (const [at, place] of places.entries()) out[place] = curves[at] ?? base[place] ?? [];
|
|
2576
|
+
return out;
|
|
2577
|
+
};
|
|
2578
|
+
return {
|
|
2579
|
+
curves: curvesOf(base),
|
|
2580
|
+
used: used.map((index) => relevant[index] ?? -1),
|
|
2581
|
+
curvesWith: (curves) => curvesOf(changed(curves)),
|
|
2582
|
+
eventWith: (curves) => eventStop(changed(curves), keptStops)
|
|
2570
2583
|
};
|
|
2571
2584
|
}
|
|
2572
2585
|
function stopCurvesWith(caseCuts, draw, options, stoppedOf) {
|
|
@@ -2605,6 +2618,22 @@ function stopCuts(caseCuts, draw, options = {}) {
|
|
|
2605
2618
|
budgetsOf(options);
|
|
2606
2619
|
return stopReadWith(caseCuts, draw, options, stoppedMemo(caseCuts, options))?.used;
|
|
2607
2620
|
}
|
|
2621
|
+
/**
|
|
2622
|
+
* This function gives the cuts of the stop of a draw and the curves of the stop for other curves of these cuts. Since 0.8.31.
|
|
2623
|
+
*
|
|
2624
|
+
* - The sets of cuts come from the needs and the parts of the case, not from the curves. Thus one search of the sets serves each call of `curvesWith`.
|
|
2625
|
+
* - `curvesWith` uses the same functions as `stopCurves`: `eventStop`, `independentStop` and `upperStop`.
|
|
2626
|
+
* - The result is `undefined` when `stopCurves` gives `undefined`.
|
|
2627
|
+
*
|
|
2628
|
+
* @param caseCuts - The case
|
|
2629
|
+
* @param draw - The draw
|
|
2630
|
+
* @param options - The stack or the parts that are also down, and the budgets: as for `stopCurves`
|
|
2631
|
+
* @throws RangeError for a bad `maxSets` or `maxWork`
|
|
2632
|
+
*/
|
|
2633
|
+
function stopRebuild(caseCuts, draw, options = {}) {
|
|
2634
|
+
budgetsOf(options);
|
|
2635
|
+
return stopReadWith(caseCuts, draw, options, stoppedMemo(caseCuts, options));
|
|
2636
|
+
}
|
|
2608
2637
|
function zeroLevels(layer) {
|
|
2609
2638
|
return Object.fromEntries(layer.levels.map((level) => [level, 0]));
|
|
2610
2639
|
}
|
|
@@ -3132,6 +3161,12 @@ const SAMPLE_ENDURANCE = {
|
|
|
3132
3161
|
// src/sensitivity.ts
|
|
3133
3162
|
/** The default step of `enduranceSensitivity`: 1 unit of each input. */
|
|
3134
3163
|
const SENSITIVITY_STEP = 1;
|
|
3164
|
+
/**
|
|
3165
|
+
* The default count of the runs of the bootstrap of the interval of a stop of two or more cuts (`SensitivityOptions.runs`). Since 0.8.31.
|
|
3166
|
+
* One call on a test layer of one store, one draw and two cuts of 10 points each took approximately 40 ms at this default.
|
|
3167
|
+
* The time is near the runs times the inputs whose step changes the days.
|
|
3168
|
+
*/
|
|
3169
|
+
const SENSITIVITY_RUNS = 1e3;
|
|
3135
3170
|
/** This function gives the size of a step down from a value. It is the step, or half the value when the value is not more than the step. */
|
|
3136
3171
|
function stepDown(value, step) {
|
|
3137
3172
|
return value > step ? step : value / 2;
|
|
@@ -3315,14 +3350,10 @@ function countsRead(counts) {
|
|
|
3315
3350
|
return (day) => day > counts.last ? void 0 : greenwoodRead(estimate, day);
|
|
3316
3351
|
}
|
|
3317
3352
|
/**
|
|
3318
|
-
* This function gives the curve of
|
|
3353
|
+
* This function gives the curve of one cut with the Greenwood reads of its estimate, when the cut has sums or counts with no fault.
|
|
3319
3354
|
* The sums come first, because they are the short form. A cut with sums that have a fault uses its counts.
|
|
3320
3355
|
*/
|
|
3321
|
-
function readCurveOf(
|
|
3322
|
-
const draw = layer.draws.find((item) => item.need === need);
|
|
3323
|
-
const used = draw === void 0 ? void 0 : stopCuts(caseCuts, draw, options);
|
|
3324
|
-
if (used === void 0 || used.length !== 1) return void 0;
|
|
3325
|
-
const cut = caseCuts.cuts[used[0] ?? -1];
|
|
3356
|
+
function readCurveOf(cut) {
|
|
3326
3357
|
if (cut?.duration === void 0) return void 0;
|
|
3327
3358
|
if (cut.sums !== void 0 && sumsFault(cut.duration, cut.sums) === void 0) return {
|
|
3328
3359
|
curve: cut.duration,
|
|
@@ -3333,6 +3364,41 @@ function readCurveOf(layer, caseCuts, need, options) {
|
|
|
3333
3364
|
read: countsRead(cut.counts)
|
|
3334
3365
|
};
|
|
3335
3366
|
}
|
|
3367
|
+
/** This function gives a Greenwood read at each point of the curve of a cut. The sums do not decrease, so a rounding below the sum before it is lifted. */
|
|
3368
|
+
function pointReads(curve) {
|
|
3369
|
+
let sum = 0;
|
|
3370
|
+
return curve.curve.map(([time, chance]) => {
|
|
3371
|
+
sum = Math.max(sum, (time > 0 ? curve.read(time)?.sum : void 0) ?? sum);
|
|
3372
|
+
return {
|
|
3373
|
+
time,
|
|
3374
|
+
chance,
|
|
3375
|
+
sum
|
|
3376
|
+
};
|
|
3377
|
+
});
|
|
3378
|
+
}
|
|
3379
|
+
/**
|
|
3380
|
+
* This function gives the reads of the stop of a draw, when each cut that the stop uses has sums or counts with no fault.
|
|
3381
|
+
* With one used cut, it gives the curve of that cut. With two or more used cuts, it gives the reads of each cut at the points of its curve.
|
|
3382
|
+
*/
|
|
3383
|
+
function stopReadsOf(layer, caseCuts, need, options) {
|
|
3384
|
+
const draw = layer.draws.find((item) => item.need === need);
|
|
3385
|
+
const stop = draw === void 0 ? void 0 : stopRebuild(caseCuts, draw, options);
|
|
3386
|
+
if (stop === void 0 || stop.used.length === 0) return void 0;
|
|
3387
|
+
const curves = stop.used.map((index) => readCurveOf(caseCuts.cuts[index]));
|
|
3388
|
+
if (curves.some((curve) => curve === void 0)) return void 0;
|
|
3389
|
+
const [first] = curves;
|
|
3390
|
+
if (curves.length === 1 && first !== void 0) return {
|
|
3391
|
+
kind: "one",
|
|
3392
|
+
curve: first
|
|
3393
|
+
};
|
|
3394
|
+
return {
|
|
3395
|
+
kind: "many",
|
|
3396
|
+
cuts: {
|
|
3397
|
+
stop,
|
|
3398
|
+
reads: curves.map((curve) => curve === void 0 ? [] : pointReads(curve))
|
|
3399
|
+
}
|
|
3400
|
+
};
|
|
3401
|
+
}
|
|
3336
3402
|
/**
|
|
3337
3403
|
* This function gives the points of a curve and their weights in the read of `survivalAt` of the core at `days`.
|
|
3338
3404
|
* Between two points, the read is linear, so it has a weight on each of the two points. After the last point, the read is 0.
|
|
@@ -3373,14 +3439,71 @@ function changeInterval(curve, before, after, horizon, change) {
|
|
|
3373
3439
|
add(before, 1);
|
|
3374
3440
|
add(after, -1);
|
|
3375
3441
|
const { se } = survivalCombination(terms);
|
|
3376
|
-
const
|
|
3377
|
-
const clamp = (value) => Math.min(ceiling, Math.max(floor, value));
|
|
3442
|
+
const clamp = clampOf(before, after, horizon);
|
|
3378
3443
|
return {
|
|
3379
3444
|
se,
|
|
3380
3445
|
low: clamp(change - Z95 * se),
|
|
3381
3446
|
high: clamp(change + Z95 * se)
|
|
3382
3447
|
};
|
|
3383
3448
|
}
|
|
3449
|
+
/** This function clamps an end of an interval of a change to 0 to 1, or to -1 to 0 for a change down. A read at or after the horizon is the last read. */
|
|
3450
|
+
function clampOf(before, after, horizon) {
|
|
3451
|
+
const [floor, ceiling] = (after >= horizon ? 1e400 : after) >= (before >= horizon ? 1e400 : before) ? [0, 1] : [-1, 0];
|
|
3452
|
+
return (value) => Math.min(ceiling, Math.max(floor, value));
|
|
3453
|
+
}
|
|
3454
|
+
/**
|
|
3455
|
+
* This function gives the intervals of the change of the chance of the three curves of the stop.
|
|
3456
|
+
* The intervals come from one parametric bootstrap of the curves of two or more cuts.
|
|
3457
|
+
*
|
|
3458
|
+
* - Each run draws the curve of each used cut with `survivalDraw` of rigor-statistics, at the points of its curve.
|
|
3459
|
+
* - The run makes the three curves of the stop from the drawn curves, with the same minimal sets (`StopRebuild.curvesWith`).
|
|
3460
|
+
* - It reads the chance of each curve before and after the step as `caseOutlook` reads `lasts`. The three statistics are the changes.
|
|
3461
|
+
* - The intervals are the percentile intervals of `survivalBootstrapMany`, clamped as the interval of one cut.
|
|
3462
|
+
* The draws are those of `survivalBootstrap` with the same seed. Thus the event interval is the event interval of 0.8.31.
|
|
3463
|
+
* - When the days do not change in the horizon, the change is 0 in each run. Then each interval is 0 to 0 with no runs.
|
|
3464
|
+
* - The seed is the hash of the case, the need and the input. Thus the same query gives the same intervals.
|
|
3465
|
+
*/
|
|
3466
|
+
function cutsChangeIntervals(cuts, before, after, horizon, runs, seed) {
|
|
3467
|
+
if (before === after || before >= horizon && after >= horizon) {
|
|
3468
|
+
const none = {
|
|
3469
|
+
se: 0,
|
|
3470
|
+
low: 0,
|
|
3471
|
+
high: 0,
|
|
3472
|
+
runs
|
|
3473
|
+
};
|
|
3474
|
+
return {
|
|
3475
|
+
event: none,
|
|
3476
|
+
independent: none,
|
|
3477
|
+
upper: none
|
|
3478
|
+
};
|
|
3479
|
+
}
|
|
3480
|
+
const lasts = (curve, days) => days >= horizon ? 1 : 1 - survivalAt(curve, days);
|
|
3481
|
+
const statistics = (chances) => {
|
|
3482
|
+
const curves = cuts.reads.map((reads, k) => reads.map((read, at) => [read.time, chances[k]?.[at] ?? 0]));
|
|
3483
|
+
const stop = cuts.stop.curvesWith(curves);
|
|
3484
|
+
return [
|
|
3485
|
+
stop.event,
|
|
3486
|
+
stop.independent,
|
|
3487
|
+
stop.upper
|
|
3488
|
+
].map((curve) => lasts(curve, after) - lasts(curve, before));
|
|
3489
|
+
};
|
|
3490
|
+
const clamp = clampOf(before, after, horizon);
|
|
3491
|
+
const [event, independent, upper] = survivalBootstrapMany(cuts.reads, statistics, {
|
|
3492
|
+
runs,
|
|
3493
|
+
seed
|
|
3494
|
+
}).map(({ low, high }) => ({
|
|
3495
|
+
se: (high - low) / (2 * Z95),
|
|
3496
|
+
low: clamp(low),
|
|
3497
|
+
high: clamp(high),
|
|
3498
|
+
runs
|
|
3499
|
+
}));
|
|
3500
|
+
if (event === void 0 || independent === void 0 || upper === void 0) throw new Error("survivalBootstrapMany gave fewer than 3 intervals.");
|
|
3501
|
+
return {
|
|
3502
|
+
event,
|
|
3503
|
+
independent,
|
|
3504
|
+
upper
|
|
3505
|
+
};
|
|
3506
|
+
}
|
|
3384
3507
|
/** This function compares two inputs for the rank: the sums of the levels in the order of the levels, the largest first, then the key. */
|
|
3385
3508
|
function rankOrder$1(levels) {
|
|
3386
3509
|
return (a, b) => {
|
|
@@ -3410,10 +3533,19 @@ function rankOrder$1(levels) {
|
|
|
3410
3533
|
* - The days are exact for the inputs. `chance` is the chance that a draw gets its need through the event. It comes
|
|
3411
3534
|
* from `caseOutlook` with the share `take`, before and after the step, with the bands of the cuts. The change of the
|
|
3412
3535
|
* chance is the change of the point values.
|
|
3413
|
-
* - The change has a 95% interval (`SensitivityChance.interval`) when the stop of the draw
|
|
3414
|
-
* A
|
|
3536
|
+
* - The change has a 95% interval (`SensitivityChance.interval`) when each cut of the stop of the draw (`stopCuts`) has sums or counts.
|
|
3537
|
+
* A cut with no sums and no counts, or with only reads that have a fault, gives no interval.
|
|
3538
|
+
* - With one cut, the interval comes from the delta method of the Greenwood sums.
|
|
3539
|
+
* - With two or more cuts, the interval comes from a parametric bootstrap of the curves of the cuts (`survivalBootstrap` of rigor-statistics).
|
|
3540
|
+
* Each run draws each curve, makes the event curve of the stop from the drawn curves, and reads the change. The draws of the cuts are independent.
|
|
3541
|
+
* - `intervals` gives the interval of the change of each of the three curves. One bootstrap gives the three, from the same runs (since 0.8.32).
|
|
3542
|
+
* - The bootstrap is correct only for large samples. At a kink of a curve, its coverage is less than 95%.
|
|
3543
|
+
* An example is two cuts with equal curves under a maximum: the coverage of a percentile interval is near 0.89 there.
|
|
3544
|
+
* - The seed of the bootstrap is the hash of the case, the need and the input. The same query gives the same interval.
|
|
3415
3545
|
*
|
|
3416
|
-
* The cost is one `enduranceOf` and one `caseOutlook` for each input, and one `
|
|
3546
|
+
* The cost is one `enduranceOf` and one `caseOutlook` for each input, and one `stopRebuild` for each draw of the base.
|
|
3547
|
+
* With two or more cuts, the intervals of each draw and each input add `runs` draws of the curves and `runs` uses of `StopRebuild.curvesWith`.
|
|
3548
|
+
* The function is pure.
|
|
3417
3549
|
*
|
|
3418
3550
|
* @param layer - The endurance layer
|
|
3419
3551
|
* @param caseCuts - The case
|
|
@@ -3422,9 +3554,11 @@ function rankOrder$1(levels) {
|
|
|
3422
3554
|
* @throws RangeError for a step that is not a finite number more than 0, and for the errors of `enduranceOf` and `caseOutlook`
|
|
3423
3555
|
*/
|
|
3424
3556
|
function enduranceSensitivity(layer, caseCuts, options) {
|
|
3425
|
-
const { step: given, ...caseOptions } = options;
|
|
3557
|
+
const { step: given, runs: givenRuns, ...caseOptions } = options;
|
|
3426
3558
|
const step = given ?? 1;
|
|
3427
3559
|
if (!(step > 0) || !Number.isFinite(step)) throw new RangeError(`The step ${String(given)} is not a finite number more than 0.`);
|
|
3560
|
+
const runs = givenRuns ?? 1e3;
|
|
3561
|
+
if (!Number.isInteger(runs) || runs < 1) throw new RangeError(`The option runs is ${String(givenRuns)}: it is not a whole number from 1.`);
|
|
3428
3562
|
const base = enduranceOf(layer, caseCuts, caseOptions);
|
|
3429
3563
|
const outlookOf = (changed) => new Map(caseOutlook(changed, caseCuts, {
|
|
3430
3564
|
...caseOptions,
|
|
@@ -3432,7 +3566,7 @@ function enduranceSensitivity(layer, caseCuts, options) {
|
|
|
3432
3566
|
}).draws.map((draw) => [draw.need, draw]));
|
|
3433
3567
|
const baseOutlook = outlookOf(layer);
|
|
3434
3568
|
const counted = new Map([...baseOutlook.keys()].flatMap((need) => {
|
|
3435
|
-
const read =
|
|
3569
|
+
const read = stopReadsOf(layer, caseCuts, need, caseOptions);
|
|
3436
3570
|
return read === void 0 ? [] : [[need, read]];
|
|
3437
3571
|
}));
|
|
3438
3572
|
const horizon = caseOptions.horizon ?? 1e400;
|
|
@@ -3451,14 +3585,26 @@ function enduranceSensitivity(layer, caseCuts, options) {
|
|
|
3451
3585
|
const to = outlook?.get(need);
|
|
3452
3586
|
const read = counted.get(need);
|
|
3453
3587
|
const moved = from === void 0 || to === void 0 ? void 0 : minus(to.lasts, from.lasts);
|
|
3454
|
-
const
|
|
3588
|
+
const one = read?.kind === "one" && from !== void 0 && to !== void 0 && moved !== void 0 ? changeInterval(read.curve, from.days, to.days, horizon, moved.event) : void 0;
|
|
3589
|
+
const intervals = one !== void 0 ? {
|
|
3590
|
+
event: one,
|
|
3591
|
+
independent: one,
|
|
3592
|
+
upper: one
|
|
3593
|
+
} : read?.kind === "many" && from !== void 0 && to !== void 0 ? cutsChangeIntervals(read.cuts, from.days, to.days, horizon, runs, seedOf(canonicalJson([
|
|
3594
|
+
caseCuts.case,
|
|
3595
|
+
need,
|
|
3596
|
+
variant.id
|
|
3597
|
+
]))) : void 0;
|
|
3455
3598
|
const chance = from === void 0 || to === void 0 || moved === void 0 ? {} : { chance: {
|
|
3456
3599
|
before: from.lasts,
|
|
3457
3600
|
after: to.lasts,
|
|
3458
3601
|
change: moved,
|
|
3459
3602
|
...from.band === void 0 ? {} : { beforeBand: from.band },
|
|
3460
3603
|
...to.band === void 0 ? {} : { afterBand: to.band },
|
|
3461
|
-
...
|
|
3604
|
+
...intervals === void 0 ? {} : {
|
|
3605
|
+
interval: intervals.event,
|
|
3606
|
+
intervals
|
|
3607
|
+
}
|
|
3462
3608
|
} };
|
|
3463
3609
|
return {
|
|
3464
3610
|
need,
|
|
@@ -3583,6 +3729,6 @@ function daysPerDollar(sensitivity, prices, options) {
|
|
|
3583
3729
|
unused
|
|
3584
3730
|
};
|
|
3585
3731
|
}
|
|
3586
|
-
export { ENDURANCE_CODES, ENDURANCE_SCHEMA, INDEPENDENT_MAX_WORK, INDEPENDENT_TOLERANCE, MINIMAL_STOP_CUTS, SAMPLE_ENDURANCE, SAMPLE_ENDURANCE_STACK, SEASON_HORIZON_DAYS, SENSITIVITY_STEP, SHARES, YEAR_STARTS, bestEndurance, caseDraws, caseOutlook, caseShortfall, caseStopped, checkEndurance, curveFault, daysPerDollar, drawDemand, enduranceOf, enduranceSensitivity, eventStop, giftNeed, giftResource, hasEnduranceError, hasSeason, heldTail, independentStop, isSource, joinEndurance, jointDays, longestStop, minimalStops, monthEdges, monthOf, monthlyShares, seasonSupply, shareOf, sowDays, stopCurves, stopCuts, storeAmounts, survivalAt, survivalQuantile, tailDays, upperStop, yearChance, yearRate, yearShortfall };
|
|
3732
|
+
export { ENDURANCE_CODES, ENDURANCE_SCHEMA, INDEPENDENT_MAX_WORK, INDEPENDENT_TOLERANCE, MINIMAL_STOP_CUTS, SAMPLE_ENDURANCE, SAMPLE_ENDURANCE_STACK, SEASON_HORIZON_DAYS, SENSITIVITY_RUNS, SENSITIVITY_STEP, SHARES, YEAR_STARTS, bestEndurance, caseDraws, caseOutlook, caseShortfall, caseStopped, checkEndurance, curveFault, daysPerDollar, drawDemand, enduranceOf, enduranceSensitivity, eventStop, giftNeed, giftResource, hasEnduranceError, hasSeason, heldTail, independentStop, isSource, joinEndurance, jointDays, longestStop, minimalStops, monthEdges, monthOf, monthlyShares, seasonSupply, shareOf, sowDays, stopCurves, stopCuts, stopRebuild, storeAmounts, survivalAt, survivalQuantile, tailDays, upperStop, yearChance, yearRate, yearShortfall };
|
|
3587
3733
|
|
|
3588
3734
|
//# sourceMappingURL=index.js.map
|