Skip to main content

WassersteinGradientFlow

Struct WassersteinGradientFlow 

Source
pub struct WassersteinGradientFlow {
    pub tau: f64,
    pub positions: Vec<f64>,
    pub n_particles: usize,
    pub potential_alpha: f64,
}
Expand description

Wasserstein gradient flow simulation using the JKO (Jordan-Kinderlehrer-Otto) minimising movement scheme.

Evolves a discrete probability measure ρ = (x_i, w_i) under the gradient flow of the free energy F[ρ] = ∫ ρ log ρ dx + ∫ V ρ dx (Fokker-Planck).

Fields§

§tau: f64

JKO time step τ.

§positions: Vec<f64>

Current particle positions x_i.

§n_particles: usize

Equal weights w_i = 1/N.

§potential_alpha: f64

Potential V(x) = α x² / 2 (quadratic confining potential), coefficient α.

Implementations§

Source§

impl WassersteinGradientFlow

Source

pub fn new(n_particles: usize, tau: f64, potential_alpha: f64) -> Self

Initialise with N Gaussian-distributed particles.

Source

pub fn step(&mut self)

Perform one JKO step: move particles to minimise τ F[ρ] + W_2²(ρ^n, ρ) / 2 via a proximal operator. For the quadratic potential V = α x²/2 the JKO update has the closed-form shrinkage: x_i^{n+1} = x_i^n / (1 + τ α).

Source

pub fn run(&mut self, n_steps: usize)

Run n_steps JKO steps.

Source

pub fn mean(&self) -> f64

Compute the empirical mean of the particle cloud.

Source

pub fn variance(&self) -> f64

Compute the empirical variance of the particle cloud.

Source

pub fn steady_state_variance(&self) -> f64

Steady-state variance: σ² = 1/(τ α N) · N = 1/α (Gaussian with covariance 1/α).

Trait Implementations§

Source§

impl Clone for WassersteinGradientFlow

Source§

fn clone(&self) -> WassersteinGradientFlow

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 Debug for WassersteinGradientFlow

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.