Plot Markov chain eigenvalues
eVals = eigplot(mc)
[eVals,hz] = eigplot(mc)
eigplot( creates a plot of the
eigenvalues of the transition matrix of the discrete-time Markov chain
mc on the complex plane. The plot highlights:
The unit circle
The Perron-Frobenius eigenvalue at (1,0)
The circle of second largest eigenvalue magnitude (SLEM)
the spectral gap between the two circles, which determines the mixing time
Create 10-state Markov chains from two random transition matrices, with one transition matrix being more sparse than the other.
rng(1); % For reproducibility numstates = 10; mc1 = mcmix(numstates,'Zeros',20); mc2 = mcmix(numstates,'Zeros',80); % mc2.P is more sparse than mc1.P
Plot the eigenvalues of the transition matrices on the separate complex planes.
figure; eigplot(mc1); figure; eigplot(mc2);
Because the spectral gap of
mc1 is thicker than the spectral gap of
mc1 mixes faster than
Consider this theoretical, right-stochastic transition matrix of a stochastic process.
Create the Markov chain that is characterized by the transition matrix P.
P = [ 0 0 1/2 1/4 1/4 0 0 ; 0 0 1/3 0 2/3 0 0 ; 0 0 0 0 0 1/3 2/3; 0 0 0 0 0 1/2 1/2; 0 0 0 0 0 3/4 1/4; 1/2 1/2 0 0 0 0 0 ; 1/4 3/4 0 0 0 0 0 ]; mc = dtmc(P);
Plot and return the eigenvalues of the transition matrix on the complex plane.
figure; eVals = eigplot(mc)
eVals = -0.5000 + 0.8660i -0.5000 - 0.8660i 1.0000 + 0.0000i -0.3207 + 0.0000i 0.1604 + 0.2777i 0.1604 - 0.2777i -0.0000 + 0.0000i
There are three eigenvalues with modulus one, which indicates that the period of
mc is three.
Compute the mixing time of the Markov chain.
[~,tMix] = asymptotics(mc)
tMix = 0.8793
eVals— Transition matrix eigenvalues
Transition matrix eigenvalues sorted by magnitude, returned as a numeric vector.
hz— Eigenvalue plot handle
Eigenvalue plot handle, returned as an object.
hz is a
unique identifier, which you can use to query and modify properties of the
By the Perron-Frobenius Theorem , a chain
with a single recurrent communicating class (a
unichain) has exactly one eigenvalue equal to
1 (the Perron-Frobenius eigenvalue), and an
accompanying nonnegative left eigenvector that normalizes to a unique
stationary distribution. All other eigenvalues have modulus less than or
1. The inequality is strict unless the recurrent
class is periodic. When there is periodicity of period k,
there are k eigenvalues on the unit circle at the
k roots of unity.
For an ergodic unichain, any initial distribution converges to the stationary distribution at a rate determined by the second largest eigenvalue modulus (SLEM), μ. The spectral gap, 1 – μ, provides a visual measure, with large gaps (smaller SLEM circles) producing faster convergence. Rates are exponential, with a characteristic time given by
 Gallager, R.G. Stochastic Processes: Theory for Applications. Cambridge, UK: Cambridge University Press, 2013.
 Horn, R. and C. R. Johnson. Matrix Analysis. Cambridge, UK: Cambridge University Press, 1985.
 Seneta, E. Non-negative Matrices and Markov Chains. New York, NY: Springer-Verlag, 1981.