egttools.analytical.utils.replicator_equation_n_player

replicator_equation_n_player()

Computes the replicator dynamics gradient for N-player games.

This function extends the replicator equation to games involving more than two players. The payoff for a strategy depends on the configuration of all other strategies in the group, encoded in the payoff_matrix.

Parameters:
  • frequencies (NDArray[np.float64]) – A 1D NumPy array of shape (nb_strategies,) representing the current frequency of each strategy in the population. The entries must sum to 1.

  • payoff_matrix (NDArray[np.float64]) – A 2D NumPy array of shape (nb_strategies, nb_group_configurations). Each row corresponds to a strategy, and each column represents a group composition, indexed using the lexicographic order defined by egttools.sample_simplex.

  • group_size (int) – The number of players interacting simultaneously.

Returns:

A 1D NumPy array of shape (nb_strategies,) containing the replicator gradient for each strategy.

Return type:

NDArray[np.float64]

See also

egttools.replicator_equation, egttools.games.AbstractGame, egttools.analytical.StochDynamics, egttools.numerical.PairwiseComparison

Examples

>>> freqs = np.array([0.3, 0.5, 0.2])
>>> group_size = 3
>>> A = np.random.rand(3, 10)  # payoff matrix with nb_group_configurations columns
>>> grad = replicator_equation_n_player(freqs, A, group_size)
>>> grad.shape
(3,)