egttools.numerical.numerical_.calculate_expected_indicators¶
- calculate_expected_indicators()¶
Calculate E[f_k] for multiple indicator functions in a single pass.
Equivalent to calling calculate_expected_indicator once per indicator, but the multivariate hypergeometric PDF is computed only once per (state, group_config) pair and shared across all indicators. Cost is O(states × groups + K) rather than O(K × states × groups).
- Parameters:
pop_size (int) – Total number of individuals in the population.
group_size (int) – Number of individuals sampled per group interaction.
nb_strategies (int) – Number of strategies available in the population.
stationary_distribution (scipy.sparse.csr_matrix) – Sparse matrix representing the stationary distribution over population states.
indicators (list[callable]) – List of functions, each with signature
f(group_config: list[int]) -> float.
- Returns:
One-dimensional array of length
len(indicators); element k is the expected value ofindicators[k].- Return type:
Examples
>>> # Compute cooperation level and group success simultaneously >>> results = calculate_expected_indicators( ... pop_size, group_size, nb_strategies, sd, ... [ ... lambda g: g[0] / group_size, # cooperation level ... lambda g: float(g[0] >= threshold), # group success ... ] ... ) >>> cooperation_level, eta_G = results