Expand description
Fixed-memory, zero-allocation streaming statistics for real-time systems.
60+ algorithms, all O(1) per update (or O(d) for d-dimensional filters), fixed memory.
Core types are no_std compatible; types marked (std) require the std feature,
(alloc) require alloc, and (std|libm) require either std or libm.
§Usage
Import from the category module you need:
use nexus_stats::smoothing::EmaF64;
use nexus_stats::detection::CusumF64;
use nexus_stats::statistics::WelfordF64;
use nexus_stats::{DataError, ConfigError, Direction};With the full feature (or individual subcrate features), advanced types
are available through the same module paths:
// Requires `smoothing` feature
use nexus_stats::smoothing::KamaF64;
// Requires `regression` feature
use nexus_stats::regression::LinearRegressionF64;
// Requires `detection` feature
use nexus_stats::signal::AutocorrelationF64;§Data Quality & Error Policy
nexus-stats distinguishes two failure categories:
Data errors — NaN or Inf values reaching a streaming update.
These indicate upstream data quality problems (broken feeds, failed
computations, missing values). All update methods that accept float
inputs return Result<_, DataError>. The library rejects the input
and leaves internal state unchanged. The caller declares the policy:
.unwrap()to crash on bad data (testing, strict systems)- Log and continue (monitoring, degraded-mode operation)
- Increment a counter and trigger a circuit breaker (production)
Programmer errors — wrong dimensions, out-of-range indices,
type misuse. These are bugs in the calling code. The library panics
via assert!. Fix the code.
§Internal State Invariant
Given only finite (non-NaN, non-Inf) inputs, all internal
accumulators remain finite for typical workloads. Extreme value
ranges (>1e150) or very long-running instances (billions of updates)
can cause internal accumulator overflow through summation. For
long-running systems: call reset() periodically, use
exponentially-weighted variants (EW*) which naturally bound growth,
or use .max_covariance() on RLS filters to auto-reset when the
covariance matrix diverges.
§Categories
§Core (always available)
| Module | Contents |
|---|---|
smoothing | EMA, AsymEma, Slew |
detection | CUSUM |
statistics | Welford, Moments, EwmaVar, Covariance, HarmonicMean, Percentile, BipowerVariation, RollSpread (std|libm), TwoScaleRv (alloc, std|libm) |
monitoring | Drawdown, Windowed Min/Max, CoDel, Liveness, EventRate, Jitter, ErrorRate, Saturation, HawkesIntensity (std|libm) |
control | DeadBand, Hysteresis, Debounce, LevelCrossing, Diff |
§Advanced (feature-gated, re-exported from subcrates)
| Feature | Module | Contents |
|---|---|---|
smoothing | smoothing | + Holt, KAMA, Spring, Kalman1d, WindowedMedian |
detection | detection | + MOSUM, Shiryaev-Roberts, AdaptiveThreshold, RobustZ, TrendAlert, MultiGate, PageHinkley, ADWIN |
detection | signal | Autocorrelation, CrossCorrelation, Entropy, TransferEntropy, PredictiveInfoBound |
detection | estimation | + SPRT |
regression | regression | Linear, Polynomial, EW variants, Transformed, LogisticRegression |
regression | learning | LMS, NLMS, RLS, OnlineKMeans, GD, AdaGrad, Adam, UCB1, ThompsonBeta, ThompsonGamma, EpsilonGreedy, EXP3 |
regression | estimation | + Kalman 2d/3d, BetaBinomial, GammaPoisson |
control | control | + PeakDetector, BoolWindow |
control | frequency | TopK, FlexProportion, DecayAccum |
full | all | Everything above |
§Features
| Feature | Default | Enables |
|---|---|---|
std | yes | WallClock, sqrt/exp intrinsics |
alloc | with std | MOSUM, KAMA, WindowedMedian, BoolWindow, adaptive filters, optimizers |
libm | no | Pure Rust sqrt/exp fallback for no_std (enables Shiryaev-Roberts, etc.) |
smoothing | no | Advanced smoothing types (Holt, KAMA, Spring, Kalman1d, WindowedMedian) |
detection | no | Advanced detection + signal analysis (implies smoothing) |
regression | no | Regression, learning, estimation types |
control | no | Advanced control + frequency types |
full | no | All subcrates |
Modules§
- clock
- Clock trait and implementations for time-aware stats types. Clock trait and implementations.
- control
- Control, thresholding, and differencing.
- detection
- Change detection and anomaly detection.
- estimation
- State estimation, Bayesian inference, and hypothesis testing.
- frequency
- Frequency counting and scoring.
- learning
- Adaptive filters, online learning, and optimization.
- monitoring
- Monitoring and health tracking. Monitoring and health tracking. System monitoring and operational health.
- normalization
- Online feature normalization. Online feature normalization. Online feature normalization.
- regression
- Regression and classification.
- signal
- Signal analysis and information theory.
- smoothing
- Smoothing and filtering primitives.
- statistics
- Core streaming statistics. Core streaming statistics. Core streaming statistics.
Macros§
- feature_
vector - Generates a named feature vector struct where every field is
f64.
Enums§
- Condition
- System condition state.
- Config
Error - Configuration error from building a stats primitive.
- Data
Error - Error returned when a streaming update receives invalid data.
- Direction
- Directional change or anomaly direction.