Skip to main content

ABCSMCConfig

Struct ABCSMCConfig 

Source
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

  1. Start with the initial tolerance and generate a population using rejection ABC.
  2. 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).
  3. Final particles approximate the posterior at the strictest tolerance.

§Arguments

  • rng - Random number generator
  • model_fn - Function that creates a model instance
  • simulator - Function that simulates data given a trace
  • observed_data - The observed data to match
  • distance_fn - Distance function for comparing datasets
  • config - 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: f64

Initial tolerance for distance threshold

§tolerance_schedule: Vec<f64>

Schedule of decreasing tolerances across rounds

§particles_per_round: usize

Number of particles to generate per round

Trait Implementations§

Source§

impl Clone for ABCSMCConfig

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for ABCSMCConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V