pub struct ABCSMCConfig {
pub initial_tolerance: f64,
pub tolerance_schedule: Vec<f64>,
pub particles_per_round: usize,
}Expand description
Sequential Monte Carlo ABC with adaptive tolerance scheduling.
An importance-weighted ABC-SMC (Beaumont 2009 / Toni et al. 2009) that
iteratively reduces the tolerance, giving better posterior approximations than
rejection ABC at stringent tolerances. See abc_smc (equally-weighted
population) and abc_smc_weighted (weighted population with typed errors).
§Algorithm
- Start with the initial tolerance and generate a population using rejection ABC.
- For each subsequent tolerance level:
- draw a base particle from the previous population proportional to its importance weight,
- perturb its continuous coordinates with a Gaussian kernel scaled by the weighted sample variance,
- reject out-of-support proposals and accept those within the new tolerance,
- weight each accepted particle by
pi(theta) / sum_j w_j K(theta | theta_j).
- Final particles approximate the posterior at the strictest tolerance.
§Arguments
rng- Random number generatormodel_fn- Function that creates a model instancesimulator- Function that simulates data given a traceobserved_data- The observed data to matchdistance_fn- Distance function for comparing datasetsconfig- Initial tolerance, decreasing tolerance schedule, population size
§Returns
Vector of traces from the final SMC population.
§Examples
use fugue::{inference::abc::ABCSMCConfig, *};
use rand::rngs::StdRng;
use rand::SeedableRng;
// Simple SMC-ABC example with small numbers for testing
let observed = vec![2.0];
let mut rng = StdRng::seed_from_u64(42);
let samples = abc_smc(
&mut rng,
|| sample(addr!("mu"), Normal::new(0.0, 1.0).unwrap()),
|trace| {
if let Some(choice) = trace.choices.get(&addr!("mu")) {
if let ChoiceValue::F64(mu) = choice.value {
vec![mu]
} else { vec![0.0] }
} else { vec![0.0] }
},
&observed,
&EuclideanDistance,
ABCSMCConfig {
initial_tolerance: 1.0,
tolerance_schedule: vec![0.5],
particles_per_round: 5,
},
);
assert!(!samples.is_empty());Configuration for ABC-SMC algorithm.
Fields§
§initial_tolerance: f64Initial tolerance for distance threshold
tolerance_schedule: Vec<f64>Schedule of decreasing tolerances across rounds
particles_per_round: usizeNumber of particles to generate per round
Trait Implementations§
Source§impl Clone for ABCSMCConfig
impl Clone for ABCSMCConfig
Source§fn clone(&self) -> ABCSMCConfig
fn clone(&self) -> ABCSMCConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ABCSMCConfig
impl RefUnwindSafe for ABCSMCConfig
impl Send for ABCSMCConfig
impl Sync for ABCSMCConfig
impl Unpin for ABCSMCConfig
impl UnsafeUnpin for ABCSMCConfig
impl UnwindSafe for ABCSMCConfig
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