Skip to main content

MclmcSettings

Struct MclmcSettings 

Source
pub struct MclmcSettings<A: Debug + Copy + Default + Serialize> {
Show 16 fields pub step_size: f64, pub momentum_decoherence_length: f64, pub num_tune: u64, pub num_draws: u64, pub num_chains: usize, pub seed: u64, pub max_energy_error: f64, pub store_unconstrained: bool, pub store_gradient: bool, pub store_transformed: bool, pub store_divergences: bool, pub adapt_options: A, pub subsample_frequency: f64, pub dynamic_step_size: bool, pub trajectory_kind: MclmcTrajectoryKind, pub trajectory_switch_fraction: f64,
}
Expand description

Settings for the unadjusted Microcanonical Langevin Monte Carlo (MCLMC) sampler.

⚠️ Experimental — use with caution: The MCLMC sampler and all of its variants are highly experimental. They have not been thoroughly validated and may not return correct posteriors. The API, defaults, and adaptation behaviour are all subject to breaking changes at any time. Do not use these samplers in production or for results you rely on.

Step size ε and momentum decoherence length L are constants — no adaptation of those is performed yet. The geometry is adapted during warmup using the sampler-specific adaptation strategy, while the step size remains fixed.

Use the type aliases DiagMclmcSettings, LowRankMclmcSettings, and FlowMclmcSettings for concrete configurations.

Fields§

§step_size: f64

Step size ε for the ESH leapfrog integrator.

§momentum_decoherence_length: f64

Momentum decoherence length L (controls partial momentum refresh rate). Set to f64::INFINITY to disable momentum refresh entirely.

§num_tune: u64

Number of warmup draws.

§num_draws: u64

Number of sampling draws after warmup.

§num_chains: usize

Number of parallel chains.

§seed: u64

RNG seed.

§max_energy_error: f64

Maximum energy error before a step is flagged as a divergence.

§store_unconstrained: bool

Store each unconstrained parameter vector in the sampler stats.

§store_gradient: bool

Store the gradient in the sampler stats.

§store_transformed: bool

Store the transformed gradient and value in the sampler stats

§store_divergences: bool

Store detailed information about each divergence in the sampler stats

§adapt_options: A

Geometry adaptation options (step-size fields are ignored for Euclidean settings).

§subsample_frequency: f64

Number of leapfrog steps per draw as a fraction of L / ε.

The number of leapfrog steps between collector calls is: round(subsample_frequency * L / ε).max(1)

  • 1.0 (default) — one sample per full trajectory (at the final step).
  • 0.0 — every leapfrog step.
  • Values in between space samples as a fraction of the decoherence length, so the interval scales naturally when L or ε changes.
§dynamic_step_size: bool

When true, use the tree-structured step size retry on divergence: halve the step size factor and try 2 steps before doubling back. log_weight will include log(step_size) to correct for the varying sampling density. When false, divergences are recorded immediately without any retry and log_weight = -energy_change.

§trajectory_kind: MclmcTrajectoryKind

Selects which leapfrog integrator and partial-momentum-refresh style to use. See MclmcTrajectoryKind for the available options. Default: MclmcTrajectoryKind::Microcanonical (original MCLMC).

§trajectory_switch_fraction: f64

Fraction of num_tune draws at which the trajectory is switched from Euclidean to Microcanonical when trajectory_kind == MclmcTrajectoryKind::EuclideanEarlyThenMicrocanonical. Ignored for other trajectory kinds. Default: 0.3.

Trait Implementations§

Source§

impl<A: Clone + Debug + Copy + Default + Serialize> Clone for MclmcSettings<A>

Source§

fn clone(&self) -> MclmcSettings<A>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A: Debug + Debug + Copy + Default + Serialize> Debug for MclmcSettings<A>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de, A> Deserialize<'de> for MclmcSettings<A>
where A: Deserialize<'de> + Debug + Copy + Default + Serialize,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<A> Serialize for MclmcSettings<A>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<A: Copy + Debug + Copy + Default + Serialize> Copy for MclmcSettings<A>

Auto Trait Implementations§

§

impl<A> Freeze for MclmcSettings<A>
where A: Freeze,

§

impl<A> RefUnwindSafe for MclmcSettings<A>
where A: RefUnwindSafe,

§

impl<A> Send for MclmcSettings<A>
where A: Send,

§

impl<A> Sync for MclmcSettings<A>
where A: Sync,

§

impl<A> Unpin for MclmcSettings<A>
where A: Unpin,

§

impl<A> UnsafeUnpin for MclmcSettings<A>
where A: UnsafeUnpin,

§

impl<A> UnwindSafe for MclmcSettings<A>
where A: UnwindSafe,

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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,