In [1]:
import numpy as np
from mc_compute_stationary_sympy import mc_compute_stationary_sympy
In [2]:
A = [[.4, .6], [.2, .8]]
mc_compute_stationary_sympy(A)
Out[2]:
In [3]:
type(_[1][0][0])
Out[3]:
In [4]:
B = np.identity(2)
mc_compute_stationary_sympy(B)
Out[4]:
In [5]:
C = np.identity(3)
mc_compute_stationary_sympy(C)
Out[5]:
Let us try matrices generated by the KMR model where action 1 is risk-dominant, so that the theory says that the unique stationary distribution is close to the distribution that concentrates on the state $N$ (where the state is the number of players playing action 1).
In [6]:
from test_mc_compute_stationary import KMR_Markov_matrix_sequential, KMR_Markov_matrix_simultaneous
In [7]:
P = KMR_Markov_matrix_sequential(N=3, p=1./3, epsilon=1e-14)
eigvals_P, eigvecs_P = mc_compute_stationary_sympy(P)
In [8]:
eigvals_P, eigvecs_P
Out[8]:
In [9]:
[val.evalf(50) for val in eigvals_P]
Out[9]:
In [10]:
[np.dot(vec, P) for vec in eigvecs_P]
Out[10]:
In [11]:
Q = KMR_Markov_matrix_simultaneous(N=5, p=1./3, epsilon=1e-15)
eigvals_Q, eigvecs_Q = mc_compute_stationary_sympy(Q)
In [12]:
eigvals_Q, eigvecs_Q
Out[12]:
In [13]:
[val.evalf(50) for val in eigvals_Q]
Out[13]:
In [14]:
[np.dot(vec, Q) for vec in eigvecs_Q]
Out[14]:
In [15]:
R = KMR_Markov_matrix_sequential(N=27, p=1./3, epsilon=1e-2)
eigvals_R, eigvecs_R = mc_compute_stationary_sympy(R)
In [16]:
eigvals_R, eigvecs_R
Out[16]:
mc_compute_stationary_sympy fails to return any eigenvalue or eigenvector for this $28 \times 28$ matrix.
In [17]:
from sympy.matrices import Matrix
In [18]:
Matrix(P).transpose().eigenvects()
Out[18]:
In [19]:
Matrix(Q).transpose().eigenvects()
Out[19]:
In [20]:
Matrix(R).transpose().eigenvects()
Out[20]:
In [20]: