Struct cont_arith_code::distribution::categorical::Categorical   
source · pub struct Categorical<T> {
    pub count: usize,
    pub map: Map<T, (usize, f64)>,
}Fields§
§count: usizeNumber of observations
map: Map<T, (usize, f64)>Symbol -> (count, log-probability)
Implementations§
source§impl<T> Categorical<T>
 
impl<T> Categorical<T>
pub fn singleton(k: T) -> Categorical<T>
sourcepub fn from_data<I>(data: I) -> Selfwhere
    T: Ord,
    I: IntoIterator<Item = T>,
 
pub fn from_data<I>(data: I) -> Selfwhere
    T: Ord,
    I: IntoIterator<Item = T>,
Fit a cateogrical distribution to the given dataset
pub fn len(&self) -> usize
pub fn index_of(&self, key: &T) -> Option<usize>
pub fn get_key(&self, i: usize) -> &T
sourcepub fn kld(&self, q: &Self) -> f64
 
pub fn kld(&self, q: &Self) -> f64
Kullback-Leibler divergence D(P||Q) of self (P) from a second
Categorical (Q) (nats). Panics if some entry of self is absent
in Q.
pub fn log_probability(&self, val: &T) -> f64
Trait Implementations§
source§impl<T: Clone> Clone for Categorical<T>
 
impl<T: Clone> Clone for Categorical<T>
source§fn clone(&self) -> Categorical<T>
 
fn clone(&self) -> Categorical<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from 
source. Read moresource§impl<T: Debug> Debug for Categorical<T>
 
impl<T: Debug> Debug for Categorical<T>
source§impl<T: Clone + Ord + Debug + 'static> Model<T> for Categorical<T>
 
impl<T: Clone + Ord + Debug + 'static> Model<T> for Categorical<T>
source§fn push(&mut self, s: i64) -> Option<T>
 
fn push(&mut self, s: i64) -> Option<T>
Push a value into the model and updates its state. Returns a
values once it’s been fully described by a series of indexes.
source§fn next_distr(&mut self) -> Box<dyn UnivariateDistribution>
 
fn next_distr(&mut self) -> Box<dyn UnivariateDistribution>
Get the distribution for the next symbol from the model.
source§impl<T: PartialEq> PartialEq for Categorical<T>
 
impl<T: PartialEq> PartialEq for Categorical<T>
source§fn eq(&self, other: &Categorical<T>) -> bool
 
fn eq(&self, other: &Categorical<T>) -> bool
This method tests for 
self and other values to be equal, and is used
by ==.source§impl<T: PartialOrd> PartialOrd for Categorical<T>
 
impl<T: PartialOrd> PartialOrd for Categorical<T>
source§fn partial_cmp(&self, other: &Categorical<T>) -> Option<Ordering>
 
fn partial_cmp(&self, other: &Categorical<T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
 
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for 
self and other) and is used by the <=
operator. Read moresource§impl<T: Debug> UnivariateDistribution for Categorical<T>
 
impl<T: Debug> UnivariateDistribution for Categorical<T>
fn truncated(&self) -> Box<dyn TruncatedDistribution>
impl<T> StructuralPartialEq for Categorical<T>
Auto Trait Implementations§
impl<T> Freeze for Categorical<T>
impl<T> RefUnwindSafe for Categorical<T>where
    T: RefUnwindSafe,
impl<T> Send for Categorical<T>where
    T: Send,
impl<T> Sync for Categorical<T>where
    T: Sync,
impl<T> Unpin for Categorical<T>where
    T: Unpin,
impl<T> UnwindSafe for Categorical<T>where
    T: UnwindSafe,
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
§impl<SS, SP> SupersetOf<SS> for SPwhere
    SS: SubsetOf<SP>,
 
impl<SS, SP> SupersetOf<SS> for SPwhere
    SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
 
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct 
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
 
fn is_in_subset(&self) -> bool
Checks if 
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
 
fn to_subset_unchecked(&self) -> SS
Use with care! Same as 
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
 
fn from_subset(element: &SS) -> SP
The inclusion map: converts 
self to the equivalent element of its superset.