Search code examples
pythonnumpylinear-algebraprobabilitymarkov-chains

Negative eigenvectors from transition matrix of a Markov chain


I have the following snippet to calculate the steady state of a transition matrix:

import numpy as np
import scipy.linalg as la

if __name__ == "__main__":
    P = np.array([[0.5, 0.2 , 0.3, 0],
                  [0.5, 0 , 0.1 , 0.4],
                  [0.6, 0.1, 0, 0.3],
                  [0.5, 0.2, 0.3, 0]])
    # Sanity check:
    assert np.sum(P, axis=1).all() == 1.0
    print la.eig(P,left=True)[1]

and it prints:

[[ -8.78275813e-01  -7.07106781e-01  -5.00000000e-01   1.47441956e-01]
 [ -2.51874610e-01  -1.58270385e-16  -5.00000000e-01  -2.94883912e-01]
 [ -3.50434239e-01  -2.60486675e-16   5.00000000e-01  -5.89767825e-01]
 [ -2.05880116e-01   7.07106781e-01   5.00000000e-01   7.37209781e-01]]

If I understand correctly the first column of this is indeed the steady state. It does not make sense to me for the probability of being in a state to be negative. What have I missed?


Solution

  • Any nonzero scalar multiple of an eigenvector is an eigenvector. This thus also includes vectors of the form v = -n * w, n > 0 and w a positive eigenvector.