pub struct RollingZScore { /* private fields */ }Expand description
Rolling z-score over a sliding window of scalar observations.
Feeds individual Decimal values via update and returns
the current z-score via value.
Returns None when the window is not yet filled or when the standard
deviation is zero (all values identical).
§Example
use quant_indicators::RollingZScore;
use rust_decimal_macros::dec;
let mut zs = RollingZScore::new(3).unwrap();
zs.update(dec!(1));
zs.update(dec!(2));
assert!(zs.value().is_none()); // window not filled
zs.update(dec!(3));
assert!(zs.value().is_some()); // z-score availableImplementations§
Source§impl RollingZScore
impl RollingZScore
Sourcepub fn new(window: usize) -> Result<Self, IndicatorError>
pub fn new(window: usize) -> Result<Self, IndicatorError>
Create a new rolling z-score with the given window size.
§Errors
Returns InvalidParameter if window is 0 or 1 (z-score requires
at least 2 observations for variance).
Trait Implementations§
Source§impl Clone for RollingZScore
impl Clone for RollingZScore
Source§fn clone(&self) -> RollingZScore
fn clone(&self) -> RollingZScore
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RollingZScore
impl RefUnwindSafe for RollingZScore
impl Send for RollingZScore
impl Sync for RollingZScore
impl Unpin for RollingZScore
impl UnsafeUnpin for RollingZScore
impl UnwindSafe for RollingZScore
Blanket Implementations§
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
Mutably borrows from an owned value. Read more