robust_rs_core/lib.rs
1//! Shared spine of the [`robust-rs`] project: the M-estimator loss trait, robust
2//! scale estimation and the influence-function / efficiency / breakdown-point
3//! theory. Dependency-light (no linear algebra; only `libm`, `num-traits`,
4//! `thiserror`), so it builds for `wasm32` and can be depended on for just the
5//! losses and theory. The estimators live in the [`robust-rs`] crate.
6//!
7//! # Modules
8//!
9//! - [`rho`]: the organizing [`RhoFunction`](rho::RhoFunction) trait (`ρ`, `ψ`,
10//! `weight`, `ψ'`, `tuning`, `is_redescending`, `rho_sup`) and its
11//! implementations: [`LeastSquares`](rho::LeastSquares), [`L1`](rho::L1),
12//! [`Huber`](rho::Huber), [`TukeyBiweight`](rho::TukeyBiweight),
13//! [`Cauchy`](rho::Cauchy), [`Welsch`](rho::Welsch), [`Andrews`](rho::Andrews),
14//! [`Hampel`](rho::Hampel).
15//! - [`scale`]: the [`ScaleEstimator`](scale::ScaleEstimator) trait and the robust
16//! scales [`Mad`](scale::Mad), [`HuberProposal2`](scale::HuberProposal2),
17//! [`SScale`](scale::SScale), [`Qn`](scale::Qn), [`Sn`](scale::Sn).
18//! - [`theory`][]: [`influence_function`](theory::influence_function),
19//! [`asymptotic_variance`](theory::asymptotic_variance),
20//! [`gaussian_efficiency`](theory::gaussian_efficiency),
21//! [`breakdown_point`](theory::breakdown_point) and the
22//! [`gauss_hermite`](theory::gauss_hermite) quadrature underneath them.
23//! - [`solver`]: the [`Control`](solver::Control) stopping rule shared by the
24//! iterative estimators.
25//! - [`types`]: the [`Scale`](types::Scale), [`TuningConstant`](types::TuningConstant),
26//! [`RawResidual`](types::RawResidual) / [`ScaledResidual`](types::ScaledResidual)
27//! newtypes.
28//! - [`error`]: the crate-wide [`RobustError`](error::RobustError).
29//!
30//! ```
31//! use robust_rs_core::rho::{Huber, RhoFunction};
32//! use robust_rs_core::theory::gaussian_efficiency;
33//!
34//! let huber = Huber::default(); // k = 1.345
35//! assert_eq!(huber.psi(10.0), 1.345); // clipped score: bounded influence
36//! assert!((gaussian_efficiency(&huber, 128) - 0.95).abs() < 0.01);
37//! ```
38//!
39//! [`robust-rs`]: https://docs.rs/robust-rs
40#![deny(missing_docs)]
41
42pub mod error;
43pub mod rho;
44pub mod scale;
45pub mod solver;
46pub mod theory;
47pub mod types;