pub struct WassersteinBall {
pub center_samples: Vec<Vec<f64>>,
pub radius: f64,
}Expand description
Describes a Wasserstein-1 ball around a set of centre samples.
The ball B_ε(P_N) = {Q : W_1(Q, P_N) ≤ ε} contains all probability measures within Wasserstein distance ε of the empirical distribution P_N.
Fields§
§center_samples: Vec<Vec<f64>>Centre samples {x_1, …, x_N} defining the empirical distribution P_N.
radius: f64Ball radius ε ≥ 0.
Implementations§
Source§impl WassersteinBall
impl WassersteinBall
Sourcepub fn new(center_samples: Vec<Vec<f64>>, radius: f64) -> OptimizeResult<Self>
pub fn new(center_samples: Vec<Vec<f64>>, radius: f64) -> OptimizeResult<Self>
Create a new Wasserstein ball.
Returns an error when radius < 0 or center_samples is empty.
Sourcepub fn distance_to_point(&self, q: &[f64]) -> f64
pub fn distance_to_point(&self, q: &[f64]) -> f64
Wasserstein-1 distance from the empirical centre to a single point q.
For a discrete empirical distribution P_N the W_1 distance to the Dirac mass δ_q is min_i ‖x_i − q‖_2 (the nearest-centre distance).
Sourcepub fn contains_point(&self, q: &[f64]) -> bool
pub fn contains_point(&self, q: &[f64]) -> bool
Check whether q is within the Wasserstein ball of the empirical centre.
Returns true iff distance_to_point(q) ≤ self.radius.
Trait Implementations§
Source§impl Clone for WassersteinBall
impl Clone for WassersteinBall
Source§fn clone(&self) -> WassersteinBall
fn clone(&self) -> WassersteinBall
Returns a duplicate of the value. Read more
1.0.0 · 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 WassersteinBall
impl RefUnwindSafe for WassersteinBall
impl Send for WassersteinBall
impl Sync for WassersteinBall
impl Unpin for WassersteinBall
impl UnsafeUnpin for WassersteinBall
impl UnwindSafe for WassersteinBall
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
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.