Skip to content

Stochastic_fictitious_play fails for large valued payoff matrices #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
katiemcgoldrick opened this issue Mar 30, 2021 · 0 comments
Open

Comments

@katiemcgoldrick
Copy link
Contributor

In #100 stochastic fictitious play is implemented but it fails for large values pay off matrices due to an overflow error when computing the exponential of large numbers.

>>> import nashpy as nash
>>> import numpy as np
>>> A = np.array([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
>>> B = A + 71
>>> game=nash.Game(A,B)
>>> tuple(game.stochastic_fictitious_play(iterations=10))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-867513ac063a> in <module>
----> 1 x = tuple(game.stochastic_fictitious_play(iterations=10))

c:\users\kathr\desktop\nashpy\src\nashpy\learning\stochastic_fictitious_play.py in stochastic_fictitious_play(A, B, iterations, etha, epsilon_bar, play_counts)
     44         ]
     45 
---> 46         plays = [
     47             np.random.choice(range(len(distribution)), p=distribution)
     48             for distribution in distributions

c:\users\kathr\desktop\nashpy\src\nashpy\learning\stochastic_fictitious_play.py in <listcomp>(.0)
     45 
     46         plays = [
---> 47             np.random.choice(range(len(distribution)), p=distribution)
     48             for distribution in distributions
     49         ]

mtrand.pyx in numpy.random.mtrand.RandomState.choice()

ValueError: probabilities contain NaN

This breaks down because of :

>>> np.exp(700)
1.0142320547350045e+304
>>> np.exp(710)
inf

Speaking with @drvinceknight and @11michalis11 , two possible solutions are 1) catch the error and provide a better error message or 2) rescale the matrix automatically

@drvinceknight drvinceknight changed the title Stochastic_fictitious_play fails for large payoff matrices Stochastic_fictitious_play fails for large valued payoff matrices Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant