pub trait ChainRunner<S>: HasChains<S>{
// 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§
Sourcefn run(&mut self, n_steps: usize, discard: usize) -> Vec<DMatrix<S>>
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.
Sourcefn run_with_progress(
&mut self,
n_steps: usize,
discard: usize,
) -> Vec<DMatrix<S>>
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.