code: def weighted_mean_expectation(
      individual: np.ndarray, weights: Optional[np.ndarray]
  ) -> float:
      r"""
      Calculate the expectation of a weighted sum of variables with given individual expected value.
  
      .. math::
          \mathbb{E}\left[\sum \limits_{i=1}^{n} w_i x_i\right]
              = \sum \limits_{i=1}^{n} w_i \mathbb{E}\left[x_i\right]
  
      where $w_i = \frac{1}{n}$, if no explicit weights are given. Moreover, the weights are normalized such that
      $\sum w_i = 1$.
  
      :param individual:
          the individual variables' expectations, $\mathbb{E}[x_i]$
      :param weights:
          the individual variables' weights
  
      :return:
          the variance of the weighted mean
      """
      return np.average(individual, weights=weights).item()
  
imports: from dataclasses import dataclass
  from typing import ClassVar, Collection, Optional
  import numpy
  from docdata import get_docdata
  from scipy import stats
  from ..utils import ExtraReprMixin, camel_to_snake
label_desc: Use image node_id 1 for calling a global function with example usage: weighted_mean_expectation(individual, weights) and returns: np