pub struct StructuredResidualModel { /* private fields */ }Expand description
The fitted structured residual-covariance model: low-rank factor Λ,
idiosyncratic diagonal D, and the smooth activity-scale c(z) evaluated at
every row. Produces per-row precision factors and the
MetricProvenance::WhitenedStructured
RowMetric.
Implementations§
Source§impl StructuredResidualModel
impl StructuredResidualModel
Sourcepub fn fit(input: ResidualFactorInput<'_>) -> Result<Self, String>
pub fn fit(input: ResidualFactorInput<'_>) -> Result<Self, String>
Fit the structured residual-covariance model by the deterministic fixed-iteration alternation, selecting the factor rank by the evidence ladder. Returns an error only on shape / non-finite-input violations; the numerical path is total (every floor and solve is guarded).
Sourcepub fn factor_rank(&self) -> usize
pub fn factor_rank(&self) -> usize
Selected factor rank r.
Sourcepub fn factor(&self) -> ArrayView2<'_, f64>
pub fn factor(&self) -> ArrayView2<'_, f64>
The fitted interference factor Λ ∈ ℝ^{p×r} (the shared off-isotropic
residual subspace). Consumed by the planted-subspace recovery test to
compare range(Λ) against the planted interference subspace.
Sourcepub fn diagonal(&self) -> ArrayView1<'_, f64>
pub fn diagonal(&self) -> ArrayView1<'_, f64>
The idiosyncratic diagonal d ∈ ℝ^p (D = diag(d)).
Sourcepub fn row_scale(&self) -> ArrayView1<'_, f64>
pub fn row_scale(&self) -> ArrayView1<'_, f64>
The per-row activity scale c(z_n) > 0, length n. Recovers the smooth
activity-scale law evaluated at every observed z_n.
Sourcepub fn log_evidence(&self) -> f64
pub fn log_evidence(&self) -> f64
The penalized Gaussian log-evidence the rank-selection ladder maximized.
Sourcepub fn row_metric(&self, n_rows: usize) -> Result<RowMetric, String>
pub fn row_metric(&self, n_rows: usize) -> Result<RowMetric, String>
Build the per-row precision factor stack U_n ∈ ℝ^{p×p} with
U_n U_nᵀ = Σ_n^{-1} and package it as a
MetricProvenance::WhitenedStructured
RowMetric. This is the single
production site of WhitenedStructured.
The precision is formed in Woodbury form:
Σ_n^{-1} = D^{-1} − D^{-1} Λ ( c^{-1} I_r + Λᵀ D^{-1} Λ )^{-1} Λᵀ D^{-1},an r × r capacitance solve (never a p × p inverse). The factor U_n
is the lower-Cholesky of the assembled Σ_n^{-1} (rank = p), so
whiten_residual_row returns coordinates whose squared norm is the exact
Mahalanobis residual r_nᵀ Σ_n^{-1} r_n.
Trait Implementations§
Source§impl Clone for StructuredResidualModel
impl Clone for StructuredResidualModel
Source§fn clone(&self) -> StructuredResidualModel
fn clone(&self) -> StructuredResidualModel
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for StructuredResidualModel
impl RefUnwindSafe for StructuredResidualModel
impl Send for StructuredResidualModel
impl Sync for StructuredResidualModel
impl Unpin for StructuredResidualModel
impl UnsafeUnpin for StructuredResidualModel
impl UnwindSafe for StructuredResidualModel
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.