pub struct RollingPercentileRank { /* private fields */ }Expand description
Percentile rank of the most-recent value within the last period values,
in [0, 100].
rank = 100 · (#below + 0.5 · #equal) / periodwhere #below counts window values strictly less than the current value and
#equal counts those equal to it (including the current value itself). This
is the “mean” method of percentileofscore: ties are split symmetrically,
so a flat window scores exactly 50, the strict window maximum scores just
under 100, and the strict minimum just over 0.
Percentile rank turns any series into a bounded, self-normalising oscillator: “where does today sit relative to its own recent history” — high readings mark stretched extremes, mid readings mark the typical range. It is the scale-free cousin of the z-score that makes no distributional assumption.
Each update is O(period): one linear pass tallies the comparisons.
§Example
use wickra_core::{Indicator, RollingPercentileRank};
let mut indicator = RollingPercentileRank::new(20).unwrap();
let mut last = None;
for i in 0..40 {
last = indicator.update(100.0 + f64::from(i));
}
// A strictly rising series puts the newest value near the top.
assert!(last.unwrap() > 90.0);Implementations§
Trait Implementations§
Source§impl Clone for RollingPercentileRank
impl Clone for RollingPercentileRank
Source§fn clone(&self) -> RollingPercentileRank
fn clone(&self) -> RollingPercentileRank
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RollingPercentileRank
impl Debug for RollingPercentileRank
Source§impl Indicator for RollingPercentileRank
impl Indicator for RollingPercentileRank
Source§fn update(&mut self, value: f64) -> Option<f64>
fn update(&mut self, value: f64) -> Option<f64>
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Auto Trait Implementations§
impl Freeze for RollingPercentileRank
impl RefUnwindSafe for RollingPercentileRank
impl Send for RollingPercentileRank
impl Sync for RollingPercentileRank
impl Unpin for RollingPercentileRank
impl UnsafeUnpin for RollingPercentileRank
impl UnwindSafe for RollingPercentileRank
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§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