Skip to main content

SignedMeasure

Struct SignedMeasure 

Source
pub struct SignedMeasure {
    pub positive_density: Box<dyn Fn(&[f64]) -> f64>,
    pub negative_density: Box<dyn Fn(&[f64]) -> f64>,
    pub domain: MeasurableSet,
    pub n_samples: usize,
}
Expand description

A signed measure represented as a difference of two non-negative measures.

By the Jordan decomposition theorem, every signed measure ν can be written as ν = ν⁺ − ν⁻ where ν⁺, ν⁻ ≥ 0 are mutually singular.

Here we work numerically with density functions.

Fields§

§positive_density: Box<dyn Fn(&[f64]) -> f64>

The positive part density f⁺(x) ≥ 0.

§negative_density: Box<dyn Fn(&[f64]) -> f64>

The negative part density f⁻(x) ≥ 0.

§domain: MeasurableSet

Domain of integration.

§n_samples: usize

Number of Monte Carlo samples.

Implementations§

Source§

impl SignedMeasure

Source

pub fn new( positive_density: impl Fn(&[f64]) -> f64 + 'static, negative_density: impl Fn(&[f64]) -> f64 + 'static, domain: MeasurableSet, n_samples: usize, ) -> Self

Create a signed measure from positive and negative densities.

Source

pub fn from_density( density: impl Fn(&[f64]) -> f64 + 'static, domain: MeasurableSet, n_samples: usize, ) -> Self

Create a signed measure from a single (possibly negative) density f.

Source

pub fn evaluate(&self, set: &MeasurableSet) -> f64

Evaluate the signed measure on a set: ν(A) = ∫_A (f⁺ − f⁻) dx.

Source

pub fn total_variation(&self, set: &MeasurableSet) -> f64

Total variation: |ν|(A) = ∫_A (f⁺ + f⁻) dx.

Source

pub fn hahn_positive_set_samples(&self, n: usize) -> Vec<Vec<f64>>

Hahn decomposition: identify the positive set P where f⁺ > f⁻.

Returns a sample of points in P within the domain.

Source

pub fn jordan_decomposition(&self) -> (f64, f64)

Jordan decomposition: return estimates of ν⁺(domain) and ν⁻(domain).

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

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.