pub struct RollingQuantile { /* private fields */ }Expand description
The quantile-th quantile of the last period values, with linear
interpolation between order statistics.
h = (period − 1) · quantile
lower = ⌊h⌋
result = sorted[lower] + (h − lower) · (sorted[lower + 1] − sorted[lower])This is the type-7 / NumPy-default quantile definition: quantile = 0.0
returns the window minimum, 0.5 the median, 1.0 the maximum, and
fractional values interpolate linearly between the bracketing order
statistics. Rolling quantiles are the building block for distribution-aware
thresholds — a price sitting above its rolling 90th-percentile, a volatility
regime split at the 25th/75th percentiles, robust band edges that ignore the
tails.
Each update is O(period log period): the window is copied into a scratch
buffer and sorted with total ordering (NaN-safe).
§Example
use wickra_core::{Indicator, RollingQuantile};
// Rolling median of the last 5 values.
let mut indicator = RollingQuantile::new(5, 0.5).unwrap();
let out = indicator.update(1.0);
assert!(out.is_none()); // warming upImplementations§
Source§impl RollingQuantile
impl RollingQuantile
Sourcepub fn new(period: usize, quantile: f64) -> Result<Self>
pub fn new(period: usize, quantile: f64) -> Result<Self>
Construct a new rolling quantile.
quantile selects the order statistic in [0.0, 1.0].
§Errors
Returns Error::PeriodZero if period == 0, or
Error::InvalidParameter if quantile is not a finite value in
[0.0, 1.0].
Trait Implementations§
Source§impl Clone for RollingQuantile
impl Clone for RollingQuantile
Source§impl Debug for RollingQuantile
impl Debug for RollingQuantile
Source§impl Indicator for RollingQuantile
impl Indicator for RollingQuantile
Source§fn update(&mut self, value: f64) -> Option<f64>
fn update(&mut self, value: f64) -> Option<f64>
None if there is no value for this input. Read moreSource§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Source§fn is_ready(&self) -> bool
fn is_ready(&self) -> bool
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
Source§fn batch_nan_into(&mut self, inputs: &[Self::Input], out: &mut [f64])
fn batch_nan_into(&mut self, inputs: &[Self::Input], out: &mut [f64])
Source§fn batch_fast_into(&mut self, inputs: &[Self::Input], out: &mut [f64])
fn batch_fast_into(&mut self, inputs: &[Self::Input], out: &mut [f64])
batch_nan_into, but
an indicator with a vectorised kernel may reassociate its arithmetic to
run it in SIMD lanes. Each value then agrees with the exact batch to within
the tolerance the indicator documents (a few units in the last place), not
bit for bit; warmup positions, NaN placement and the output length are
identical. The kernels are deterministic: the same input produces the same
bits on every platform, with or without SIMD hardware. Read moreAuto Trait Implementations§
impl Freeze for RollingQuantile
impl RefUnwindSafe for RollingQuantile
impl Send for RollingQuantile
impl Sync for RollingQuantile
impl Unpin for RollingQuantile
impl UnsafeUnpin for RollingQuantile
impl UnwindSafe for RollingQuantile
Blanket Implementations§
Source§impl<T> BatchExt for Twhere
T: Indicator,
impl<T> BatchExt for Twhere
T: Indicator,
Source§fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
None during warmup) per input.Source§impl<T> BatchNanExt for T
impl<T> BatchNanExt for T
Source§fn batch_nan(&mut self, inputs: &[f64]) -> Vec<f64>
fn batch_nan(&mut self, inputs: &[f64]) -> Vec<f64>
f64 per input, warmup positions filled with NaN, bit-for-bit equal
to replaying update.Source§fn batch_fast(&mut self, inputs: &[f64]) -> Vec<f64>
fn batch_fast(&mut self, inputs: &[f64]) -> Vec<f64>
Indicator::batch_fast_into) into a fresh
vector: within the indicator’s documented tolerance of
batch_nan, deterministic across platforms.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more