# Documentation

### This is machine translation

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

# isergodic

Check Markov chain for ergodicity

## Syntax

``tf = isergodic(mc)``

## Description

example

````tf = isergodic(mc)` returns `true` if the discrete-time Markov chain `mc` is ergodic and `false` otherwise.```

## Examples

collapse all

Consider this three-state transition matrix.

Create the Markov chain that is characterized by the transition matrix P.

```P = [0 1 0; 0 0 1; 1 0 0]; mc = dtmc(P); ```

Determine whether the Markov chain is ergodic.

```isergodic(mc) ```
```ans = logical 0 ```

`0` indicates that the Markov chain is not ergodic.

Visually confirm that the Markov chain is not ergodic by plotting its eigenvalues on the complex plane.

```figure; eigplot(mc); ```

All three eigenvalues have modulus one. This result indicates that the period of the Markov chain is three. Periodic Markov chains are not ergodic.

## Input Arguments

collapse all

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

## Output Arguments

collapse all

Ergodicity flag, returned as `true` if `mc` is an ergodic Markov chain and `false` otherwise.

collapse all

### Ergodic Chain

A Markov chain is ergodic if it is both irreducibile and aperiodic. This condition is equivalent to the transition matrix being a primitive nonnegative matrix.

## Algorithms

• By Wielandt's theorem [3], the Markov chain `mc` is ergodic if and only if all elements of Pm are positive for m = (n - 1)2 + 1. P is the transition matrix (`mc.P`) and n is the number of states (`mc.NumStates`). To determine ergodicity, `isergodic` computes this matrix power.

• By the Perron-Frobenius Theorem [2], ergodic Markov chains have unique limiting distributions. That is, they have unique stationary distributions to which every initial distribution converges. Ergodic unichains, which consist of a single ergodic class plus transient classes, also have unique limiting distributions (with zero probability mass in the transient classes).

## References

[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] Wielandt, H. "Unzerlegbare, Nicht Negativen Matrizen." Mathematische Zeitschrift. Vol. 52, 1950, pp. 642-648.