Crate uncertain[][src]

Computation with uncertain values.

When working with values which are not exactly determined, such as sensor data, it can be difficult to handle uncertainties correctly.

The Uncertain trait makes such computations as natural as regular computations:

use uncertain::{Uncertain, Distribution};
use rand_distr::Normal;

// Some inputs about which we are not sure
let x = Distribution::from(Normal::new(5.0, 2.0).unwrap());
let y = Distribution::from(Normal::new(7.0, 3.0).unwrap());

// Do some computations
let distance = x.sub(y).map(|diff: f64| diff.abs());

// Ask a question about the result
let is_it_far = distance.map(|dist| dist > 2.0);

// Check how certain the answer is
assert_eq!(is_it_far.pr(0.9), false);
assert_eq!(is_it_far.pr(0.5), true);

References

The Uncertain trait exported from the library is an implementation of the paper Uncertain<T>.

Structs

BoxedUncertain

Boxed uncertain value. An uncertain value which can be cloned. See Uncertain::into_boxed.

Distribution

Wraps a rand::distributions::Distribution to create uncertain values from probability distributions and ensure they have the correct Copy and Clone semantics.

Traits

Uncertain

An interface for using uncertain values in computations.