# Internal Functions

These functions are not intended to be used by you, the user.

## Contents

## Index

`DiscreteMarkovChains.breadth_first_search`

`DiscreteMarkovChains.characteristic_matrix`

`DiscreteMarkovChains.digraph`

`DiscreteMarkovChains.is_row_stochastic`

`DiscreteMarkovChains.required_row_sum`

`DiscreteMarkovChains.state_index`

`DiscreteMarkovChains.strongly_connected_components`

## Documentation

The main type is `DiscreteMarkovChain`

:

`DiscreteMarkovChains.strongly_connected_components`

— Function`strongly_connected_components(V::Array, E::Array{Tuple})`

Strongly connected components of a directed graph in reverse topological order. Translated from sympy/utilities/iteratbles.py/strongly*connected*components.

`DiscreteMarkovChains.breadth_first_search`

— FunctionComputes the period of an irreducible transition matrix T must be a 2D array

`DiscreteMarkovChains.digraph`

— Function`digraph(x)`

Creates a digraph (directed graph) representation of a Markov chain.

**Arguments**

`x`

: some kind of Markov chain.

**Returns**

A 1D array of 2-tuples. An element $(i, j)$ is in the array iff the transition matrix at $(i,j)$ is nonzero.

`DiscreteMarkovChains.state_index`

— Function`state_index(x)`

**Arguments**

`x`

: some kind of Markov chain.

**Returns**

A dictionary mapping each state in a Markov chain to its position in the state space. It is essentially the inverse of `state_space(x)`

.

`DiscreteMarkovChains.is_row_stochastic`

— Function`is_row_stochastic(mat, row_sum=1)`

Tests whether a matrix, x, is row stochasitc. The desired sum of each row can be specified as well.

**Definitions**

A matrix is said to be row stochasic if all its rows sum to 1. This definition is extened so that all its rows sum to `row_sum`

.

**Arguments**

`mat`

: a matrix that we want to check.`row_sum`

: the desired value that each row should total to.

**Returns**

`true`

if the given matrix, `mat`

, is row-stochasitc.

`DiscreteMarkovChains.required_row_sum`

— Function`required_row_sum(type)`

**Arguments**

`type`

: The type of Markov chain. It can be

`DiscreteMarkovChain`

or `ContinuousMarkovChain`

.

**Returns**

The number that each row in the transition matrix should sum up to.

`DiscreteMarkovChains.characteristic_matrix`

— Function```
characteristic_matrix(::AbstractDiscreteMarkovChain)
characteristic_matrix(::AbstractContinuousMarkovChain)
```

**Definitions**

Many derivations and interesting ideas about Markov chains involve the identity matrix or zero matrix somewhere along the line. Most of the time, the identity matrix appears more often in discrete Markov chains. Instead of the identity matrix, the zero matrix appears in its place for continuous Markov chains.

**Returns**

The identity matrix if its argument is an instance of `AbstractDiscreteMarkovChain`

. The zero matrix if its argument is an instance of `AbstractContinuousMarkovChain`