egttools.numerical.numerical_.calculate_expected_indicator¶
- calculate_expected_indicator()¶
Calculate E[f] = sum_s sd(s) * sum_g P(g|s) * f(g) for an arbitrary indicator f.
The callable
indicatorreceives a list of ints representing the count of each strategy in the sampled group (length nb_strategies, sums to group_size) and must return a float.- 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.
indicator (callable) – Function with signature
f(group_config: list[int]) -> float.
- Returns:
Expected value of the indicator.
- Return type:
Examples
>>> # Expected group success for CRD: cooperators are strategy 0, threshold = 3 >>> eta_G = calculate_expected_indicator( ... pop_size, group_size, nb_strategies, sd, ... lambda g: float(g[0] >= 3) ... )