Skip to main content

Model

Struct Model 

Source
pub struct Model {
    pub rate: Border,
    /* private fields */
}
Expand description

A binary value frequency model

Fields§

§rate: Border

learning rate

Implementations§

Source§

impl Model

Source

pub fn new_flat(threshold: Border, rate: Border) -> Model

Create a new flat (50/50 probability) instance

Source

pub fn new_custom(zero_percent: u8, threshold: Border, rate: Border) -> Model

Create a new instance with a given percentage for zeroes

Source

pub fn reset_flat(&mut self)

Reset the model to 50/50 distribution

Source

pub fn get_probability_zero(&self) -> Border

Return the probability of 0

Source

pub fn get_probability_one(&self) -> Border

Return the probability of 1

Source

pub fn update_zero(&mut self)

Update the frequency of zero

Source

pub fn update_one(&mut self)

Update the frequency of one

Source

pub fn update(&mut self, value: bool)

Update frequencies in favor of given ‘value’ Lower factors produce more aggressive updates

Trait Implementations§

Source§

impl Model<bool> for Model

Source§

fn get_range(&self, value: bool) -> (Border, Border)

Get the probability range of a value
Source§

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

Get the sum of all probabilities
Source§

fn encode(&self, value: V, re: &mut RangeEncoder, out: &mut [Symbol]) -> usize

Encode a value using a range encoder return the number of symbols written
Source§

fn decode(&self, code: Border, re: &mut RangeEncoder) -> (V, usize)

Decode a value using given ‘code’ on the range encoder return a (value, num_symbols_to_shift) pair

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V