weighted_mean_expectation

weighted_mean_expectation(individual: ndarray, weights: ndarray | None) float[source]

Calculate the expectation of a weighted mean of variables with given individual expected values.

For random variables \(x_1, \ldots, x_n\) with individual expectations \(\mathbb{E}[x_i]\) and scalar weights \(w_1, \ldots, w_n\), the expectation of the weighted mean is:

\[\mathbb{E}\left[\frac{\sum \limits_{i=1}^{n} w_i x_i}{\sum \limits_{j=1}^{n} w_j}\right] = \frac{\sum \limits_{i=1}^{n} w_i \mathbb{E}\left[x_i\right]}{\sum \limits_{j=1}^{n} w_j}\]

When \(w_i = \frac{1}{n}\) (uniform weights, used if no explicit weights are given), the weights are normalized such that \(\sum w_i = 1\).

Note

Unlike variance, the expected value formula is identical for both scaling factor and repeat count interpretations of weights.

Parameters:
  • individual (ndarray) – the individual variables’ expectations, \(\mathbb{E}[x_i]\)

  • weights (ndarray | None) – the individual variables’ scalar weights

Returns:

the expectation of the weighted mean

Return type:

float