distribution_variances¶
- sofia_redux.toolkit.resampling.distribution_variances(coordinates, mean=None, covariance=None, mask=None, sigma_inv=None, dof=1)[source]¶
Return variance at each coordinate based on coordinate distribution.
Given a normal sample distribution \(X\), returns the variance at each sample coordinate. For example, consider a population of zero mean (\(\bar{X} = 0\)) and a standard deviation of one (\(\sigma = 1\)). Samples located at \(\bar{X} \pm \sigma\) will return a variance of 1, while samples located at \(\bar{X} \pm 2\sigma\) will return a variance of 4.
By default, the distribution variance is derived using
coordinate_covariance()
, and the sample mean is derived usingcoordinate_mean()
assuming the loss of 1 degree of freedom. However, the expected value (\(E[X]\)) may be supplied with themean
optional parameter along with thecovariance
, and the number of lost degrees of freedom (dof
).- Parameters:
- coordinatesnumpy.ndarray (n_dimensions, n_samples)
The coordinates of the sample distribution.
- meannumpy.ndarray (n_dimensions,), optional
The expected mean value of the distribution.
- covariancenumpy.ndarray (n_dimensions, n_dimensions), optional
The covariance matrix (if known) for the sample distribution.
- masknumpy.ndarray of bool (n_samples,), optional
An array of bool values where
True
indicates a sample should be included when calculating the mean and covariance, andFalse
indicates that a sample should be ignored. By default, all samples are included. The output variance will still be calculated for all samples.- sigma_invnumpy.ndarray (n_dimensions, n_dimensions), optional
The inverse of the covariance matrix, optionally passed in for speed if the covariance is known, and it’s inverse has been pre-calculated.
- dofint or float, optional
The lost degrees of freedom, typically 1 to indicate that the population mean is not known and is replaced by the sample mean.
- Returns:
- variancenumpy.ndarray (n_samples,)
The variance at each sample coordinate based on the sample distribution.