pub struct ConvergenceMonitor { /* private fields */ }Expand description
Tracks a running sequence of estimates and detects convergence.
Implementations§
Source§impl ConvergenceMonitor
impl ConvergenceMonitor
Sourcepub fn new(window_size: usize) -> Self
pub fn new(window_size: usize) -> Self
Create a new monitor with the given window size.
The monitor considers the sequence converged when the last
window_size estimates all lie within epsilon of each other.
Sourcepub fn add_estimate(&mut self, value: f64)
pub fn add_estimate(&mut self, value: f64)
Record a new estimate.
Sourcepub fn has_converged(&self, epsilon: f64) -> bool
pub fn has_converged(&self, epsilon: f64) -> bool
Check whether the last window_size estimates have converged: i.e.,
the maximum minus the minimum within the window is less than epsilon.
Sourcepub fn current_estimate(&self) -> Option<f64>
pub fn current_estimate(&self) -> Option<f64>
Return the most recent estimate, or None if no estimates have been
added.
Auto Trait Implementations§
impl Freeze for ConvergenceMonitor
impl RefUnwindSafe for ConvergenceMonitor
impl Send for ConvergenceMonitor
impl Sync for ConvergenceMonitor
impl Unpin for ConvergenceMonitor
impl UnsafeUnpin for ConvergenceMonitor
impl UnwindSafe for ConvergenceMonitor
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