pub struct Model<Dist: Continuous<f64, f64>> { /* private fields */ }
Expand description
Implementation of a hmm::Model
with emission values from univariate continuous distributions.
Log-scale probabilities are used for numeric stability.
Implementations
sourceimpl<Dist: Continuous<f64, f64>> Model<Dist>
impl<Dist: Continuous<f64, f64>> Model<Dist>
sourcepub fn new(
transition: Array2<LogProb>,
observation: Vec<Dist>,
initial: Array1<LogProb>
) -> Result<Self>
pub fn new(
transition: Array2<LogProb>,
observation: Vec<Dist>,
initial: Array1<LogProb>
) -> Result<Self>
Construct new Hidden MarkovModel with the given transition, observation, and initial state matrices and vectors already in log-probability space.
Trait Implementations
sourceimpl<Dist: Continuous<f64, f64>> Model<f64> for Model<Dist>
impl<Dist: Continuous<f64, f64>> Model<f64> for Model<Dist>
sourcefn num_states(&self) -> usize
fn num_states(&self) -> usize
The number of states in the model.
sourcefn states(&self) -> StateIterⓘNotable traits for StateIterimpl Iterator for StateIter type Item = State;
fn states(&self) -> StateIterⓘNotable traits for StateIterimpl Iterator for StateIter type Item = State;
Return iterator over the states of an HMM.
sourcefn transitions(&self) -> StateTransitionIterⓘNotable traits for StateTransitionIterimpl Iterator for StateTransitionIter type Item = StateTransition;
fn transitions(&self) -> StateTransitionIterⓘNotable traits for StateTransitionIterimpl Iterator for StateTransitionIter type Item = StateTransition;
Returns an iterator of all transitions.
sourcefn transition_prob(&self, from: State, to: State) -> LogProb
fn transition_prob(&self, from: State, to: State) -> LogProb
Transition probability between two states from
and to
.
sourcefn initial_prob(&self, state: State) -> LogProb
fn initial_prob(&self, state: State) -> LogProb
Initial probability given the HMM state
.
sourcefn observation_prob(&self, state: State, observation: &f64) -> LogProb
fn observation_prob(&self, state: State, observation: &f64) -> LogProb
Probability for the given observation in the given state.
sourcefn transition_prob_idx(&self, from: State, to: State, _to_idx: usize) -> LogProb
fn transition_prob_idx(&self, from: State, to: State, _to_idx: usize) -> LogProb
Transition probability between two states from
and to
for observation with index
_to_idx
(index of to
). Read more
fn has_end_state(&self) -> bool
Auto Trait Implementations
impl<Dist> RefUnwindSafe for Model<Dist> where
Dist: RefUnwindSafe,
impl<Dist> Send for Model<Dist> where
Dist: Send,
impl<Dist> Sync for Model<Dist> where
Dist: Sync,
impl<Dist> Unpin for Model<Dist> where
Dist: Unpin,
impl<Dist> UnwindSafe for Model<Dist> where
Dist: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.