[−][src]Struct markovr::MarkovChain
Variable-order Markov chain.
Implementations
impl<T: Element> MarkovChain<T>
[src]
pub fn new(order: usize) -> Self
[src]
Creates a new MarkovChain.
'order' is the order of the Markov Chain.
A value of 1 is your typical Markov Chain, that only looks back one place.
A value of 0 is just a weighted die, since there is no memory.
You could think of order as the shape of the input tensor, where the input tensor is the sliding view / window.
pub fn train(&mut self, view: &[T], result: T, weight_delta: i32)
[src]
Feeds training data into the model.
'view' is the sliding window of elements to load into the MarkovChain chain. the number of elements in view should be self.order + 1 (excess will be ignored). the last element in view is the element to increase the weight of.
'weight_delta' should be the number of times we're loading this view into the model (typically 1 at a time).
pub fn generate_deterministic(&self, view: &[T], rand_val: u64) -> Option<T>
[src]
Generates the next value, given the previous item(s).
view is the sliding window of the latest elements. only the last self.order elements are looked at.
rand_val allows for a deterministic result, if supplied.
pub fn generate(&self, view: &[T]) -> Option<T>
[src]
Generates the next value, given the previous item(s).
view is the sliding window of the latest elements. only the last self.order elements are looked at.
pub fn probability(&self, view: &[T], result: T) -> f32
[src]
Returns the probability of getting 'result', given 'view'.
Auto Trait Implementations
impl<T> RefUnwindSafe for MarkovChain<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for MarkovChain<T> where
T: Send,
T: Send,
impl<T> Sync for MarkovChain<T> where
T: Sync,
T: Sync,
impl<T> Unpin for MarkovChain<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for MarkovChain<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,