pub struct DiVector { /* private fields */ }Expand description
Two-sided per-dimension attribution accumulator.
Implementations§
Source§impl DiVector
impl DiVector
Sourcepub fn zeros(dim: usize) -> Self
pub fn zeros(dim: usize) -> Self
Build a zeroed DiVector with dim dimensions.
§Examples
use anomstream_core::domain::DiVector;
let v = DiVector::zeros(4);
assert_eq!(v.dim(), 4);
assert_eq!(v.total(), 0.0);Sourcepub fn from_arrays(high: Vec<f64>, low: Vec<f64>) -> RcfResult<Self>
pub fn from_arrays(high: Vec<f64>, low: Vec<f64>) -> RcfResult<Self>
Build a DiVector from explicit high / low vectors.
Useful for tests and downstream code that wants to pipe a
ready-made attribution back into a triage helper (e.g.
anomstream_triage::AlertClusterer).
§Errors
Returns RcfError::DimensionMismatch when
high.len() != low.len().
Sourcepub fn per_dim_total(&self, d: usize) -> f64
pub fn per_dim_total(&self, d: usize) -> f64
Per-dimension total: high[d] + low[d].
§Panics
Panics when d >= self.dim() — call sites size-check first.
Sourcepub fn argmax(&self) -> Option<usize>
pub fn argmax(&self) -> Option<usize>
Index of the dimension with the largest high[d] + low[d].
Returns None for an empty vector.
Sourcepub fn add_high(&mut self, d: usize, value: f64) -> RcfResult<()>
pub fn add_high(&mut self, d: usize, value: f64) -> RcfResult<()>
Add value to the upper-side contribution for dimension d.
§Errors
Returns RcfError::OutOfBounds when d >= self.dim().
Sourcepub fn add_low(&mut self, d: usize, value: f64) -> RcfResult<()>
pub fn add_low(&mut self, d: usize, value: f64) -> RcfResult<()>
Add value to the lower-side contribution for dimension d.
§Errors
Returns RcfError::OutOfBounds when d >= self.dim().
Sourcepub fn accumulate(&mut self, other: &Self) -> RcfResult<()>
pub fn accumulate(&mut self, other: &Self) -> RcfResult<()>
Element-wise add other into self.
§Errors
Returns RcfError::DimensionMismatch when dimensions differ.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for DiVector
impl<'de> Deserialize<'de> for DiVector
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for DiVector
Auto Trait Implementations§
impl Freeze for DiVector
impl RefUnwindSafe for DiVector
impl Send for DiVector
impl Sync for DiVector
impl Unpin for DiVector
impl UnsafeUnpin for DiVector
impl UnwindSafe for DiVector
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
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