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 =|dist| dist > 2.0);

// Check how certain the answer is
assert_eq!(, false);
assert_eq!(, true);

This works by sampling a Bayesian network which is implicitly created by describing the computation on the uncertain type. The Uncertain trait only permits tests for simple boolean hypotheses. This is by design: using Wald’s sequential probability ratio test, evaluation typically takes less than 100 samples.


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



An opaque uncertain value.


Information about a failed call to expect.


Wraps a Distribution and implements Uncertain.


An uncertain value which always yields the same value.



An interface for using uncertain values in computations.