Realm

oa::ml::metric::WeightedMean

Additive numerator/denominator state for one weighted mean. The result is sum / weight — never the mean of per-batch means, which disagrees for uneven final batches. An empty denominator reports NaN rather than zero, so merges with empty state are exact no-ops.

StRust public API

Declaration

pub struct WeightedMean { /* private fields */ }
Public Rust declaration.

Public Methods

pub fn update(&mut self, sum: f64, weight: f64) -> Result<()>
pub fn merge(&mut self, other: &Self)
pub fn result(&self) -> f64
pub const fn sum(&self) -> f64
pub const fn weight(&self) -> f64
pub fn reset(&mut self)
fn clone(&self) -> WeightedMean
fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn eq(&self, other: &WeightedMean) -> bool

Associated Functions

pub fn new() -> Self
fn default() -> WeightedMean

Public Method Documentation

pub fn update(&mut self, sum: f64, weight: f64) -> Result<()>
No public source comment is attached to this declaration.
pub fn merge( &mut self, other: &Self )
No public source comment is attached to this declaration.
pub fn result( &self ) -> f64
No public source comment is attached to this declaration.
pub const fn sum( &self ) -> f64
No public source comment is attached to this declaration.
pub const fn weight( &self ) -> f64
No public source comment is attached to this declaration.
pub fn reset( &mut self )
No public source comment is attached to this declaration.
fn clone( &self ) -> WeightedMean
No public source comment is attached to this declaration.
fn fmt( &self, f: &mut Formatter<'_> ) -> Result
No public source comment is attached to this declaration.
fn eq( &self, other: &WeightedMean ) -> bool
No public source comment is attached to this declaration.
pub fn new() -> Self
No public source comment is attached to this declaration.
fn default() -> WeightedMean
No public source comment is attached to this declaration.