pub struct BranchingProcess {
pub z0: usize,
pub mean_offspring: f64,
/* private fields */
}Expand description
Galton-Watson branching process.
Each individual in generation n independently produces a random number of offspring in generation n+1 according to an offspring distribution.
Fields§
§z0: usizeInitial population Z(0).
mean_offspring: f64Mean offspring per individual.
Implementations§
Source§impl BranchingProcess
impl BranchingProcess
Sourcepub fn poisson(z0: usize, lambda: f64, seed: u64) -> Self
pub fn poisson(z0: usize, lambda: f64, seed: u64) -> Self
Creates a new Galton-Watson process with Poisson offspring.
Sourcepub fn geometric(z0: usize, p: f64, seed: u64) -> Self
pub fn geometric(z0: usize, p: f64, seed: u64) -> Self
Creates a new process with Geometric offspring.
Sourcepub fn bernoulli(z0: usize, p: f64, seed: u64) -> Self
pub fn bernoulli(z0: usize, p: f64, seed: u64) -> Self
Creates a new process with Bernoulli offspring.
Sourcepub fn simulate(&self, n_generations: usize) -> Vec<usize>
pub fn simulate(&self, n_generations: usize) -> Vec<usize>
Simulate the process for n_generations generations.
Returns population sizes Z(0), Z(1), …, Z(n_generations).
Sourcepub fn extinction_probability(&self) -> f64
pub fn extinction_probability(&self) -> f64
Theoretical extinction probability for Poisson offspring.
For Poisson(lambda) offspring:
- If lambda <= 1: extinction probability = 1.
- If lambda > 1: extinction probability = q where q = exp(lambda*(q-1)). Solved iteratively.
Sourcepub fn mc_extinction_probability(
&self,
n_paths: usize,
n_generations: usize,
) -> f64
pub fn mc_extinction_probability( &self, n_paths: usize, n_generations: usize, ) -> f64
Estimate extinction probability by Monte Carlo simulation.
Auto Trait Implementations§
impl Freeze for BranchingProcess
impl RefUnwindSafe for BranchingProcess
impl Send for BranchingProcess
impl Sync for BranchingProcess
impl Unpin for BranchingProcess
impl UnsafeUnpin for BranchingProcess
impl UnwindSafe for BranchingProcess
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<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.