In mathematics, a stochastic matrix is a square matrix used to describe the transitions of a Markov chain. Each of its entries is a nonnegative real number representing a probability.:9–11 It is also called a probability matrix, transition matrix, substitution matrix, or Markov matrix.:9–11
The stochastic matrix was first developed by Andrey Markov at the beginning of the 20th century, and has found use throughout a wide variety of scientific fields, including probability theory, statistics, mathematical finance and linear algebra, as well as computer science and population genetics.:1–8
There are several different definitions and types of stochastic matrices::9–11
In the same vein, one may define a stochastic vector (also called probability vector) as a vector whose elements are nonnegative real numbers which sum to 1. Thus, each row of a right stochastic matrix (or column of a left stochastic matrix) is a stochastic vector.:9–11
A common convention in English language mathematics literature is to use row vectors of probabilities and right stochastic matrices rather than column vectors of probabilities and left stochastic matrices; this article follows that convention.:1–8
The stochastic matrix was developed alongside the Markov chain by Andrey Markov, a Russian mathematician and professor at St. Petersburg University who first published on the topic in 1906.:1–8 His initial intended uses were for linguistic analysis and other mathematical subjects like card shuffling, but both Markov chains and matrices rapidly found use in other fields.:1–8
Stochastic matrices were further developed by scholars like Andrey Kolmogorov, who expanded their possibilities by allowing for continuous-time Markov processes. By the 1950s, articles using stochastic matrices had appeared in the fields of econometrics and circuit theory. In the 1960s, stochastic matrices appeared in an even wider variety of scientific works, from behavioral science to geology to residential planning. In addition, much mathematical work was also done through these decades to improve the range of uses and functionality of the stochastic matrix and Markovian processes more generally.
From the 1970s to present, stochastic matrices have found use in almost every field that requires formal analysis, from structural science to medical diagnosis to personnel management. In addition, stochastic matrices have found wide use in land change modeling, usually under the term Markov matrix.
If the probability of moving from to in one time step is , the stochastic matrix is given by using as the row and column element, e.g.,
Since the total of transition probability from a state to all other states must be 1,
thus this matrix is a right stochastic matrix.:1–8
The above elementwise sum across each row of may be more concisely written as , where is the -dimensional vector of all ones. Using this, it can be seen that the product of two right stochastic matrices and is also right stochastic: . In general, the -th power of a right stochastic matrix is also right stochastic. The probability of transitioning from to in two steps is then given by the element of the square of :
In general, the probability transition of going from any state to another state in a finite Markov chain given by the matrix in k steps is given by .
An initial probability distribution of states, specifying where the system might be initially and with what probabilities, is given as a row vector.
A stationary probability vector is defined as a distribution, written as a row vector, that does not change under application of the transition matrix; that is, it is defined as a probability distribution on the set which is also a row eigenvector of the probability matrix, associated with eigenvalue 1:
The right spectral radius of every right stochastic matrix is at most 1 by Gershgorin circle theorem. Additionally, every right stochastic matrix has an "obvious" column eigenvector associated to the eigenvalue 1: the vector , whose coordinates are all equal to 1 (just observe that multiplying a row of times equals the sum of the entries of the row and, hence, it equals 1). As left and right eigenvalues of a square matrix are the same, every stochastic matrix has, at least, a row eigenvector associated to the eigenvalue 1 and the largest absolute value of all its eigenvalues is also 1. Finally, the Brouwer Fixed Point Theorem (applied to the compact convex set of all probability distributions of the finite set ) implies that there is some left eigenvector which is also a stationary probability vector.
On the other hand, the Perron-Frobenius theorem also ensures that every irreducible stochastic matrix has such a stationary vector, and that the largest absolute value of an eigenvalue is always 1. However, this theorem cannot be applied directly to such matrices because they need not be irreducible.
In general, there may be several such vectors. However, for a matrix with strictly positive entries (or, more generally, for an irreducible aperiodic stochastic matrix), this vector is unique and can be computed by observing that for any we have the following limit,
where is the element of the row vector . Among other things, this says that the long-term probability of being in a state is independent of the initial state . That both of these computations give the same stationary vector is a form of an ergodic theorem, which is generally true in a wide variety of dissipative dynamical systems: the system evolves, over time, to a stationary state.
Intuitively, a stochastic matrix represents a Markov chain; the application of the stochastic matrix to a probability distribution redistributes the probability mass of the original distribution while preserving its total mass. If this process is applied repeatedly, the distribution converges to a stationary distribution for the Markov chain.:55-59
Suppose there are a timer and a row of five adjacent boxes, with a cat in the first box and a mouse in the fifth box at time zero. The cat and the mouse both jump to a random adjacent box when the timer advances. E.g. if the cat is in the second box and the mouse in the fourth one, the probability is one fourth that the cat will be in the first box and the mouse in the fifth after the timer advances. If the cat is in the first box and the mouse in the fifth one, the probability is one that the cat will be in box two and the mouse will be in box four after the timer advances. The cat eats the mouse if both end up in the same box, at which time the game ends. The random variable K gives the number of time steps the mouse stays in the game.
The Markov chain that represents this game contains the following five states specified by the combination of positions (cat,mouse). Note that while a naive enumeration of states would list 25 states, many are impossible either because the mouse can never have a lower index than the cat (as that would mean the mouse occupied the cat's box and survived to move past it), or because the sum of the two indices will always have even parity. In addition, the 3 possible states that lead to the mouse's death are combined into one:
We use a stochastic matrix, (below), to represent the transition probabilities of this system (rows and columns in this matrix are indexed by the possible states listed above, with the pre-transition state as the row and post-transition state as the column).:1–8 For instance, starting from state 1 - 1st row - it is impossible for the system to stay in this state, so ; the system also cannot transition to state 2 - because the cat would have stayed in the same box - so , and by a similar argument for the mouse, . Transitions to states 3 or 5 are allowed, and thus .
No matter what the initial state, the cat will eventually catch the mouse (with probability 1) and a stationary state π = (0,0,0,0,1) is approached as a limit.:55-59 To compute the long-term average or expected value of a stochastic variable Y, for each state Sj and time tk there is a contribution of Yj,k·P(S=Sj,t=tk). Survival can be treated as a binary variable with Y=1 for a surviving state and Y=0 for the terminated state. The states with Y=0 do not contribute to the long-term average.
As State 5 is an absorbing state, the distribution of time to absorption is discrete phase-type distributed. Suppose the system starts in state 2, represented by the vector . The states where the mouse has perished don't contribute to the survival average so state five can be ignored. The initial state and transition matrix can be reduced to,
where is the identity matrix, and represents a column matrix of all ones that acts as a sum over states.
Since each state is occupied for one step of time the expected time of the mouse's survival is just the sum of the probability of occupation over all surviving states and steps in time,
Higher order moments are given by