pub struct ParallelTempering<T: TargetDistribution + Clone + Send, P: ProposalDistribution + Clone + Send> {
pub base_target: T,
pub proposal: P,
pub temperatures: Array1<f64>,
pub states: Vec<Array1<f64>>,
pub log_densities: Vec<f64>,
pub n_chains: usize,
pub exchange_freq: usize,
pub move_accepted: Vec<usize>,
pub exchange_accepted: Vec<usize>,
pub move_attempts: Vec<usize>,
pub exchange_attempts: Vec<usize>,
}Expand description
Parallel Tempering (Replica Exchange) sampler
Runs multiple chains at different temperatures in parallel and exchanges states between chains to improve mixing.
Fields§
§base_target: TBase target distribution
proposal: PProposal distribution
temperatures: Array1<f64>Temperature schedule
states: Vec<Array1<f64>>Current states for each chain
log_densities: Vec<f64>Current log densities for each chain
n_chains: usizeNumber of chains
exchange_freq: usizeExchange attempt frequency
move_accepted: Vec<usize>Acceptance counters for moves
exchange_accepted: Vec<usize>Acceptance counters for exchanges
move_attempts: Vec<usize>Total move attempts
exchange_attempts: Vec<usize>Total exchange attempts
Implementations§
Source§impl<T: TargetDistribution + Clone + Send, P: ProposalDistribution + Clone + Send> ParallelTempering<T, P>
impl<T: TargetDistribution + Clone + Send, P: ProposalDistribution + Clone + Send> ParallelTempering<T, P>
Sourcepub fn new(
base_target: T,
proposal: P,
temperatures: Array1<f64>,
initial_states: Vec<Array1<f64>>,
exchange_freq: usize,
) -> Result<Self>
pub fn new( base_target: T, proposal: P, temperatures: Array1<f64>, initial_states: Vec<Array1<f64>>, exchange_freq: usize, ) -> Result<Self>
Create a new parallel tempering sampler
Sourcepub fn step<R: Rng + ?Sized>(&mut self, rng: &mut R) -> Result<()>
pub fn step<R: Rng + ?Sized>(&mut self, rng: &mut R) -> Result<()>
Perform one step for all chains
Sourcepub fn exchange_step<R: Rng + ?Sized>(&mut self, rng: &mut R) -> Result<()>
pub fn exchange_step<R: Rng + ?Sized>(&mut self, rng: &mut R) -> Result<()>
Attempt exchanges between adjacent chains
Sourcepub fn sample<R: Rng + ?Sized>(
&mut self,
n_samples_: usize,
rng: &mut R,
) -> Result<Array2<f64>>
pub fn sample<R: Rng + ?Sized>( &mut self, n_samples_: usize, rng: &mut R, ) -> Result<Array2<f64>>
Run the parallel tempering sampler
Sourcepub fn move_acceptance_rates(&self) -> Array1<f64>
pub fn move_acceptance_rates(&self) -> Array1<f64>
Get acceptance rates for moves
Sourcepub fn exchange_acceptance_rates(&self) -> Array1<f64>
pub fn exchange_acceptance_rates(&self) -> Array1<f64>
Get acceptance rates for exchanges
Auto Trait Implementations§
impl<T, P> Freeze for ParallelTempering<T, P>
impl<T, P> RefUnwindSafe for ParallelTempering<T, P>where
T: RefUnwindSafe,
P: RefUnwindSafe,
impl<T, P> Send for ParallelTempering<T, P>
impl<T, P> Sync for ParallelTempering<T, P>
impl<T, P> Unpin for ParallelTempering<T, P>
impl<T, P> UnsafeUnpin for ParallelTempering<T, P>where
T: UnsafeUnpin,
P: UnsafeUnpin,
impl<T, P> UnwindSafe for ParallelTempering<T, P>where
T: UnwindSafe,
P: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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.