egttools.plotting.helpers.calculate_stability¶
- calculate_stability(roots, f, atol=1e-07, return_mode='bool', delta=0.1)[source]¶
Calculates the stability of the roots. Returns stability classification for each root.
From each root \(x\), the function steps a distance
deltain every feasible direction \(d = e_i - e_j\) (moving mass from strategy \(j\) to strategy \(i\) without leaving the simplex) and checks whether the flow points back towards the root (\(f \cdot d < 0\)) or away from it (\(f \cdot d > 0\)). The root is stable if the flow points back in every direction, unstable if it points away in every direction, and a saddle otherwise. Directions that leave an edge or a vertex towards the interior count, so a root that is stable along its edge but invadable by the third strategy is a saddle.- Parameters:
roots (
List[NDArray[double]]) – A list of barycentric coordinates of the roots.f (
Callable[[NDArray[double]],NDArray[double]]) – A function which computes the gradient at any point in the simplex, in barycentric coordinates.atol (
float) – Numerical tolerance for zero comparisons.return_mode (
Literal['bool','int']) –‘bool’ returns True for stable, False otherwise.
’int’ returns 1 (stable), -1 (unstable), or 0 (saddle).
delta (
float) – Size of the perturbation, in barycentric coordinates.
- Returns:
Stability of each root, as booleans or ternary integers.
- Return type: