check_edge_with_distribution

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

Defines an edge based on statistical deviation from a sample distribution.

Given a sample distribution (\(X\)) of coordinates, the deviation of a reference coordinate \(X_{ref}\) from the mean sample distribution \(\bar{X}\) is given as:

\[\sigma_{ref} = \sqrt{(X_{ref} - \bar{X})^{T} \Sigma^{-1} (X_{ref} - \bar{X})}\]

where \(\Sigma\) is the sample covariance of \(X\). In this definition, the “edge” of the distribution is defined at \(\beta = 1 / threshold\) so that reference locations where \(\sigma_{ref} \leq \beta\) are considered inside the distribution edge. For example, setting threshold = 2 will return a False value if \(\sigma_{ref} > 0.5\).

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 any distribution statistics.

thresholdint or float

The “edge” of the distribution is given by 1 / threshold. If the deviation of the reference coordinate from the distribution mean is greater than the edge, a False value will be returned. Setting threshold to zero results in an edge at infinity, i.e., all reference coordinates will be considered inside the distribution edge.

Returns:
insidebool

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