This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Plot Markov chain eigenvalues


eVals = eigplot(mc)
[eVals,hz] = eigplot(mc)



eigplot(mc) 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


eVals = eigplot(mc) returns the eigenvalues eVals sorted by magnitude.

[eVals,hz] = eigplot(mc) additionally returns the handle to the eigenvalue plot. Use hz to modify properties of the plot after it is created.


collapse all

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.



Because the spectral gap of mc1 is thicker than the spectral gap of mc2, mc1 mixes faster than mc2.

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.

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 =


Input Arguments

collapse all

Discrete-time Markov chain with NumStates states and transition matrix P, specified as a dtmc object.

Output Arguments

collapse all

Transition matrix eigenvalues sorted by magnitude, returned as a numeric vector.

Eigenvalue plot handle, returned as an object. hz is a unique identifier, which you can use to query and modify properties of the plot.


  • By the Perron-Frobenius Theorem [2], 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 equal to 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


    See asymptotics.


[1] Gallager, R.G. Stochastic Processes: Theory for Applications. Cambridge, UK: Cambridge University Press, 2013.

[2] Horn, R. and C. R. Johnson. Matrix Analysis. Cambridge, UK: Cambridge University Press, 1985.

[3] Seneta, E. Non-negative Matrices and Markov Chains. New York, NY: Springer-Verlag, 1981.

See Also

Introduced in R2017b

Was this topic helpful?