1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Online (streaming) estimators that run in bounded memory.
//!
//! Each estimator consumes one value at a time through `update` and reports its
//! current estimate through an accessor, holding only a fixed-size summary of the
//! stream seen so far. State size is a compile-time constant — independent of how
//! many values have been consumed — so an arbitrarily long stream is processed
//! without memory growth.
//!
//! * [`RunningMoments`] — Welford's online mean and variance.
//! * [`P2Quantile`] — the P² streaming-quantile estimator (Jain & Chlamtac 1985).
pub use RunningMoments;
pub use P2Quantile;
/// Converts a stream count to `f64` for use as a divisor.
///
/// Shared by the streaming estimators so the count→float conversion is done one
/// way: through a lossless `u32` window, never an `as` cast (banned in `src/`).
///
/// # Arguments
///
/// * `n` — a stream count. Counts beyond `u32::MAX` clamp to `u32::MAX`, far past
/// any realistic stream where `f64` already loses integer precision (`> 2^53`).
///
/// # Returns
///
/// `n` represented as an `f64`.
pub
/// Converts a 1-based, possibly-negative marker position to `f64`.
///
/// Shared by [`P2Quantile`]'s parabolic/linear updates. Goes through a lossless
/// `u32` magnitude window so the conversion never uses an `as` cast.
///
/// # Arguments
///
/// * `n` — a marker position; its magnitude clamps to `u32::MAX` (far beyond the
/// five P² markers' realistic positions).
///
/// # Returns
///
/// `n` as an `f64`, sign preserved.
pub