egttools.helpers.vectorized.cpp_vectorized_replicator_equation_n_player

cpp_vectorized_replicator_equation_n_player()

vectorized_replicator_equation_n_player(x1: numpy.ndarray[numpy.float64[m, n]], x2: numpy.ndarray[numpy.float64[m, n]], x3: numpy.ndarray[numpy.float64[m, n]], payoff_matrix: numpy.ndarray[numpy.float64[m, n]], group_size: int) -> Tuple[numpy.ndarray[numpy.float64[m, n]], numpy.ndarray[numpy.float64[m, n]], numpy.ndarray[numpy.float64[m, n]]]

Calculates the gradient of the replicator dynamics given the current population state.

This function must only be used for 3 strategy populations! It provides a fast way to compute the gradient of selection for a large number of population states.

You need to pass 3 matrices each containing the frequency of one strategy.

The combination of [x1[i,j], x2[i,j], x3[i,j]], gives the population state.

Parameters
  • x1 (numpy.ndarray) – Matrix containing the first component of the frequencies

  • x2 (numpy.ndarray) – Matrix containing the second component of the frequencies

  • x3 (numpy.ndarray) – Matrix containing the third component of the frequencies

  • payoff_matrix (numpy.ndarray) – A payoff matrix containing the payoff of each row strategy for each possible group configuration, indicated by the column index. The matrix must have shape (nb_strategies, nb_group_configurations).

  • group_size (int) – size of the group

Returns

Returns 3 matrices containing the gradient of each strategy. Each Matrix has the same shape as x1, x2 and x3.

Return type

Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]