Struct uncertain::PointMass [−][src]
An uncertain value which always yields the same value.
This type can be useful when fixed values should
be conditionally returned e.g. from flat_map
.
If you only need a fixed value as part of an uncertain computation, consider
using map
.
Examples
Basic usage: conditional distribution.
use uncertain::{Uncertain, PointMass, Distribution}; use rand_distr::Normal; let a = Distribution::from(Normal::new(2.0, 1.0).unwrap()); let b = a.flat_map(|a| if a < 1.5 { Distribution::from(Normal::new(0.0, 1.0).unwrap()).into_boxed() } else { PointMass::new(1.0).into_boxed() }); assert!(b.map(|b| b > 0.5).pr(0.9));
In most cases you can use map
instead:
use uncertain::{Uncertain, PointMass, Distribution}; use rand_distr::StandardNormal; let x = 1.0; let y = Distribution::<f64, _>::from(StandardNormal).into_ref(); let a = PointMass::new(x).add(&y); let b = (&y).map(|v: f64| v + x); assert!(a.join(b, |a, b| a == b).pr(0.999));
Implementations
impl<T> PointMass<T> where
T: Clone,
[src]
T: Clone,
Trait Implementations
impl<T: Clone> Clone for PointMass<T> where
T: Clone,
[src]
T: Clone,
impl<T: Copy> Copy for PointMass<T> where
T: Clone,
[src]
T: Clone,
impl<T> Uncertain for PointMass<T> where
T: Clone,
[src]
T: Clone,
type Value = T
The type of the contained value.
fn sample(&self, _rng: &mut Pcg32, _epoch: usize) -> Self::Value
[src]
fn pr(&self, probability: f32) -> bool where
Self::Value: Into<bool>,
[src]
Self::Value: Into<bool>,
fn expect(
&self,
precision: Self::Value
) -> Result<Self::Value, ConvergenceError<Self::Value>> where
Self::Value: Float,
[src]
&self,
precision: Self::Value
) -> Result<Self::Value, ConvergenceError<Self::Value>> where
Self::Value: Float,
fn into_boxed(self) -> BoxedUncertain<Self::Value> where
Self: 'static + Sized + Send,
[src]
Self: 'static + Sized + Send,
fn into_ref(self) -> RefUncertain<Self> where
Self: Sized,
Self::Value: Clone,
[src]
Self: Sized,
Self::Value: Clone,
fn map<O, F>(self, func: F) -> Map<Self, F> where
Self: Sized,
F: Fn(Self::Value) -> O,
[src]
Self: Sized,
F: Fn(Self::Value) -> O,
fn flat_map<O, F>(self, func: F) -> FlatMap<Self, F> where
Self: Sized,
O: Uncertain,
F: Fn(Self::Value) -> O,
[src]
Self: Sized,
O: Uncertain,
F: Fn(Self::Value) -> O,
fn join<O, U, F>(self, other: U, func: F) -> Join<Self, U, F> where
Self: Sized,
U: Uncertain,
F: Fn(Self::Value, U::Value) -> O,
[src]
Self: Sized,
U: Uncertain,
F: Fn(Self::Value, U::Value) -> O,
fn not(self) -> Not<Self> where
Self: Sized,
Self::Value: Into<bool>,
[src]
Self: Sized,
Self::Value: Into<bool>,
fn and<U>(self, other: U) -> And<Self, U> where
Self: Sized,
Self::Value: Into<bool>,
U: Uncertain,
U::Value: Into<bool>,
[src]
Self: Sized,
Self::Value: Into<bool>,
U: Uncertain,
U::Value: Into<bool>,
fn or<U>(self, other: U) -> Or<Self, U> where
Self: Sized,
Self::Value: Into<bool>,
U: Uncertain,
U::Value: Into<bool>,
[src]
Self: Sized,
Self::Value: Into<bool>,
U: Uncertain,
U::Value: Into<bool>,
fn add<U>(self, other: U) -> Sum<Self, U> where
Self: Sized,
U: Uncertain,
Self::Value: Add<U::Value>,
[src]
Self: Sized,
U: Uncertain,
Self::Value: Add<U::Value>,
fn sub<U>(self, other: U) -> Difference<Self, U> where
Self: Sized,
U: Uncertain,
Self::Value: Sub<U::Value>,
[src]
Self: Sized,
U: Uncertain,
Self::Value: Sub<U::Value>,
fn mul<U>(self, other: U) -> Product<Self, U> where
Self: Sized,
U: Uncertain,
Self::Value: Mul<U::Value>,
[src]
Self: Sized,
U: Uncertain,
Self::Value: Mul<U::Value>,
fn div<U>(self, other: U) -> Ratio<Self, U> where
Self: Sized,
U: Uncertain,
Self::Value: Div<U::Value>,
[src]
Self: Sized,
U: Uncertain,
Self::Value: Div<U::Value>,
Auto Trait Implementations
impl<T> RefUnwindSafe for PointMass<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for PointMass<T> where
T: Send,
T: Send,
impl<T> Sync for PointMass<T> where
T: Sync,
T: Sync,
impl<T> Unpin for PointMass<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for PointMass<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,