egttools.analytical.utils.calculate_gradients

calculate_gradients(population_states, gradient_function)[source]

Calculate the selection gradients for a list of population states.

Parameters:
  • population_states (ndarray of shape (m, n)) – A 2D NumPy array where each row corresponds to a population state, with n strategies and m total states.

  • gradient_function (Callable[[ndarray], ndarray]) – A function that takes a 1D NumPy array of strategy frequencies (length n) and returns a 1D array representing the gradient for each strategy.

Returns:

A NumPy array where each row contains the gradient of selection for the corresponding input population state.

Return type:

ndarray of shape (m, n)