Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d8e151a
Leave long RR artifact runs as gaps
mikenrafter Nov 1, 2026
cdb5124
Reduce spectral error on epoch timestamps
mikenrafter Nov 1, 2026
b7423f8
Abstain when a beat has no finite time
mikenrafter Nov 1, 2026
f54d922
Refuse unidentifiable cosinor fits
mikenrafter Nov 1, 2026
10c6b1c
Retain small TRIMP contributions in the total
mikenrafter Nov 1, 2026
e66cbe1
Evaluate training-load decay with affine arithmetic
mikenrafter Nov 1, 2026
58e4f14
Count repeated zone intervals before summing
mikenrafter Nov 1, 2026
c8e325a
Compute circadian variance with centered moments
mikenrafter Nov 1, 2026
580e167
Compute HRV moments without subtracting a large mean
mikenrafter Nov 1, 2026
c17280c
Make the changed batch outputs independently reproducible
mikenrafter Nov 1, 2026
b5903fd
Repeated calculations need summaries that combine without replay
mikenrafter Nov 1, 2026
0725b69
RR correction and rhythm screening replay settled beats on each sync
mikenrafter Nov 1, 2026
f118248
HRV and respiration updates rescan completed windows
mikenrafter Nov 1, 2026
3c21387
Refuse malformed metric inputs and label capped RR gaps explicitly
mikenrafter Nov 3, 2026
e3426a0
Merge branch 'split/rr-hrv-outputs' into split/area-1-framework
mikenrafter Nov 3, 2026
f9bb3ee
Merge branch 'split/area-1-framework' into split/area-2-rr-rhythm
mikenrafter Nov 3, 2026
51d33e9
Validate cap-only gap labels across streaming and checkpoint paths
mikenrafter Nov 3, 2026
0171a3c
Merge branch 'split/area-2-rr-rhythm' into split/area-3-hrv-respiration
mikenrafter Nov 3, 2026
9eea67c
Refuse overlapping HRV clocks without shifting recorded segment times
mikenrafter Nov 3, 2026
9408e3a
Merge branch 'split/rr-hrv-outputs' into split/area-1-framework
mikenrafter Nov 3, 2026
ecbff93
Merge branch 'split/area-1-framework' into split/area-2-rr-rhythm
mikenrafter Nov 3, 2026
e21147a
Merge branch 'split/area-2-rr-rhythm' into split/area-3-hrv-respiration
mikenrafter Nov 3, 2026
d059e6e
Refuse invalid clocks across spectral consumers and non-finite cosino…
mikenrafter Nov 4, 2026
23b5ae1
Merge branch 'split/rr-hrv-outputs' into split/area-1-framework
mikenrafter Nov 4, 2026
b1fdba5
Merge branch 'split/area-1-framework' into split/area-2-rr-rhythm
mikenrafter Nov 4, 2026
59207de
Merge branch 'split/area-2-rr-rhythm' into split/area-3-hrv-respiration
mikenrafter Nov 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions ALGORITHMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,57 @@ al. 2017 · Pimentel et al. · Brage et al. 2004 · Keytel et al. 2005 · Tudor-
2019 · Hopkins 2004 ·
Mahalanobis 1936 · Killick et al. 2012 · Wittmann & Roenneberg 2006 · Pietilä et al. 2018 ·
Malik et al.

<!-- Split #99: rr -->

| Batch change | Method and limits |
|---|---|
| Leave long RR artifact runs as gaps | Lipponen & Tarvainen 2019; Peltola 2012; The 32-beat cap is an internal ESTIMATE rule with low confidence, not a published threshold. Longer runs split the series; each side is corrected independently. The synthetic 33-beat case keeps 200 NN beats and drops 33. |

<!-- Split #99: spectral -->

| Batch change | Method and limits |
|---|---|
| Reduce spectral error on epoch timestamps | Lomb 1976; Scargle 1982; Press & Rybicki 1989; Evaluate trigonometric arguments relative to the first sample. The mathematical spectrum is time-shift invariant; floating-point band powers and threshold decisions can change for all Lomb-Scargle callers. |

