Skip to main content

Crate uncertain_numerics

Crate uncertain_numerics 

Source
Expand description

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

§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};

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());

§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.

Structs§

AConjugateLinearSolveResult
Result of an A-conjugate probabilistic linear solve.
AConjugateLinearSolveStep
One A-conjugate projection-conditioning step.
AConjugateProjectionSolver
Probabilistic linear solver using residual directions orthogonalized in the A inner product.
ActiveBayesianQuadrature
Sequential active Bayesian quadrature over a finite candidate set.
ActiveDesignResult
Result of a sequential active Bayesian-quadrature run.
ActiveDesignStep
One function evaluation selected by the active design.
BayesianQuadrature
Bayesian quadrature with an RBF covariance kernel and Gaussian integration measure.
CovarianceGreedyProjectionSolver
Sequential probabilistic linear solver with data-independent covariance-greedy directions.
CovarianceGreedySolveResult
Result of a covariance-greedy probabilistic linear solve.
CovarianceGreedyStep
One covariance-greedy projection step.
CovarianceTraceAcquisition
Covariance-trace acquisition for exact linear-system projection observations.
GaussianConditioner
Reusable factorization of a symmetric positive-definite linear system.
GaussianLinearBelief
Gaussian belief over the unknown solution vector of a linear system.
GaussianMeasure
Gaussian probability measure (N(\mu, \sigma^2)).
LinearSolveStep
One residual-projection conditioning step.
ProbabilisticLinearSolveResult
Result of an iterative probabilistic linear solve.
RbfKernel
Squared-exponential (radial-basis-function) covariance kernel.
ResidualProjectionSolver
Residual-driven probabilistic solver for dense SPD systems.
ScalarNormalPosterior
Gaussian posterior for a scalar computational quantity.
SelectedCandidate
Candidate selected by posterior integral-variance reduction.
SelectedLinearDirection
Candidate projection chosen to maximize posterior covariance-trace reduction.
SpdLinearSystem
Dense symmetric positive-definite linear system A x = b.
VarianceReductionAcquisition
Expected reduction in posterior integral variance from evaluating one candidate node.

Enums§

ActiveDesignError
Errors raised while running sequential active Bayesian quadrature.
ActiveSelectionError
Errors raised while selecting active Bayesian-quadrature candidates.
ActiveTermination
Reason a sequential active Bayesian-quadrature run terminated.
BayesianQuadratureError
Errors raised while constructing a Bayesian quadrature posterior.
ConditioningError
Errors raised while constructing or using a Gaussian conditioning system.
CovarianceGreedyTermination
Reason a covariance-greedy probabilistic solve terminated.
KernelError
Errors raised while constructing covariance kernels.
LinearSolveTermination
Reason a residual-projection probabilistic linear solve terminated.
LinearSolverError
Errors raised by probabilistic linear-system primitives.
MeasureError
Errors raised while constructing probability measures.
PosteriorError
Errors raised while constructing probabilistic numerical results.

Traits§

ContinuousProbabilityMeasure
Contract for a normalized continuous probability measure on the real line.
KernelIntegral
Analytic double integral of a scalar kernel under a probability measure.
KernelMean
Analytic mean embedding of a scalar kernel under a probability measure.
ScalarKernel
Contract for a scalar covariance kernel.