pub struct MarkovModel<S> { /* private fields */ }Expand description
A finite first-order Markov model retaining exact counts and fitting policy.
Implementations§
Source§impl<S: Ord + Clone> MarkovModel<S>
impl<S: Ord + Clone> MarkovModel<S>
Sourcepub fn policy(&self) -> &MarkovPolicy
pub fn policy(&self) -> &MarkovPolicy
Returns the policy and corpus provenance used during fitting.
Sourcepub fn transition_matrix(&self) -> FiniteTransitionMatrix<S>
pub fn transition_matrix(&self) -> FiniteTransitionMatrix<S>
Projects the fitted counts and smoothing policy into the shared finite transition representation used by hidden-state inference.
Sourcepub fn transition_count(&self, from: &S, to: &S) -> Result<u64, MarkovError>
pub fn transition_count(&self, from: &S, to: &S) -> Result<u64, MarkovError>
Returns the exact observed count for one transition.
Sourcepub fn transition_probability(
&self,
from: &S,
to: &S,
) -> Result<f64, MarkovError>
pub fn transition_probability( &self, from: &S, to: &S, ) -> Result<f64, MarkovError>
Returns the additively smoothed probability of one transition.
Sourcepub fn score(
&self,
sequences: &[Vec<S>],
) -> Result<TransitionScore, MarkovError>
pub fn score( &self, sequences: &[Vec<S>], ) -> Result<TransitionScore, MarkovError>
Scores sequences without changing the fitted model.
Sourcepub fn to_stable_text(
&self,
state_label: impl FnMut(&S) -> String,
) -> Result<String, MarkovError>
pub fn to_stable_text( &self, state_label: impl FnMut(&S) -> String, ) -> Result<String, MarkovError>
Serializes policy, provenance, states, and exact counts deterministically.
The caller supplies a stable, domain-owned state label. Labels are hex-encoded and indexed in sorted state order, so punctuation and whitespace cannot make the representation ambiguous.
Trait Implementations§
Source§impl<S: Clone> Clone for MarkovModel<S>
impl<S: Clone> Clone for MarkovModel<S>
Source§fn clone(&self) -> MarkovModel<S>
fn clone(&self) -> MarkovModel<S>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<S: Debug> Debug for MarkovModel<S>
impl<S: Debug> Debug for MarkovModel<S>
Source§impl<S: PartialEq> PartialEq for MarkovModel<S>
impl<S: PartialEq> PartialEq for MarkovModel<S>
impl<S: PartialEq> StructuralPartialEq for MarkovModel<S>
Auto Trait Implementations§
impl<S> Freeze for MarkovModel<S>
impl<S> RefUnwindSafe for MarkovModel<S>
impl<S> Send for MarkovModel<S>
impl<S> Sync for MarkovModel<S>
impl<S> Unpin for MarkovModel<S>
impl<S> UnsafeUnpin for MarkovModel<S>
impl<S> UnwindSafe for MarkovModel<S>
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