pub struct Model {
pub rate: Border,
/* private fields */
}Expand description
A binary value frequency model
Fields§
§rate: Borderlearning rate
Implementations§
Source§impl Model
impl Model
Sourcepub fn new_flat(threshold: Border, rate: Border) -> Model
pub fn new_flat(threshold: Border, rate: Border) -> Model
Create a new flat (50/50 probability) instance
Sourcepub fn new_custom(zero_percent: u8, threshold: Border, rate: Border) -> Model
pub fn new_custom(zero_percent: u8, threshold: Border, rate: Border) -> Model
Create a new instance with a given percentage for zeroes
Sourcepub fn reset_flat(&mut self)
pub fn reset_flat(&mut self)
Reset the model to 50/50 distribution
Sourcepub fn get_probability_zero(&self) -> Border
pub fn get_probability_zero(&self) -> Border
Return the probability of 0
Sourcepub fn get_probability_one(&self) -> Border
pub fn get_probability_one(&self) -> Border
Return the probability of 1
Sourcepub fn update_zero(&mut self)
pub fn update_zero(&mut self)
Update the frequency of zero
Sourcepub fn update_one(&mut self)
pub fn update_one(&mut self)
Update the frequency of one
Trait Implementations§
Source§impl Model<bool> for Model
impl Model<bool> for Model
Source§fn find_value(&self, offset: Border) -> (bool, Border, Border)
fn find_value(&self, offset: Border) -> (bool, Border, Border)
Find the value by a given probability offset, return with the range
Source§fn get_denominator(&self) -> Border
fn get_denominator(&self) -> Border
Get the sum of all probabilities
Auto Trait Implementations§
impl Freeze for Model
impl RefUnwindSafe for Model
impl Send for Model
impl Sync for Model
impl Unpin for Model
impl UnsafeUnpin for Model
impl UnwindSafe for Model
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