pub struct HiddenMarkovModel { /* private fields */ }Expand description
Hidden Markov Model builder.
A temporal model with hidden states and observations.
Implementations§
Source§impl HiddenMarkovModel
impl HiddenMarkovModel
Sourcepub fn new(
num_states: usize,
num_observations: usize,
time_steps: usize,
) -> Self
pub fn new( num_states: usize, num_observations: usize, time_steps: usize, ) -> Self
Create a new HMM.
§Arguments
num_states- Number of hidden statesnum_observations- Number of observable symbolstime_steps- Length of sequence
Sourcepub fn set_initial_distribution(
&mut self,
initial: ArrayD<f64>,
) -> Result<&mut Self>
pub fn set_initial_distribution( &mut self, initial: ArrayD<f64>, ) -> Result<&mut Self>
Set initial state distribution P(state_0).
Sourcepub fn set_transition_matrix(
&mut self,
transition: ArrayD<f64>,
) -> Result<&mut Self>
pub fn set_transition_matrix( &mut self, transition: ArrayD<f64>, ) -> Result<&mut Self>
Set transition matrix P(state_t | state_{t-1}).
§Arguments
transition- Transition probabilities [from_state, to_state]
Sourcepub fn set_emission_matrix(
&mut self,
emission: ArrayD<f64>,
) -> Result<&mut Self>
pub fn set_emission_matrix( &mut self, emission: ArrayD<f64>, ) -> Result<&mut Self>
Set emission matrix P(obs_t | state_t).
§Arguments
emission- Emission probabilities [state, observation]
Sourcepub fn graph(&self) -> &FactorGraph
pub fn graph(&self) -> &FactorGraph
Get the underlying factor graph.
Sourcepub fn filter(&self, observations: &[usize], t: usize) -> Result<ArrayD<f64>>
pub fn filter(&self, observations: &[usize], t: usize) -> Result<ArrayD<f64>>
Perform filtering: compute P(state_t | obs_0:t).
Uses variable elimination to compute the marginal distribution over the hidden state at time t given observations from 0 to t.
Auto Trait Implementations§
impl Freeze for HiddenMarkovModel
impl RefUnwindSafe for HiddenMarkovModel
impl Send for HiddenMarkovModel
impl Sync for HiddenMarkovModel
impl Unpin for HiddenMarkovModel
impl UnwindSafe for HiddenMarkovModel
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§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 moreSource§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).Source§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.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.