<!-- Split #99: nonfinite -->

| Batch change | Method and limits |
|---|---|
| Abstain when a beat has no finite time | Task Force 1996 HRV; Welch 1967 spectra; input-validity guard is an implementation rule; HRV frequency/time, nocturnal and session RMSSD, RSA and CVHR return absent metrics for non-finite beat times. This prevents endless segment walks and invalid integer conversions. Finite-input formulas are unchanged. |

<!-- Split #99: ['cosinor', 'near_singular'] -->

| Batch change | Method and limits |
|---|---|
| Refuse unidentifiable cosinor fits | Nelson et al. 1979, Methods for cosinor-rhythmometry; Welford 1962 centered co-moments; Use centered least squares and a relative determinant gate of 1e-12 of the diagonal product. This is a numerical policy. Nearly collinear phase columns abstain, and ordinary fit parameters can move in their last digits. Upstream zero-amplitude significance gating is retained. |

<!-- Split #99: trimp -->

| Batch change | Method and limits |
|---|---|
| Retain small TRIMP contributions in the total | Morton, Fitz-Clarke & Banister 1990; Neumaier 1974 compensated summation; Compensate the per-minute sum. The reserve and sex-specific weighting are unchanged; the synthetic total moves in its last digits. |

<!-- Split #99: ctl -->

| Batch change | Method and limits |
|---|---|
| Evaluate training-load decay with affine arithmetic | Banister et al. 1975; Morton et al. 1990; Neumaier 1974 prefix summation; Evaluate the same EWMA recurrence as scale times seed plus offset. This matches the arithmetic used by the later incremental implementation. Last digits change; 42/7-day defaults and bounded-prefix priming remain implementation choices. |

<!-- Split #99: zones -->

| Batch change | Method and limits |
|---|---|
| Count repeated zone intervals before summing | Karvonen 1957 supports reserve zones only; interval credit is an internal ESTIMATE rule; Group equal duration credits by zone. Cadence validation, median capping and tail credit are retained. Grouped multiplication changes the last digits of zone seconds. |

<!-- Split #99: circadian -->

| Batch change | Method and limits |
|---|---|
| Compute circadian variance with centered moments | Witting 1990; van Someren 1999; Welford 1962 centered variance; IS and IV may move in their last digits. Batch circular profile sums and first-winner tie selection are unchanged on the rebased head. Chunked merges can reorder profile sums and move near-tie L5/M10 start epochs; that stream-specific behavior belongs with the aggregators. |

<!-- Split #99: hrv -->

| Batch change | Method and limits |
|---|---|
| Compute HRV moments without subtracting a large mean | Task Force 1996; Welford 1962 centered sums and products; Use origin-shifted moments for NN levels and five-minute bins, and centered lag co-moments for ACF. Last digits and decisions within rounding of jitter gates can change. Existing respiratory-line exemptions, coverage gates and absent-value rules remain. |
78 changes: 78 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Changelog

## Split #99 output changes

Edge must bump `kAlgoVersion` when adopting these changed batch outputs.

### Review input and gap validity

HRV time, nocturnal and session RMSSD abstain on non-finite NN intervals before
segmentation. Cosinor rejects non-finite or non-positive periods before computing
its design. CTL/ATL abstains on unknown/non-finite daily load; explicit observed
zero-load rest days still decay. These are input-validity policies, not new
physiological models. Capped RR runs now report `BeatClass.gap`, appended after
existing enum values, rather than claiming every omitted beat is long/short.
HRV also abstains when retained beat times regress, including when RR
accumulation disagrees with the recorded time at a capped-gap reset. Recorded
segment anchors are preserved; timestamps are never shifted to hide the conflict.
Frequency HRV, RSA and CVHR use the same regressing-clock refusal. Time HRV
also refuses supplied clock vectors whose length does not match the NN vector;
NN-only calls remain supported. Cosinor refuses non-finite design/response
moments, including overflow from a positive subnormal period or finite responses.
Other finite-input formulas, corrected NN and cap accounting are unchanged.


