Expand description
Time-series anomaly detection with no training data.
Struktura detects when the structure of a signal changes: detrended fluctuation analysis (DFA) for the correlation structure, plus a streaming monitor that calibrates itself on the first rows of your data.
§Quick start
use struktura::{compare, is_degraded};
// Compare current readings against a known-good baseline
let result = compare(&normal_readings, ¤t_readings);
println!("{}", result); // "HEALTHY shift=+0.003" or "CRITICAL shift=-0.45"
// Or just ask: is this signal degraded compared to baseline?
if is_degraded(&normal_readings, ¤t_readings) {
trigger_alert();
}§Domains
space: spacecraft telemetry monitoring (reaction wheels, magnetometers, batteries)market: financial regime detection (trending / random walk / mean-reverting)text: writing rhythm analysis (human literary prose vs mechanical/AI)rhythm: event timing analysis (git commits, heartbeats, keystrokes)
Works in no_std environments (default-features = false). 85-112x faster than Python.
Modules§
- autopilot
- Autonomic layer over the hybrid monitor: detect → decide → adapt → continue, without a human in the loop.
- case
- A case directory: saves a recording, its incidents, detector config, and
a manifest so
struktura replaycan reproduce and diff the analysis. - changepoint
- Changepoint detection: locates WHERE the structure changed.
- classify
- Signal classification — what kind of signal is this?
- codegen
- conformal
- Conformal prediction: calibrated confidence for any detector.
- context
- Operating context: column typing and a context timeline that pairs each sample row with its active operating mode, command, and annotations.
- evolve_
real - Evolve against real labeled data: the bridge between the synthetic
RED/BLUE loop (
crate::redblue) and actual benchmark anomalies. - ffi
- fingerprint
- Structural fingerprint — the “DNA” of a signal.
- genome
- Genome structural analysis via DFA on GC-content windows.
- incident
- Incident records: groups temporally proximate alarms into inspectable
incidents with per-channel evidence, context, and reconstruction state.
IncidentBuilderfoldsAlarmReports andEvents intoIncidents (alarms withingapticks join; farther out starts a new one), pulling in explanations viaexplain_alarmand context from aContextTimeline. - market
- Financial time series regime detection via DFA.
- mfdfa
- Multifractal DFA (MFDFA) — reveals signals with multiple scaling regimes.
- monitor
- Flight-grade streaming hybrid health monitor.
- prognosis
- Prognosis: time-to-threshold estimation from a health-metric trajectory.
- redblue
- RED/BLUE adversarial self-improvement.
- replay
- Re-run a detector on a saved case, diff the output against the saved incidents, and report what changed.
- report
- Human-readable investigation report from incident records. Designed to be printed to a terminal or written to a Markdown file.
- rhythm
- Rhythm analysis — DFA on inter-event timing sequences.
- rover
- Rover health monitoring — structural analysis for planetary exploration.
- rover_
flight - Fixed-size rover health monitor for flight computers.
- smap_
eval - Telemanom-protocol evaluation with a closed-form predictor.
- space
- Spacecraft health monitoring via DFA structural analysis.
- telemetry_
bench - Coupled-spacecraft telemetry benchmark comparing DFA to the standard telemetry fault taxonomy (packet loss, spike, stuck, drift, regime shift, mixed).
- text
- Text structural analysis via DFA on sentence-length sequences.
- trend
- Trend detection: is the signal’s structure drifting over time?
Structs§
- Baseline
Tracker - BootstrapCI
- Compare
Result - Result of comparing two signals.
- DfaResult
- Result of a DFA or ACR computation.
- Shuffle
Proof - Sliding
Window - Split
Half Result - Structural
Law - Complete structural analysis of a time series.
Enums§
- Health
Verdict - Health verdict comparing current DFA alpha against a known baseline.
- LawQuality
- How confident the analysis is in the derived scaling exponent.
Functions§
- acr
- Compute autocorrelation decay exponent.
- analyze
- Full structural analysis of a time series.
- anomaly_
scores - Per-window anomaly scores from sliding DFA.
- bootstrap_
alpha - Subsampling confidence interval for α (Politis–Romano style).
- compare
- Compare two signals and get a verdict: is the structure the same?
- dfa
- Compute the DFA scaling exponent of a time series.
- dfa_
box_ sizes - Box sizes that
dfa,dfa_into,dfa_fast_intoanddfa_scratchuse for a series ofnsamples: up to 12 distinct sizes, geometrically spaced frommax(16, n / 50)ton / 4. Returns the sizes and how many of them are valid (0 when the range is empty). - dfa_
fast_ into - Prefix-sum DFA: identical boxes and mathematics to
dfa_into, but the per-segment sums (Σy, Σj·y, Σy²) are O(1) prefix-difference lookups instead of an O(s) pass per segment. One O(n) pass builds the profile prefixes; each of the ≤12 box sizes then costs O(n/s) segments × O(1). - dfa_
into - DFA with a caller-provided buffer, avoiding allocation on the hot path.
- dfa_
scratch - Allocation-free DFA: the same mathematics as
dfa_into, with the cumulative profile written into a caller-owned slice. Runs onno_stdtargets with no heap at all; a stack array or astatic mutbuffer works. - dfa_
short - DFA for short series (from about 24 samples), or
Nonewhen the series cannot be measured (too short, constant, or fewer than 3 usable box sizes). - has_
changed - Has the signal’s structure changed at all?
- health_
check - Compare current DFA alpha against a known healthy baseline.
- is_
degraded - Is the current signal structurally degraded compared to baseline?
- prove_
structure - sanitize
- Filter out NaN and Inf values from a signal.
- shuffle
- Deterministic Fisher-Yates shuffle of a signal.
- split_
half_ validate