Trait ChainRunner

Source
pub trait ChainRunner<S>: HasChains<S>
where S: Clone + Zero + Send + PartialEq + Sync + Debug + 'static,
{ // Provided methods fn run(&mut self, n_steps: usize, discard: usize) -> Vec<DMatrix<S>> { ... } fn run_with_progress( &mut self, n_steps: usize, discard: usize, ) -> Vec<DMatrix<S>> { ... } }
Expand description

An extension trait for types that own multiple MCMC chains.

ChainRunner<S> extends HasChains<S> by providing default methods to run all chains in parallel using Rayon. These methods allow you to:

  • Run all chains for a specified number of iterations and discard an initial burn-in period.
  • Optionally display progress bars for each chain during execution.

Any type that implements HasChains<S> (with appropriate bounds on S) automatically implements ChainRunner<S>.

Provided Methods§

Source

fn run(&mut self, n_steps: usize, discard: usize) -> Vec<DMatrix<S>>

Runs all chains in parallel, discarding the first discard iterations (burn-in).

§Arguments
  • n_steps - The total number of iterations to run for each chain.
  • discard - The number of initial iterations to discard from each chain.
§Returns

A vector of nalgebra::DMatrix<S> matrices, one for each chain, containing the samples after burn-in.

Source

fn run_with_progress( &mut self, n_steps: usize, discard: usize, ) -> Vec<DMatrix<S>>

Runs all chains in parallel with progress bars, discarding the burn-in.

Each chain is run concurrently with its own progress bar. After execution, the first discard iterations are discarded.

§Arguments
  • n_steps - The total number of iterations to run for each chain.
  • discard - The number of initial iterations to discard.
§Returns

A vector of sample matrices (one per chain) containing only the samples after burn-in.

Implementors§

Source§

impl<S: Debug + Sync + PartialEq + Send + Zero + Clone + 'static, T: HasChains<S>> ChainRunner<S> for T