### Leave long RR artifact runs as gaps

The 32-beat cap is an internal ESTIMATE rule with low confidence, not a published threshold. Longer runs split the series; each side is corrected independently. The synthetic 33-beat case keeps 200 NN beats and drops 33.

Method: Lipponen & Tarvainen 2019; Peltola 2012. Reproduce with `dart run tool/reproduce_outputs.dart`.

### Reduce spectral error on epoch timestamps

Evaluate trigonometric arguments relative to the first sample. The mathematical spectrum is time-shift invariant; floating-point band powers and threshold decisions can change for all Lomb-Scargle callers.

Method: Lomb 1976; Scargle 1982; Press & Rybicki 1989. Reproduce with `dart run tool/reproduce_outputs.dart`.

### Abstain when a beat has no finite time

HRV frequency/time, nocturnal and session RMSSD, RSA and CVHR return absent metrics for non-finite beat times. This prevents endless segment walks and invalid integer conversions. Finite-input formulas are unchanged.

Method: Task Force 1996 HRV; Welch 1967 spectra; input-validity guard is an implementation rule. Reproduce with `dart run tool/reproduce_outputs.dart`.

### Refuse unidentifiable cosinor fits

Use centered least squares and a relative determinant gate of 1e-12 of the diagonal product. This is a numerical policy. Nearly collinear phase columns abstain, and ordinary fit parameters can move in their last digits. Upstream zero-amplitude significance gating is retained.

Method: Nelson et al. 1979, Methods for cosinor-rhythmometry; Welford 1962 centered co-moments. Reproduce with `dart run tool/reproduce_outputs.dart`.

### Retain small TRIMP contributions in the total

Compensate the per-minute sum. The reserve and sex-specific weighting are unchanged; the synthetic total moves in its last digits.

Method: Morton, Fitz-Clarke & Banister 1990; Neumaier 1974 compensated summation. Reproduce with `dart run tool/reproduce_outputs.dart`.

### Evaluate training-load decay with affine arithmetic

Evaluate the same EWMA recurrence as scale times seed plus offset. This matches the arithmetic used by the later incremental implementation. Last digits change; 42/7-day defaults and bounded-prefix priming remain implementation choices.

Method: Banister et al. 1975; Morton et al. 1990; Neumaier 1974 prefix summation. Reproduce with `dart run tool/reproduce_outputs.dart`.

### Count repeated zone intervals before summing

Group equal duration credits by zone. Cadence validation, median capping and tail credit are retained. Grouped multiplication changes the last digits of zone seconds.

Method: Karvonen 1957 supports reserve zones only; interval credit is an internal ESTIMATE rule. Reproduce with `dart run tool/reproduce_outputs.dart`.

### Compute circadian variance with centered moments

IS and IV may move in their last digits. Batch circular profile sums and first-winner tie selection are unchanged on the rebased head. Chunked merges can reorder profile sums and move near-tie L5/M10 start epochs; that stream-specific behavior belongs with the aggregators.

Method: Witting 1990; van Someren 1999; Welford 1962 centered variance. Reproduce with `dart run tool/reproduce_outputs.dart`.

### Compute HRV moments without subtracting a large mean

Use origin-shifted moments for NN levels and five-minute bins, and centered lag co-moments for ACF. Last digits and decisions within rounding of jitter gates can change. Existing respiratory-line exemptions, coverage gates and absent-value rules remain.

Method: Task Force 1996; Welford 1962 centered sums and products. Reproduce with `dart run tool/reproduce_outputs.dart`.

7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ There is **one** sleep source (`segmentSleep`) and **one** headline readiness

## Tests

On Linux, `nix develop` supplies the pinned Flutter 3.41.6 / Dart 3.11.4
toolchain used by Edge, plus Git, Clang, CMake, Ninja, and pkg-config.
The interactive shell enters an FHS environment for native build tools.
For a command without an interactive shell, use `nix develop -c dart test`;
`nix develop -c analytics-fhs <command>` also supplies the FHS environment.

```bash
nix develop
dart pub get
dart analyze
dart test
Expand Down
Loading