Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.ht

### Fixed

- Phase 5 transient detection scored each sample against a centred
30-sample window, so a box or step entered its own baseline. With the
Phase 5 defaults, 0 of 200 boxes were detected at any amplitude up to
1000 sigma. `transient_segments` now uses a trailing median/MAD baseline
with a guard gap (default `min_length`), freezes the baseline at onset,
and leaves detected samples out of later baselines. A segment opens after
`min_length` samples in a row beyond the threshold and closes when most
of the next `min_length` samples are back inside; NaN samples are
skipped. Samples with fewer than 15 trailing samples (the first 22 with
the defaults) are not scored. A 10 sigma box is detected in 200 of 200
draws; white noise gives no segment in 200 draws. A `UserWarning` is
issued when the residual lag-1 autocorrelation outside the segments
exceeds 0.3. `ljung_box_test` and `detect_anomalies` accept `n_fitted`.
`AnomalyReport.to_dict` now includes `metadata`. `transient_segments` now
requires `rolling_window >= 2` (it raises `ValueError` for 1) and integer
`min_length`, `rolling_window` and `guard`, and `ljung_box_test` requires integer `n_fitted` (both raise
`TypeError` otherwise). `rolling_zscore` is unchanged. (C4)

- Enlarge the calibration table, preserve nonzero Monte Carlo standard errors,
correct abstract percent formatting, and keep the running title within the
page margin. (FIG-03, FMT-01)
Expand Down
32 changes: 32 additions & 0 deletions KNOWN_ISSUES.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,35 @@ matrix size manageable. If you pass a model whose last layer is
unrealistically thin (i.e., not actually a half-space), you will get
unexpected truncation. Always make the last layer thick (~50 km is
conventional in the example configs).

---

## Phase 5 transient threshold assumes independent residuals

`anomaly.detection.transient_segments` flags runs of at least 7 samples
beyond 3 sigma of a trailing median/MAD baseline. The threshold is fixed.
It holds for white residuals: no segment in 200 white-noise series of
600 or 2920 samples. It over-flags correlated residuals: 600-sample AR(1)
series with no transient are flagged in 2 of 200 draws at phi 0.5 and in
115 of 200 at phi 0.8 (seed 12345). The centred detector it replaced
flagged none of these, because it could not detect anything. Daily dv/v
residuals are often this correlated, so a default Phase 5 run on them
will report noise as transients, with only the warning to say so. The
detector warns when the lag-1 autocorrelation outside the detected
segments exceeds 0.3. It does not yet calibrate the threshold
empirically, for example by a block bootstrap of pre-event residuals.
Until it does, treat segments from correlated residuals as candidates.

## Phase 5 cannot test the first samples of a record

`transient_segments` needs 15 samples of history (`rolling_window // 2`)
that end `guard` samples (7) before the sample under test, so the first
22 samples of a gap-free series are not scored. A transient that starts
between samples 15 and 22 is reported from sample 22. One that starts
before sample 15 fills the first baseline and is taken as the reference
level: a step there is not detected, and the end of a box there is
reported as a transient of the opposite sign that runs to the end of the
record.

A 5 sigma step mid-record is still missed in 3 to 5 % of draws and split
in two in 2 to 4 % (seed 12, 100 draws; seed 2026, 200 draws).
10 changes: 8 additions & 2 deletions docs/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,14 @@ v0.2.

**Input:** Phase 4 residuals.

**Computation:** Ljung–Box whiteness test (default 30 lags), rolling
z-score transient detection, and a structured anomaly report.
**Computation:** Ljung–Box whiteness test (default 20 lags), transient
detection, and a structured anomaly report. A transient is a run of at
least 7 samples more than 3 sigma from a trailing baseline: the median of
the previous 30 samples, with a MAD scale, ending 7 samples before the
sample under test. The segment closes when most of the next 7 samples
are back inside 3 sigma; the first 22 samples are not scored. A warning is issued when the residual lag-1
autocorrelation outside the detected segments exceeds 0.3, because the
fixed threshold then over-flags.

**Output:** `AnomalyReport` containing the whiteness p-value, transient
segments, and a dict serialisable to JSON.
Expand Down
Loading
Loading