1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//! Probabilistic numerical methods with explicit uncertainty over computational
//! quantities.
//!
//! `uncertain-numerics` treats numerical computation as an inference problem.
//! Instead of returning only a point estimate of an integral or of the solution
//! of a linear system, each method returns a validated Gaussian posterior: its
//! mean is the estimate and its variance states how much the computation still
//! does not know. Every statistical and numerical assumption behind that
//! posterior is explicit, documented, and tested.
//!
//! # What is implemented
//!
//! | Area | Entry points |
//! | --- | --- |
//! | One-dimensional Bayesian quadrature | [`BayesianQuadrature`], [`RbfKernel`], [`GaussianMeasure`], [`ScalarNormalPosterior`] |
//! | Active Bayesian quadrature | [`ActiveBayesianQuadrature`], [`VarianceReductionAcquisition`] |
//! | Probabilistic linear solvers | [`SpdLinearSystem`], [`GaussianLinearBelief`], [`ResidualProjectionSolver`], [`AConjugateProjectionSolver`], [`CovarianceGreedyProjectionSolver`] |
//! | Building blocks | [`GaussianConditioner`], [`KernelMean`], [`KernelIntegral`], [`ScalarKernel`], [`ContinuousProbabilityMeasure`] |
//!
//! # Example
//!
//! Infer the integral of `cos(x)` against a standard Gaussian measure from seven
//! function evaluations, together with its posterior uncertainty:
//!
//! ```
//! use uncertain_numerics::{BayesianQuadrature, GaussianMeasure, RbfKernel};
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let kernel = RbfKernel::new(1.0, 1.0)?; // signal variance, length scale
//! let measure = GaussianMeasure::new(0.0, 1.0)?; // p(x) = N(0, 1)
//! let quadrature = BayesianQuadrature::new(kernel, measure, 1.0e-10);
//!
//! let nodes = [-3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0];
//! let values: Vec<f64> = nodes.iter().copied().map(f64::cos).collect();
//! let posterior = quadrature.posterior(&nodes, &values)?;
//!
//! // Exactly, E[cos X] = exp(-1/2) for X ~ N(0, 1).
//! let exact = (-0.5_f64).exp();
//! println!("{} ± {}", posterior.mean(), posterior.standard_deviation());
//! assert!((posterior.mean() - exact).abs() < 3.0 * posterior.standard_deviation());
//! # Ok(())
//! # }
//! ```
//!
//! # Numerical policy
//!
//! - Inputs are validated at the API boundary. Invalid values produce typed
//! errors that implement [`std::error::Error`]; they never propagate as `NaN`.
//! - Linear systems are solved from a reusable Cholesky factorization. Explicit
//! inverses are never formed.
//! - Jitter is a caller-supplied constant added to the diagonal. Because it
//! changes the posterior, it is never increased automatically to make a
//! factorization succeed.
//! - Posterior variances that are negative by more than machine roundoff are
//! reported as errors rather than clamped.
//!
//! # Interpreting the uncertainty
//!
//! Posterior uncertainty is conditional on the numerical model. Under the
//! assumed prior the reported intervals are empirically calibrated, which the
//! integration tests verify. Under misspecification, for example an RBF length
//! scale that is far too smooth for the integrand, the posterior can be
//! confidently wrong. The `docs/` directory of the repository records the known
//! failure modes and the calibration status of each linear-solver policy.
//!
//! # Minimum supported Rust version
//!
//! Rust 1.85. Raising the MSRV is treated as at least a minor version bump.
// Applied here rather than in `[lints.rust]` so that examples and integration
// tests, which have no crate-level docs, are not affected.
pub use ;
pub use ;
pub use ;
pub use ActiveDesignError;
pub use ActiveSelectionError;
pub use BayesianQuadrature;
pub use BayesianQuadratureError;
pub use GaussianConditioner;
pub use ConditioningError;
pub use ;
pub use PosteriorError;
pub use ;
pub use KernelError;
pub use KernelIntegral;
pub use KernelMean;
pub use GaussianLinearBelief;
pub use LinearSolverError;
pub use SpdLinearSystem;
pub use ;
pub use MeasureError;
pub use ScalarNormalPosterior;
pub use ;
/// Compiles and runs every Rust code block in the README as a doctest, so the
/// examples shown on GitHub and crates.io can never drift from the real API.