egttools.plotting.simplified.lattice_gradient_interpolator

lattice_gradient_interpolator(gradient_fn, population_size)[source]

Continuous extension of a gradient defined on the states of a finite population of 3 strategies.

The gradient of selection of a finite population is defined only at the integer states \((n_0, n_1, n_2)\) with \(n_0 + n_1 + n_2 = Z\). This function evaluates gradient_fn once at every such state and interpolates linearly inside each triangle of the lattice, which gives a continuous, piecewise-linear field that equals the exact gradient at every population state. Root finding, stability analysis and trajectory integration need such a continuous field.

Parameters:
  • gradient_fn (Callable[[NDArray[int_]], NDArray[double]]) – Function returning the gradient (length 3) at an integer population state.

  • population_size (int) – Population size \(Z\).

Returns:

The interpolating function, which takes a state in counts (3 floats; it is projected onto the plane \(\sum_i n_i = Z\) and clipped to the simplex), and the array of lattice gradients of shape (Z + 1, Z + 1, 3), where entry [i, j] holds the gradient at state (i, j, Z - i - j) and entries with i + j > Z are NaN.

Return type:

Tuple[Callable[[NDArray[double]], NDArray[double]], NDArray[double]]