Use discrete replicator dynamicsΒΆ

One of the algorithms implemented in Nashpy is called Discrete Replicator dynamics, this is implemented as a method on the Game class:

>>> import nashpy as nash
>>> import numpy as np
>>> A = np.array([[3, 2], [4, 1]])
>>> game = nash.Game(A)

The discrete_replicator-dynamics produces the strategy distribution for a given number of discrete time steps:

>>> initial_distribution=np.array([0.2,0.8])
>>> strategy_over_time = game.discrete_replicator_dynamics(initial_distribution, steps=100, quantize=False)
>>> strategy_over_time
array([[0.25581395, 0.74418605],
       [0.30494427, 0.69505573],
       [0.34559999, 0.65440001],
...
       [0.5       , 0.5       ],
       [0.5       , 0.5       ],
       [0.5       , 0.5       ]])

Quantization can be used to model a finite integer population:

>>> initial_distribution=np.array([20,80])
>>> strategy_over_time = game.discrete_replicator_dynamics(initial_distribution, steps=100, quantize=True)
>>> strategy_over_time
array([[26., 74.],
       [31., 69.],
       [35., 65.],
...
       [48., 52.],
       [48., 52.],
       [48., 52.]])