weighted_variance¶
- sofia_redux.toolkit.resampling.weighted_variance(error, weights, weightsum=None)[source]¶
Utility function to calculate the biased weighted variance.
Calculates the biased weighted variance from data errors as:
\[V = \frac{\sum{(w\sigma)^2}}{(\sum{w})^2}\]- Parameters:
- errornumpy.ndarray (ndata,)
1-sigma error values.
- weightsnumpy.ndarray (ndata,)
Data weights.
- weightsumint or float, optional
Sum of weights. Optionally passed in for speed if pre-calculated.
- Returns:
- weighted_variancefloat
The weighted variance.