Computes the spectral gap of a finite, irreducible discrete-time Markov chain, a lightweight diagnostic of its convergence and mixing behaviour.
Value
A numeric scalar in \([0,1]\) containing the spectral gap. For
the trivial one-state chain, 1 is returned.
Details
The spectral gap is defined from the second largest eigenvalue modulus
(SLEM, see slem) as
$$\mathrm{gap} = 1 - \mathrm{SLEM}.$$
As with slem, only irreducibility is required. A periodic
chain has SLEM = 1 and therefore spectral gap 0: this is
the mathematically correct value, not an error condition, since a
periodic chain never contracts towards its stationary distribution.
A larger spectral gap indicates faster convergence to stationarity; see
impliedTimescales for the timescale associated with each
non-trivial eigenvalue individually, of which the SLEM gives the slowest
(dominant) one.
References
Levin, D. A. and Peres, Y. (2017). Markov Chains and Mixing Times, 2nd edition. American Mathematical Society.