egttools.games.informal_risk.InformalRiskGame¶
- class InformalRiskGame(group_size, cost, multiplying_factor, strategies)[source]¶
Bases:
AbstractGame
Game of informal risk sharing.
This game has been taken from the model introduced in
`Santos, F. P., Pacheco, J. M., Santos, F. C., & Levin, S. A. (2021). Dynamics of informal risk sharing in collective index insurance. Nature Sustainability. https://doi.org/10.1038/s41893-020-00667-2`
to investigate the dynamics of a collective index insurance with informal risk sharing.
Methods
Calculates the Fitness of an strategy for a given population state.
Estimates the payoffs for each strategy and returns the values in a matrix.
Returns the payoff of a strategy given a group composition.
Updates the vector of payoffs with the payoffs of each player after playing the game.
Stores the payoff matrix in a txt file.
Attributes
Number of different strategies playing the game.
Returns the payoff matrix of the game.
returns the type of game.
- __init__(group_size, cost, multiplying_factor, strategies)[source]¶
Game of informal risk sharing.
This game has been taken from the model introduced in
`Santos, F. P., Pacheco, J. M., Santos, F. C., & Levin, S. A. (2021). Dynamics of informal risk sharing in collective index insurance. Nature Sustainability. https://doi.org/10.1038/s41893-020-00667-2`
to investigate the dynamics of a collective index insurance with informal risk sharing.
- __new__(**kwargs)¶
- calculate_fitness(player_strategy, pop_size, population_state)[source]¶
Calculates the Fitness of an strategy for a given population state.
The calculation is done by computing the expected payoff over all possible group combinations for the given population state: $ fitness = sum_{states} payoff * P(state) $ :type player_strategy:
int
:param player_strategy: :type player_strategy: index of the strategy :type pop_size:int
:param pop_size: (might be eliminated in the future) :type pop_size: size of the population - Only necessary for compatibility with the C++ implementation :type population_state:ndarray
:param population_state: :type population_state: vector with the population state (the number of players adopting each strategy)- Return type
The fitness of the population.
- calculate_payoffs()[source]¶
Estimates the payoffs for each strategy and returns the values in a matrix.
Each row of the matrix represents a strategy and each column a game state. E.g., in case of a 2 player game, each entry a_ij gives the payoff for strategy i against strategy j. In case of a group game, each entry a_ij gives the payoff of strategy i for game state j, which represents the group composition.
- Returns
A matrix with the expected payoffs for each strategy given each possible game state.
- Return type
numpy.ndarray[numpy.float64[m, n]]
- payoff(strategy, group_composition)[source]¶
Returns the payoff of a strategy given a group composition.
If the group composition does not include the strategy, the payoff should be zero.
- play(group_composiiton, game_payoffs)[source]¶
Updates the vector of payoffs with the payoffs of each player after playing the game.
This method will run the game using the players and player types defined in :param group_composition, and will update the vector :param game_payoffs with the resulting payoff of each player.