egttools.sample_simplex

sample_simplex()

Converts a state index into a group composition vector.

This function performs the inverse of calculate_state, returning a vector representing the number of individuals using each strategy from a given index.

Parameters:
  • index (int) – Index of the population state (from 0 to total number of states - 1).

  • pop_size (int) – Population size (total number of individuals in the group).

  • nb_strategies (int) – Number of available strategies.

Returns:

A vector of length nb_strategies where each entry represents the number of individuals using the corresponding strategy.

Return type:

NDArray[np.int64]

Examples

>>> sample_simplex(0, 3, 3)
array([3, 0, 0])
>>> sample_simplex(3, 3, 3)
array([1, 1, 1])