[][src]Struct markovian::BranchingProcess

pub struct BranchingProcess<T, D, R> where
    T: Debug + PartialEq + Clone + One + Zero + PartialOrd + Unsigned,
    D: Distribution<T>,
    R: Rng
{ /* fields omitted */ }

Branching process in the natural numbers NN = {0, 1, 2, ...}.

A Branching process is characterized by a density p over NN. It can be thought of the size of a population. In this population, each individual is identical to the rest and they are independent of each other. Moreover, at each time step, individuals have descendents and die. Their descendants constitutes the second generation and the process repeats. The overall process is therefore characterized by the number of offsprings an individual has. The resulting process is a Markov Chain in NN.

Implementations

impl<T, D, R> BranchingProcess<T, D, R> where
    T: Debug + PartialEq + Clone + One + Zero + PartialOrd + Unsigned,
    D: Distribution<T>,
    R: Rng
[src]

pub fn new(state: T, base_distribution: D, rng: R) -> Self[src]

Creates a new Branching process.

Examples

Construction using density p(0) = 0.3, p(1) = 0.4, p(2) = 0.3.

let init_state: u32 = 1;
let density = raw_dist![(0.3, 0), (0.4, 1), (0.3, 2)];
let rng = thread_rng();
let mut branching_process = markovian::BranchingProcess::new(init_state, density, rng);

Trait Implementations

impl<T: Clone, D: Clone, R: Clone> Clone for BranchingProcess<T, D, R> where
    T: Debug + PartialEq + Clone + One + Zero + PartialOrd + Unsigned,
    D: Distribution<T>,
    R: Rng
[src]

impl<T: Debug, D: Debug, R: Debug> Debug for BranchingProcess<T, D, R> where
    T: Debug + PartialEq + Clone + One + Zero + PartialOrd + Unsigned,
    D: Distribution<T>,
    R: Rng
[src]

impl<T, D, R> Distribution<T> for BranchingProcess<T, D, R> where
    T: Debug + PartialEq + Clone + One + Zero + PartialOrd + Unsigned,
    D: Distribution<T>,
    R: Rng
[src]

fn sample<R2: ?Sized>(&self, rng: &mut R2) -> T where
    R2: Rng
[src]

Sample a possible next state.

impl<T, D, R> Iterator for BranchingProcess<T, D, R> where
    T: Debug + PartialEq + Clone + One + Zero + PartialOrd + Unsigned,
    D: Distribution<T>,
    R: Rng
[src]

type Item = T

The type of the elements being iterated over.

fn next(&mut self) -> Option<Self::Item>[src]

Changes the state of the Branching to a new state, chosen according to the distribution for offsprings, and returns the new state.

Examples

let init_state: u32 = 1;
let density = raw_dist![(0.3, 0), (0.4, 1), (0.3, 2)];
let rng = thread_rng();
let mut branching_process = markovian::BranchingProcess::new(init_state, density, rng);

// The next state is 0, 1 or 2. 
let new_state = branching_process.next();
assert!( (new_state == Some(0)) || (new_state == Some(1)) || (new_state == Some(2)) );

impl<T, D, R> State for BranchingProcess<T, D, R> where
    T: Debug + PartialEq + Clone + One + Zero + PartialOrd + Unsigned,
    D: Distribution<T>,
    R: Rng
[src]

type Item = T

impl<T, D, R> StateIterator for BranchingProcess<T, D, R> where
    T: Debug + PartialEq + Clone + One + Zero + PartialOrd + Unsigned,
    D: Distribution<T>,
    R: Rng
[src]

Auto Trait Implementations

impl<T, D, R> RefUnwindSafe for BranchingProcess<T, D, R> where
    D: RefUnwindSafe,
    R: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, D, R> Send for BranchingProcess<T, D, R> where
    D: Send,
    R: Send,
    T: Send

impl<T, D, R> Sync for BranchingProcess<T, D, R> where
    D: Sync,
    R: Sync,
    T: Sync

impl<T, D, R> Unpin for BranchingProcess<T, D, R> where
    D: Unpin,
    R: Unpin,
    T: Unpin

impl<T, D, R> UnwindSafe for BranchingProcess<T, D, R> where
    D: UnwindSafe,
    R: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

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

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

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

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

impl<T, U> Into<U> for T where
    U: From<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<I> IteratorRandom for I where
    I: Iterator
[src]

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

type Owned = T

The resulting type after obtaining ownership.

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<V, T> VZip<V> for T where
    V: MultiLane<T>,