coordinate_mean

sofia_redux.toolkit.resampling.coordinate_mean(coordinates, mask=None)[source]

Returns the mean coordinate of a distribution.

Given a distribution of \(N\) coordinates in \(K\) dimensions, the mean coordinate in dimension \(k\) is given as:

\[\bar{x_k} = \frac{\sum_{i=1}^{N}{w_i x_{k,i}}}{\sum_{i=1}^{N}{w_i}}\]

where \(w_i = 0\) if mask[i] is False and \(w_i = 1\) if mask[i] is True.

Parameters:
coordinatesnumpy.ndarray (n_dimensions, n_coordinates)

The coordinate distribution.

masknumpy.ndarray of bool (n_coordinates,), optional

An array of bool values where True indicates a coordinate should be included in the calculation, and False indicates that a coordinate should be ignored. By default, all coordinates are included.

Returns:
mean_coordinatenumpy.ndarray (n_dimensions,)

The mean coordinate of the distribution.