egttools.calculate_expected_state_indicators

calculate_expected_state_indicators()

Calculate E[f_k] = sum_s sd(s) * f_k(s) for multiple state-level indicators in one pass.

Iterates over non-zero states in the stationary distribution exactly once, evaluating all indicators at each state. Cost: O(nb_nonzero_states * K) where K is the number of indicators.

Parameters:
  • pop_size (int) – Total number of individuals in the population.

  • nb_strategies (int) – Number of strategies available in the population.

  • stationary_distribution (scipy.sparse.csr_matrix) – Sparse stationary distribution over population states.

  • indicators (list[callable]) – List of functions, each mapping a population state (list[int]) to a float.

Returns:

Vector of length len(indicators) with the expected value of each indicator.

Return type:

numpy.ndarray