pub struct SparseAtomCodes { /* private fields */ }Expand description
Storage for the per-row codes of all N observations.
Held column-of-structs rather than struct-of-columns: each row’s
(active_mask, weights) lives together because the atom-selection
strategies all touch a single row at a time. Cross-row vectorization
happens through ndarray views built on demand.
Implementations§
Source§impl SparseAtomCodes
impl SparseAtomCodes
Sourcepub fn empty(n_obs: usize, k_atoms: usize) -> Self
pub fn empty(n_obs: usize, k_atoms: usize) -> Self
Allocate n_obs empty codes, each sized for k_atoms.
pub fn n_obs(&self) -> usize
pub fn k_atoms(&self) -> usize
pub fn row(&self, n: usize) -> &SparseAtomCode
pub fn row_mut(&mut self, n: usize) -> &mut SparseAtomCode
pub fn iter(&self) -> impl Iterator<Item = &SparseAtomCode>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut SparseAtomCode>
Sourcepub fn weights_matrix(&self) -> Array2<f64>
pub fn weights_matrix(&self) -> Array2<f64>
Flatten weights into a single (N, K) array, with zeros where the
mask is unset. Allocates; intended for diagnostic / post-fit use.
Sourcepub fn coactivation(&self, a: usize, b: usize) -> CoactivationStats
pub fn coactivation(&self, a: usize, b: usize) -> CoactivationStats
Co-activation statistics for one atom pair (a, b) — the #976
code-dependence trigger. Pure popcount ratios over the active masks:
P(a|b) = #{rows: a∧b} / #{rows: b} and symmetrically.
Two derived readings drive the structure search:
CoactivationStats::dependence(symmetric, the FUSION trigger) — independent atoms with marginal activation ratesπ_a, π_bco-activate at rateπ_a·π_b, so both conditionals stay near the marginals; a shattered curved family re-encoded as several near-duplicate atoms pushes both conditionals toward 1.CoactivationStats::absorption_asymmetry(the ABSORPTION-audit trigger) — an A⇒B hierarchy where sparsity folded B’s content into A showsP(parent|child) ≈ 1without the converse, so a large asymmetry with one conditional near 1 flags the pair for the within-atom substructure audit (#907 race on the atom’s own code distribution).
These are triggers, not decisions: they rank move proposals
deterministically; acceptance is owned by the e-process gates in
gam_solve::structure_search.
Sourcepub fn weight_codependence(&self, a: usize, b: usize) -> f64
pub fn weight_codependence(&self, a: usize, b: usize) -> f64
#976 — the AMPLITUDE half of the fusion criterion: the Pearson
correlation of the two atoms’ activation WEIGHTS over the rows where both
are active. Support co-activation (CoactivationStats::dependence) only
says the two atoms fire together; it cannot distinguish a single curved
family SHATTERED across two near-duplicate atoms (where moving along the
family smoothly trades amplitude between the pair, so their weights are
strongly — typically negatively — correlated on the joint support) from
two GENUINELY INDEPENDENT atoms that merely happen to co-fire on the same
input class (weights uncorrelated). The magnitude |ρ| of this
correlation is the interaction-evidence the issue’s fusion trigger pairs
with code dependence: high support-overlap AND high |weight_correlation|
is the shattering signature (“dependent codes + joint interaction
evidence”), whereas high overlap with |ρ|≈0 is two independent features
that should NOT be fused.
Returns 0.0 when fewer than two rows are jointly active or when either
atom’s weight is constant on the joint support (an undefined correlation
is, for the trigger, “no amplitude dependence detected”).
Trait Implementations§
Source§impl Clone for SparseAtomCodes
impl Clone for SparseAtomCodes
Source§fn clone(&self) -> SparseAtomCodes
fn clone(&self) -> SparseAtomCodes
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 SparseAtomCodes
impl RefUnwindSafe for SparseAtomCodes
impl Send for SparseAtomCodes
impl Sync for SparseAtomCodes
impl Unpin for SparseAtomCodes
impl UnsafeUnpin for SparseAtomCodes
impl UnwindSafe for SparseAtomCodes
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.