A Python implementation for analyzing the emergence and stability of social hierarchies through evolutionary game theory and stochastic processes.
This repository contains a collection of tools for modeling strategic interactions between players using Markov chains and graph theory. The main focus is on identifying stochastically stable states and minimum stochastic potential equilibria, which help understand how social hierarchies emerge and persist over time.
See social_hierarchies.pdf for the related research paper including the theory developed and a discussion of the computational results.
An implementation of Young (1993) can be found here: https://github.com/ecdogaroglu/evolution_of_conventions.git
To get started, create and activate the environment with
$ conda/mamba env create
$ conda activate social_hierarchiesTo build the project, type
$ pytasksocial-hierarchies/
├── src/
│ └── social_hierarchies/
│ ├── config.py # Project configuration
│ ├── dynamics/ # Core stochastic process implementations
│ │ ├── graph.py # Directed graph analysis
│ │ ├── markov_chain.py # Markov chain computations
│ │ ├── probabilities.py # Probability calculations
│ │ └── task_dynamics.py # Pytask definitions for dynamics
│ ├── final/ # Results processing
│ │ ├── plot.py # Plotting functions
│ │ └── task_final.py # Pytask definitions for plotting
│ ├── game/ # Game theory components
│ │ ├── game.py # State space and best response
│ │ └── task_game.py # Pytask definitions for games
│ └── task_parameters.py # Parameter management
├── paper/ # Documentation/research outputs
└── bld/ # Build directory for results
Edit src/social_hierarchies/task_parameters.py to configure your simulation:
parameters = {
"m": 2, # memory size
"k": 1, # sample size
"epsilon": 0.0001, # experimentation probability
"num_act": 2, # number of actions
"num_players": 2, # number of players (only 2 is supported)
"l": 2, # hierarchy levels
}
# Define game payoffs
parameters["payoffs"] = np.array([
[(1, 1), (0, -1)],
[(-1, 0), (1, 1)]
])- State Space: Represents the history of play between agents
- Transition Matrices: Capture how the system evolves with and without perturbations
- Recurrent Communication Classes (RCC): Sets of states that communicate with each other
- Stochastic Potential: Measures the difficulty of transitioning between RCCs
- Edmonds' Algorithm: Finds the minimum stochastic potential states
The analysis produces several outputs in the bld/ directory:
- Transition matrices for perturbed and unperturbed processes
- Stochastically stable states
- Visualizations of:
- RCC graphs
- Stationary distributions
- Edmonds' arborescences
- Shortest paths between states
This project was created with cookiecutter and the econ-project-templates.
Young, H. Peyton. "The evolution of conventions." Econometrica: Journal of the Econometric Society (1993): 57-84.
This project is licensed under the MIT License - see the LICENSE file for details.