5 个不稳定版本
0.3.1 | 2021年3月11日 |
---|---|
0.3.0 | 2021年3月4日 |
0.2.1 | 2021年2月28日 |
0.2.0 | 2021年2月26日 |
0.1.0 | 2021年2月25日 |
#1785 在 算法 中
每月 34 次下载
42KB
744 行
Uncertain<T>
使用不确定值的快速和正确计算。
当处理非精确确定的值时,例如传感器数据,正确处理不确定性可能会很困难。
Uncertain
特性使这种计算与常规计算一样自然
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);
这是通过采样贝叶斯网络实现的,该网络隐式地由描述不确定类型的计算创建。 Uncertain
特性仅允许对简单的布尔假设进行测试。这是设计决定的:使用 Wald 的 顺序概率比测试,评估通常需要不到 100
次采样。
稳定性
虽然这个包以版本 0.x
发布,但应预料到 API 破坏性更改。
参考文献
从库中导出的 Uncertain
特性是论文 Uncertain<T>
的实现。
依赖项
~360–485KB