Last updated on Sep 04, 2024.

netsse.tools.misc_func.weighted_std#

netsse.tools.misc_func.weighted_std(a, w, axis=None, ddof=1)#

Computes the weighted standard deviation of some data.

The weighted standard deviation is a measure of the spread of a distribution of the array elements from the mean, where some of the elements are more significant than others. The weighted standard deviation is calculated based on the weighted mean and it attaches more importance to data that have more weight than to data with less weight (National Institute of Standards and Technology, 1996).

Parameters:
  • a (array_like) – Variable for which the weighted std. must be computed.

  • w (array_like) – Array of weights. All elements must be positive. The array w must broadcastable with the array a.

  • axis (None or int, optional) – Axis or axes along which the standard deviation is computed. The default is to compute the weighted standard deviation of the flattened array.

  • ddof (int, default 0) – Delta Degrees of Freedom. The divisor used in the calculations is (N_nz - ddof)/N_nz, where N_nz represents the number of non-zero weights.

Returns:

std – Weighted standard deviation of the data.

Return type:

array_like

See also

weighted_quantile

Computes the q-th quantiles of weighted data.

References

National Institute of Standards and Technology, 1996. Formula for the weighted standard deviation. Available at: https://www.itl.nist.gov/div898/software/dataplot/refman2/ch2/weightsd.pdf (Consulted on 06-08-2023).

Example

>>> std = weighted_std(a,w,axis=None,ddof=1)