check_edge_with_ellipsoid

sofia_redux.toolkit.resampling.check_edge_with_ellipsoid(coordinates, reference, mask, threshold)[source]

Defines an ellipsoid edge around a coordinate distribution.

Given a distribution (\(X\)) of \(N\) samples in \(K\) dimensions, the center of mass for dimension \(k\) is:

\[\bar{X}_{k} = \frac{1}{N} \sum_{i=1}^{N}{X_{ik}}\]

The ellipsoid center is at \(\bar{X}\) with principle axes given by \(\beta\), where \(\beta = 1 - \text{threshold}\). Note that the resampling algorithm scales all coordinates to a window parameter such that \(|X_k| \leq 1\), and the threshold parameter therefore defines a fraction of the window in the range \(0 < \text{threshold} < 1\). If threshold[k] = 0 or 1, then no edge will be defined for dimension \(k\), and the ellipsoid definition will only apply over remaining dimensions (dimension \(k\) will be ignored in all calculations).

A reference coordinate (\(X_{ref}\)) is considered inside the ellipsoid edge if:

\[\sum_{k=1}^{K}{\frac{(X_{ref, k} - \bar{X}_k)^2}{\beta_k^2}} \leq 1\]
Parameters:
coordinatesnumpy.ndarray (n_dimensions, n_samples)

The coordinates of the sample distribution.

referencenumpy.ndarray (n_dimensions,)

The reference coordinate.

masknumpy.ndarray of bool (n_samples,)

A mask where False values exclude the corresponding sample from the center-of-mass calculation.

thresholdnumpy.ndarray (n_dimensions,)

Defines the principle axes (1 - threshold) of an ellipsoid centered on the coordinate center of mass in units of the resampling window parameter. Must be in the range 0 < threshold < 1.

Returns:
insidebool

True if reference is inside the distribution “edge” and False otherwise.