Code Monkey home page Code Monkey logo

uncertain's Introduction

Uncertain<T>

crates.io Released API docs CI MIT licensed

Fast and correct computations 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);

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.

Stability

While this crate is released as version 0.x, breaking API changes should be expected.

References

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.