[][src]Struct gmarkov_lib::MarkovChain

pub struct MarkovChain<I: ChainItem> { /* fields omitted */ }

The Markov Chain data structure

A Markov chain is a statistical model that is used to predict random sequences based on the probability of one symbol coming after another. For a basic introduction you can read this article. For a more technical overview you can read the wikipedia article on the subject.

Items in markov chains in gmarkov-lib must implement the Eq, Hash, and Clone traits for use.

Methods

impl<I: ChainItem> MarkovChain<I>[src]

pub fn with_order<T>(order: usize) -> MarkovChain<I>[src]

Create a Markov chain with order order.

The order specifies how many steps back in the sequence the chain keeps track of. A higher order allows for better results but also requires a much larger dataset.

pub fn feed(&mut self, input: impl Iterator<Item = I>)[src]

Train the Markov chain by "feeding" it the iterator input.

This adds the input to the current Markov chain. The generated output will resemble this input.

Trait Implementations

impl<I: Clone + ChainItem> Clone for MarkovChain<I>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<I: ChainItem> IntoIterator for MarkovChain<I>[src]

type Item = I

The type of the elements being iterated over.

type IntoIter = MarkovIterator<I>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Transform the Markov chain into an iterator.

You will usually want to clone the Markov chain before turning it into an iterator so that you don't have to retrain it every time.

impl<I: Debug + ChainItem> Debug for MarkovChain<I>[src]

Auto Trait Implementations

impl<I> Send for MarkovChain<I> where
    I: Send

impl<I> Sync for MarkovChain<I> where
    I: Sync

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]