mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 23:12:04 +00:00
fix(cycle): raise the hard cycle-length ceiling so long cycles survive
The hard upper bound clamped cycle lengths at 45 days, force-excluding any longer cycle as an outlier before the robust statistics ran. Cycles over 35 days are oligomenorrhea but still real, and adolescent and perimenopausal users routinely run to fifty days or more — exactly the irregular users for whom an honest estimate matters most. Clamping their genuine cycles biased the estimate toward the population middle. Raise the ceiling to 60 days. It stays a coarse gross-error backstop; the median-plus-MAD fence and the missed-log heuristic still do the real outlier work, and because the fence is computed before exclusion, raising the ceiling does not move it — it only stops the hard rule from pre-empting the fence on long but consistent cycles.
This commit is contained in:
1 parent
f5798e20d8
commit
df67b60420
2 files changed
+27
-2
No files matched your search
@@ -88,6 +88,17 @@ describe("cycle/prediction — cycle-length estimator (§1, §5)", () => {
|
||||
expect(est.lengthRounded).toBe(28);
|
||||
});
|
||||
|
||||
it("keeps a legitimate long (oligomenorrhea) cycle inside the hard bound", () => {
|
||||
// A run of long-but-real cycles (ACOG: > 35 d is oligomenorrhea, still a
|
||||
// real cycle; perimenopause routinely runs longer). A 52-day length must
|
||||
// not be force-excluded by the hard ceiling — only the MAD fence / missed-
|
||||
// log heuristic should ever drop it. Here the whole run is long, so the
|
||||
// robust median sits near 50 and 52 is well inside the fence.
|
||||
const est = estimateCycleLength([48, 50, 52, 49, 51], "PERIMENOPAUSE");
|
||||
expect(est.cyclesObserved).toBe(5); // none clipped by HARD_CYCLE_MAX
|
||||
expect(est.lengthRounded).toBe(50);
|
||||
});
|
||||
|
||||
it("perimenopause widens the fence (OUTLIER_K 4 keeps more)", () => {
|
||||
const lengths = [28, 30, 26, 40, 24, 32];
|
||||
const normal = estimateCycleLength(lengths, "TRYING_TO_CONCEIVE");
|
||||
|
||||
Reference in new issue
Block a user