egttools.analytical.utils.calculate_gradients¶
- calculate_gradients(population_states, gradient_function)[source]¶
Calculates the gradients of selection of each of the states given in
population_states
.- Parameters
population_states (numpy.ndarray) – A numpy array of shape (m,n) where n is the number of strategies in the population and m the number of states for which the gradient should be calculated.
gradient_function (Callable[[np.ndarray], np.ndarray]) – A function which accepts a vector of shape (n,) containing the frequencies of each strategy/type in the population, and returns another vector of shape (n,) containing the gradient for each strategy.
- Returns
A numpy array of shape (m,n) containing the gradients for each of the input states given in
population_states
.- Return type