egttools.numerical.numerical_.vectorized_replicator_equation_n_player

vectorized_replicator_equation_n_player()

Vectorized computation of replicator dynamics for 3-strategy N-player games.

This function computes replicator gradients over a meshgrid of frequency values for 3-strategy populations. It is optimized for performance using vectorization.

The three input matrices x1, x2, x3 must represent the frequencies of each strategy over a 2D grid. The sum of x1 + x2 + x3 must equal 1 elementwise.

Parameters:
  • x1 (NDArray[np.float64]) – 2D array of the first strategy’s frequencies.

  • x2 (NDArray[np.float64]) – 2D array of the second strategy’s frequencies.

  • x3 (NDArray[np.float64]) – 2D array of the third strategy’s frequencies.

  • payoff_matrix (NDArray[np.float64]) – Array of shape (3, nb_group_configurations) with payoffs for each strategy.

  • group_size (int) – Number of players in a group interaction.

Returns:

A tuple with three 2D arrays (same shape as input) representing the replicator gradient for each strategy at each grid point.

Return type:

Tuple[NDArray[np.float64], NDArray[np.float64], NDArray[np.float64]]

See also

egttools.replicator_equation_n_player, egttools.vectorized_replicator_equation

Examples

>>> X, Y = np.meshgrid(np.linspace(0, 1, 50), np.linspace(0, 1, 50))
>>> x1 = X
>>> x2 = Y
>>> x3 = 1 - x1 - x2
>>> A = np.random.rand(3, 10)
>>> u1, u2, u3 = vectorized_replicator_equation_n_player(x1, x2, x3, A, 3)
>>> u1.shape
(50, 50)