Low-level Classes¶
C++17 classes exposed via pybind11. Use them for streaming (one value at a time) or to read multiple statistics from a single pass.
- class robustrolling.MonotonicMax(window_size)¶
Rolling maximum — monotonic deque, O(1) amortised.
- Parameters:
window_size – int
- process_batch(x: numpy.ndarray) numpy.ndarray¶
mm = MonotonicMax(3) mm.update(1.0); mm.update(3.0); mm.update(2.0) mm.get_max() # 3.0
- class robustrolling.MonotonicMin(window_size)¶
Rolling minimum — monotonic deque, O(1) amortised.
- Parameters:
window_size – int
- process_batch(x: numpy.ndarray) numpy.ndarray¶
- class robustrolling.MultisetMedian(window_size)¶
Rolling median —
std::multisetwith tracked iterator, O(log n). Even-size windows return the average of the two middle elements.- Parameters:
window_size – int
- process_batch(x: numpy.ndarray) numpy.ndarray¶
- class robustrolling.SlidingWelford(window_size)¶
Rolling sample variance (ddof=1) — Welford algorithm with ring buffer, O(1).
- Parameters:
window_size – int
- process_batch(x: numpy.ndarray) numpy.ndarray¶
sw = SlidingWelford(3) for v in [1., 2., 3., 4.]: sw.update(v) sw.get_variance() # 1.0
- class robustrolling.SlidingMoments(window_size)¶
Rolling mean, skewness, and excess kurtosis — Terriberry’s 4th-moment algorithm, O(1). Requires ≥ 3 observations for skewness, ≥ 4 for kurtosis.
- Parameters:
window_size – int
- reset()¶
- process_mean_batch(x: numpy.ndarray) numpy.ndarray¶
- process_skewness_batch(x: numpy.ndarray) numpy.ndarray¶
- process_kurtosis_batch(x: numpy.ndarray) numpy.ndarray¶
sm = SlidingMoments(4) for v in [1., 2., 3., 4.]: sm.update(v) sm.get_mean(), sm.get_skewness(), sm.get_kurtosis() # (2.5, 0.0, -1.2)
- class robustrolling.SlidingCovariance(window_size)¶
Rolling sample covariance and Pearson correlation — 2-D Welford algorithm, O(1).
- Parameters:
window_size – int
- process_covariance_batch(x: numpy.ndarray, y: numpy.ndarray) numpy.ndarray¶
- process_correlation_batch(x: numpy.ndarray, y: numpy.ndarray) numpy.ndarray¶
sc = SlidingCovariance(3) for x, y in [(1,2),(2,4),(3,6)]: sc.update(x, y) sc.get_covariance(), sc.get_correlation() # (2.0, 1.0)