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
//! Multivariate robust statistics: robust estimates of multivariate location
//! and scatter and the outlier detection built on them.
//!
//! The organizing object here is a **location–scatter pair** `(μ̂, Σ̂)` (a
//! robust centre and a robust covariance) from which a robust Mahalanobis
//! distance `dᵢ = √((xᵢ − μ̂)ᵀ Σ̂⁻¹ (xᵢ − μ̂))` flags multivariate outliers, just
//! as robust residuals flag them in regression. Four estimators produce such a
//! pair, trading efficiency against breakdown and equivariance:
//!
//! - [`Mcd`]: the Minimum Covariance Determinant (Rousseeuw 1985) via FAST-MCD
//! (Rousseeuw & Van Driessen 1999): 50%-breakdown, affine-equivariant, the
//! multivariate analogue of LTS.
//! - [`Ogk`]: the Orthogonalized Gnanadesikan–Kettenring estimator
//! (Maronna & Zamar 2002): a fast, deterministic, positive-definite pairwise
//! estimator (orthogonally, not fully affine, equivariant).
//! - [`MScatter`]: a monotone M-estimator of location and scatter
//! (Maronna 1976): the direct multivariate analogue of the regression
//! M-estimator, reusing a [`robust_rs_core::rho::RhoFunction`] weight.
//! - [`Tyler`]: Tyler's (1987) distribution-free M-estimator of *shape*,
//! normalized to unit determinant.
//!
//! [`mahalanobis`] exposes the distance/outlier map over *any* `(μ̂, Σ̂)` pair,
//! together with the classical (non-robust) mean/covariance baseline.
pub use MScatter;
pub use ;
pub use Ogk;
pub use ;
use ;
use RobustError;
use chi2_quantile;
use ;
/// A fitted robust location–scatter estimate.
///
/// The shared result type of [`MScatter`] and [`Ogk`]. FAST-MCD carries extra
/// structure (a raw estimate and the retained subset), so it returns its own
/// [`McdFit`], but that type implements [`RobustScatter`] too, so all three are
/// interchangeable behind the trait and the Mahalanobis/outlier map is written
/// once against `(μ̂, Σ̂)`. [`Tyler`] does *not* use this type: it returns a
/// bespoke [`TylerFit`] implementing no shared trait, because its shape-only
/// distances are not `χ²`-calibrated, so this type's Gaussian outlier map would
/// misapply to them.
/// Quantities every fitted robust covariance estimator can report, the
/// multivariate counterpart of [`crate::estimator::RobustEstimator`].
/// Robust Mahalanobis distances `dᵢ = √((xᵢ − loc)ᵀ scatter⁻¹ (xᵢ − loc))` for
/// every row of `x`. Shared by the estimators to populate [`ScatterFit`] and
/// re-exported publicly as [`mahalanobis::mahalanobis_distances`]. Errors if the
/// scatter is not positive definite.
pub