@mark1russell7/stack-endurance 0.8.29 → 0.8.30
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 +6 -3
- package/build/add-on.js +1 -1
- package/build/index.d.ts +7 -5
- package/build/index.d.ts.map +1 -1
- package/build/index.js +54 -31
- package/build/index.js.map +1 -1
- package/build/{join-NN0eFb6s.js → join-CsR-FKzr.js} +7 -3
- package/build/join-CsR-FKzr.js.map +1 -0
- package/build/schema.d.ts.map +1 -1
- package/build/schema.js +1 -0
- package/build/schema.js.map +1 -1
- package/package.json +3 -3
- package/build/join-NN0eFb6s.js.map +0 -1
package/README.md
CHANGED
|
@@ -100,6 +100,8 @@ A cut can have no `duration`, as before a source gives its curve. Then each draw
|
|
|
100
100
|
|
|
101
101
|
The gate checks the counts of a cut (`Cut.counts`) with `countsFault` of the core. Counts that do not give the curve of the cut, or counts on a cut with no curve, are the error `endurance-curve`. Since 0.8.27.
|
|
102
102
|
|
|
103
|
+
The gate checks the sums of a cut (`Cut.sums`) with `sumsFault` of the core in the same way. Since 0.8.30.
|
|
104
|
+
|
|
103
105
|
Since 0.8.4, `stopCurves`, `caseShortfall` and `yearShortfall` give a `bound`: the weakest bound of the curves that the result uses (`weakestBound` of the core). A cut with no `bound` has a law. The shortfall does not decrease when a cut lasts longer, so the bound of each curve carries to the result.
|
|
104
106
|
|
|
105
107
|
| Bounds of the curves | Bound of the result |
|
|
@@ -146,9 +148,10 @@ Two groups of cuts that share no minimal set are independent, so the independent
|
|
|
146
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.
|
|
147
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.
|
|
148
150
|
- `chance.interval` gives the 95% interval of the change (`ChanceInterval`: `se`, `low` and `high`). Since 0.8.27 (M2-sensitivity-interval).
|
|
149
|
-
- The stop of the draw must use one cut (`stopCuts`)
|
|
150
|
-
-
|
|
151
|
-
- The
|
|
151
|
+
- The stop of the draw must use one cut (`stopCuts`). That cut must have sums (`Cut.sums` of the core) or counts (`Cut.counts`) with no fault. Else the interval is absent.
|
|
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
|
+
- 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
|
+
- `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)`.
|
|
152
155
|
- A stop of two or more cuts has no interval. Its event curve and upper curve are not smooth functions of the curves of the cuts. Its independent curve has a term for each state of the cuts.
|
|
153
156
|
|
|
154
157
|
An example on the sample:
|
package/build/add-on.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as checkEndurance, t as joinEndurance } from "./join-
|
|
1
|
+
import { r as checkEndurance, t as joinEndurance } from "./join-CsR-FKzr.js";
|
|
2
2
|
import { t as ENDURANCE_SCHEMA } from "./layer-a3Fr70Uh.js";
|
|
3
3
|
import { parseEndurance } from "./schema.js";
|
|
4
4
|
// src/add-on.ts
|
package/build/index.d.ts
CHANGED
|
@@ -659,7 +659,8 @@ export declare function caseOutlook(layer: EnduranceLayer, caseCuts: CaseCuts, o
|
|
|
659
659
|
* A converter with a limit can take nothing: it is a source, for example a solar panel. Since 0.8.20 (M2-solar).
|
|
660
660
|
* - `endurance-curve`: a survival curve does not start at `[0, 1]`, or it does not end at a chance of 0.
|
|
661
661
|
* Or its days do not increase, or its chance increases.
|
|
662
|
-
* Or the band or the
|
|
662
|
+
* Or the band, the counts or the sums of a cut do not agree with its curve (`bandFault`, `countsFault`, `sumsFault`).
|
|
663
|
+
* Or the cut has them and no curve.
|
|
663
664
|
* - `endurance-bound`: the bound of a cut is not a value of `CUT_BOUNDS` of the core. Since 0.8.4.
|
|
664
665
|
* - `endurance-prior-case`: a prior names a case that the layer does not have.
|
|
665
666
|
* - `endurance-cycle`: converters make a resource from itself, through one converter or a chain. One fault names each cycle.
|
|
@@ -756,9 +757,10 @@ export interface SensitivityChance {
|
|
|
756
757
|
/** The chance after the step minus the chance before it, for each curve. It is the change of the point values. */
|
|
757
758
|
readonly change: CurveValues;
|
|
758
759
|
/**
|
|
759
|
-
* The 95% interval of `change`, when the stop of the draw uses one cut
|
|
760
|
+
* The 95% interval of `change`, when the stop of the draw uses one cut. Since 0.8.27.
|
|
761
|
+
* That cut must have sums (`Cut.sums`) or counts (`Cut.counts`) with no fault.
|
|
760
762
|
* With one cut, the three curves of the stop are the curve of the cut, so the three changes are equal.
|
|
761
|
-
* Without counts, the interval is also absent.
|
|
763
|
+
* Without sums and counts, the interval is also absent. Since 0.8.30, the sums give the interval with no counts.
|
|
762
764
|
*
|
|
763
765
|
* With two or more cuts, the interval is absent. The event curve and the upper curve are not smooth functions of the curves
|
|
764
766
|
* of the cuts (a maximum, and a sum with a limit). The independent curve is a polynomial with a term for each state of the cuts.
|
|
@@ -834,8 +836,8 @@ export interface Sensitivity {
|
|
|
834
836
|
* - The days are exact for the inputs. `chance` is the chance that a draw gets its need through the event. It comes
|
|
835
837
|
* from `caseOutlook` with the share `take`, before and after the step, with the bands of the cuts. The change of the
|
|
836
838
|
* chance is the change of the point values.
|
|
837
|
-
* - The change has a 95% interval (`SensitivityChance.interval`) when the stop of the draw uses one cut (`stopCuts`) with counts.
|
|
838
|
-
* A stop of two or more cuts has no interval. A cut with no counts, or with
|
|
839
|
+
* - The change has a 95% interval (`SensitivityChance.interval`) when the stop of the draw uses one cut (`stopCuts`) with sums or counts.
|
|
840
|
+
* A stop of two or more cuts has no interval. A cut with no sums and no counts, or with only reads that have a fault, also has no interval.
|
|
839
841
|
*
|
|
840
842
|
* The cost is one `enduranceOf` and one `caseOutlook` for each input, and one `stopCuts` for each draw of the base. The function is pure.
|
|
841
843
|
*
|
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;;;;;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;;;;;;WAMA,OAAO,SAAS,eAAe,SAAS;;;;;WAKxC;;WAEA,MAAM,SAAS;;;;;;W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AiCpH;;qBAGC,iBAAiB;;iBAeb,6BAA6B,aAAa;;;;;;WAMhD,QAAQ;;;;;;;WAOR;;;qBAIE;;YAGD,gBAAgB,KAAK;;;;;;;iBAQhB;;WAEN;WACA,KAAK;WACL,MAAM;;WAEN;;;iBAIM;WACN;;WAEA;;WAEA,yBAAyB,aAAa;;WAEtC,WAAW;;WAEX,WAAW;;WAEX,kBAAkB;;;iBAIZ;WACN,OAAO;WACP,WAAW;;;iBAIL,sBAAsB;WAC5B;;WAEA,gBAAgB;;WAEhB,QAAQ;;;;;;;;;;;;;;;;;;;wBAoBH,cAAc,OAAO,gBAAgB,eAAe,SAAS,uBAAuB;;YA0ExF,iBAAiB;;iBAGZ;;WAEN;;WAEA;;WAEA;;;iBAIM;WACN,OAAO;WACP,WAAW;;;;;;;iBAQL;WACN,SAAS;WACT,QAAQ;;;iBAIF;WACN;WACA;WACA;WACA;;WAEA;;WAEA;;;;;;WAMA,OAAO;;WAEP,WAAW;;WAEX,OAAOA;;WAEP;;;;;WAKA,OAAO;;;iBAID;WACN;WACA;WACA;WACA,OAAO;;WAEP;;WAEA,gBAAgB;;WAEhB;;WAEA;;WAEA,OAAOA;;;;;;;;;;;;;;;;wBAiBF,YAAY,OAAO,gBAAgB,UAAU,UAAU,SAAS,iBAAiB
|
|
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;;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;WAElB,WAAW,SAAS;;;iBAId;WACN;WACA,MAAM;WACN;WACA;;WAEA,SAAS,SAAS;WAClB,QAAQ;;;iBAIF;WACN;WACA,IAAI;;WAEJ;;WAEA,iBAAiB;;WAEjB,mBAAmB;;WAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAgDK,cAAc,aAAa,aAAa,QAAQ,YAAY,SAAS,uBAAuB"}
|
package/build/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as ENDURANCE_SCHEMA } from "./layer-a3Fr70Uh.js";
|
|
2
|
-
import { a as hasEnduranceError, c as giftNeed, d as isSource, f as monthlyShares, i as curveFault, l as giftResource, n as ENDURANCE_CODES, o as canRun, p as shareOf, r as checkEndurance, s as deviceKey, t as joinEndurance, u as inputsOf } from "./join-
|
|
3
|
-
import { DEFAULT_MAX_SETS, STACK_SCHEMA, countsFault, dateOfDay, dayNumber, neededParts, stopSets, stopped, survivalAt, weakestBound } from "@mark1russell7/system-stack";
|
|
2
|
+
import { a as hasEnduranceError, c as giftNeed, d as isSource, f as monthlyShares, i as curveFault, l as giftResource, n as ENDURANCE_CODES, o as canRun, p as shareOf, r as checkEndurance, s as deviceKey, t as joinEndurance, u as inputsOf } from "./join-CsR-FKzr.js";
|
|
3
|
+
import { DEFAULT_MAX_SETS, STACK_SCHEMA, countsFault, dateOfDay, dayNumber, neededParts, stopSets, stopped, sumsFault, survivalAt, weakestBound } from "@mark1russell7/system-stack";
|
|
4
4
|
import { ONE, ZERO, add, div, equals, fromFloat, mul, 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 { Z95, kaplanMeier,
|
|
7
|
+
import { Z95, greenwoodRead, kaplanMeier, survivalCombination } from "@mark1russell7/rigor-statistics";
|
|
8
8
|
// src/fit.ts
|
|
9
9
|
/** The relative tolerance of a take and of a fit. */
|
|
10
10
|
const TOLERANCE = 1e-13;
|
|
@@ -3291,17 +3291,46 @@ function estimateOf(counts) {
|
|
|
3291
3291
|
});
|
|
3292
3292
|
return kaplanMeier(observations);
|
|
3293
3293
|
}
|
|
3294
|
-
/**
|
|
3295
|
-
function
|
|
3294
|
+
/**
|
|
3295
|
+
* This function gives the Greenwood reads of a curve from its sums. The read at a day is the read of the last point at or before that day.
|
|
3296
|
+
* This is the step rule of a Kaplan-Meier curve. `changeInterval` reads only the days of the points, so each read is the read of a point.
|
|
3297
|
+
*/
|
|
3298
|
+
function sumsRead(curve, sums) {
|
|
3299
|
+
return (day) => {
|
|
3300
|
+
let found;
|
|
3301
|
+
for (const [index, [point, chance]] of curve.entries()) {
|
|
3302
|
+
if (point > day) break;
|
|
3303
|
+
found = {
|
|
3304
|
+
time: day,
|
|
3305
|
+
chance,
|
|
3306
|
+
sum: sums[index] ?? 0
|
|
3307
|
+
};
|
|
3308
|
+
}
|
|
3309
|
+
return found;
|
|
3310
|
+
};
|
|
3311
|
+
}
|
|
3312
|
+
/** This function gives the Greenwood reads of the Kaplan-Meier estimate of a table of counts. A day after `last` has no read. */
|
|
3313
|
+
function countsRead(counts) {
|
|
3314
|
+
const estimate = estimateOf(counts);
|
|
3315
|
+
return (day) => day > counts.last ? void 0 : greenwoodRead(estimate, day);
|
|
3316
|
+
}
|
|
3317
|
+
/**
|
|
3318
|
+
* This function gives the curve of the one cut of the stop of a draw, when that cut has sums or counts with no fault.
|
|
3319
|
+
* The sums come first, because they are the short form. A cut with sums that have a fault uses its counts.
|
|
3320
|
+
*/
|
|
3321
|
+
function readCurveOf(layer, caseCuts, need, options) {
|
|
3296
3322
|
const draw = layer.draws.find((item) => item.need === need);
|
|
3297
3323
|
const used = draw === void 0 ? void 0 : stopCuts(caseCuts, draw, options);
|
|
3298
3324
|
if (used === void 0 || used.length !== 1) return void 0;
|
|
3299
3325
|
const cut = caseCuts.cuts[used[0] ?? -1];
|
|
3300
|
-
if (cut?.duration === void 0
|
|
3301
|
-
return {
|
|
3326
|
+
if (cut?.duration === void 0) return void 0;
|
|
3327
|
+
if (cut.sums !== void 0 && sumsFault(cut.duration, cut.sums) === void 0) return {
|
|
3328
|
+
curve: cut.duration,
|
|
3329
|
+
read: sumsRead(cut.duration, cut.sums)
|
|
3330
|
+
};
|
|
3331
|
+
if (cut.counts !== void 0 && countsFault(cut.duration, cut.counts) === void 0) return {
|
|
3302
3332
|
curve: cut.duration,
|
|
3303
|
-
|
|
3304
|
-
estimate: estimateOf(cut.counts)
|
|
3333
|
+
read: countsRead(cut.counts)
|
|
3305
3334
|
};
|
|
3306
3335
|
}
|
|
3307
3336
|
/**
|
|
@@ -3322,34 +3351,28 @@ function pointWeights(curve, days) {
|
|
|
3322
3351
|
return [];
|
|
3323
3352
|
}
|
|
3324
3353
|
/**
|
|
3325
|
-
* This function gives the interval of the change of the chance, from the counts of the one cut of the stop.
|
|
3354
|
+
* This function gives the interval of the change of the chance, from the sums or the counts of the one cut of the stop.
|
|
3326
3355
|
*
|
|
3327
3356
|
* - The change is `S(before) - S(after)`. A read at or after the horizon is 0, so it adds no term.
|
|
3328
|
-
* - Each read of the curve is a weighted sum of the chances of the estimate at up to two points. A point
|
|
3329
|
-
* -
|
|
3330
|
-
*
|
|
3357
|
+
* - Each read of the curve is a weighted sum of the chances of the estimate at up to two points. A point with no read has the chance 0.
|
|
3358
|
+
* - `survivalCombination` of rigor-statistics gives the Greenwood error of the weighted sum.
|
|
3359
|
+
* The covariance of the chances at two points `a <= b` is `S(a) * S(b) * V(a)`.
|
|
3331
3360
|
*/
|
|
3332
|
-
function changeInterval(
|
|
3361
|
+
function changeInterval(curve, before, after, horizon, change) {
|
|
3333
3362
|
const terms = [];
|
|
3334
3363
|
const add = (days, sign) => {
|
|
3335
3364
|
if (days >= horizon) return;
|
|
3336
|
-
for (const [day, weight] of pointWeights(
|
|
3365
|
+
for (const [day, weight] of pointWeights(curve.curve, days)) {
|
|
3366
|
+
const read = day > 0 ? curve.read(day) : void 0;
|
|
3367
|
+
if (read !== void 0) terms.push({
|
|
3368
|
+
read,
|
|
3369
|
+
weight: sign * weight
|
|
3370
|
+
});
|
|
3371
|
+
}
|
|
3337
3372
|
};
|
|
3338
3373
|
add(before, 1);
|
|
3339
3374
|
add(after, -1);
|
|
3340
|
-
const
|
|
3341
|
-
const difference = survivalDifference(read.estimate, from, to);
|
|
3342
|
-
return difference === void 0 ? void 0 : difference.se * difference.se;
|
|
3343
|
-
};
|
|
3344
|
-
let variance = 0;
|
|
3345
|
-
for (const [a, weightA] of terms) for (const [b, weightB] of terms) {
|
|
3346
|
-
const atA = square(0, a);
|
|
3347
|
-
const atB = square(0, b);
|
|
3348
|
-
const between = square(a, b);
|
|
3349
|
-
if (atA === void 0 || atB === void 0 || between === void 0) return void 0;
|
|
3350
|
-
variance += weightA * weightB * ((atA + atB - between) / 2);
|
|
3351
|
-
}
|
|
3352
|
-
const se = Math.sqrt(Math.max(0, variance));
|
|
3375
|
+
const { se } = survivalCombination(terms);
|
|
3353
3376
|
const [floor, ceiling] = (after >= horizon ? 1e400 : after) >= (before >= horizon ? 1e400 : before) ? [0, 1] : [-1, 0];
|
|
3354
3377
|
const clamp = (value) => Math.min(ceiling, Math.max(floor, value));
|
|
3355
3378
|
return {
|
|
@@ -3387,8 +3410,8 @@ function rankOrder$1(levels) {
|
|
|
3387
3410
|
* - The days are exact for the inputs. `chance` is the chance that a draw gets its need through the event. It comes
|
|
3388
3411
|
* from `caseOutlook` with the share `take`, before and after the step, with the bands of the cuts. The change of the
|
|
3389
3412
|
* chance is the change of the point values.
|
|
3390
|
-
* - The change has a 95% interval (`SensitivityChance.interval`) when the stop of the draw uses one cut (`stopCuts`) with counts.
|
|
3391
|
-
* A stop of two or more cuts has no interval. A cut with no counts, or with
|
|
3413
|
+
* - The change has a 95% interval (`SensitivityChance.interval`) when the stop of the draw uses one cut (`stopCuts`) with sums or counts.
|
|
3414
|
+
* A stop of two or more cuts has no interval. A cut with no sums and no counts, or with only reads that have a fault, also has no interval.
|
|
3392
3415
|
*
|
|
3393
3416
|
* The cost is one `enduranceOf` and one `caseOutlook` for each input, and one `stopCuts` for each draw of the base. The function is pure.
|
|
3394
3417
|
*
|
|
@@ -3409,7 +3432,7 @@ function enduranceSensitivity(layer, caseCuts, options) {
|
|
|
3409
3432
|
}).draws.map((draw) => [draw.need, draw]));
|
|
3410
3433
|
const baseOutlook = outlookOf(layer);
|
|
3411
3434
|
const counted = new Map([...baseOutlook.keys()].flatMap((need) => {
|
|
3412
|
-
const read =
|
|
3435
|
+
const read = readCurveOf(layer, caseCuts, need, caseOptions);
|
|
3413
3436
|
return read === void 0 ? [] : [[need, read]];
|
|
3414
3437
|
}));
|
|
3415
3438
|
const horizon = caseOptions.horizon ?? 1e400;
|