What is a Markov chain?
by Stephen M. Walker II, CoFounder / CEO
What is a Markov chain?
A Markov chain is a stochastic model that describes a sequence of possible events, where the probability of each event depends only on the state attained in the previous event. This characteristic is often referred to as "memorylessness" or the Markov property, meaning the future state of the process depends only on the current state and not on how the process arrived at its current state.
Markov chains can be categorized into two types based on the nature of time: discretetime Markov chains (DTMCs) and continuoustime Markov chains (CTMCs). In a DTMC, the changes in states are considered at discrete time steps, while in a CTMC, the state changes can occur at any time.
The state space of a Markov chain, which is the set of all possible states, can be anything: letters, numbers, weather conditions, baseball scores, or stock performances. The transition from one state to another is governed by a transition matrix, which represents the probability distribution of the state's transitions. The sum of probabilities in each row of the matrix will be one, implying that this is a stochastic matrix.
Markov chains have a wide range of applications in various fields. They are used in statistical models of realworld processes, such as studying cruise control systems in motor vehicles, queues or lines of customers arriving at an airport, currency exchange rates, and animal population dynamics. They are also the basis for general stochastic simulation methods known as Markov chain Monte Carlo, which are used for simulating sampling from complex probability distributions. In data science, a common application of Markov chains is text prediction, which is commonly used in the tech industry by companies like Google, LinkedIn, and Instagram.
The concept of Markov chains is attributed to the Russian mathematician Andrey Markov, who pioneered this field of probability theory. Markov chains were first introduced in his 1906 paper, which studied the stochastic processes that involve sequences of random events or states that are not independent of each other. His work laid the foundation for a new branch of probability theory that focuses on the properties of systems that undergo transitions from one state to another in a chainlike fashion.
Key features of Markov chains

Discrete and Continuous Time — Markov chains can be defined in discrete or continuous time, with the latter being called a continuoustime Markov chain (CTMC).

Finite or Countably Infinite State Space — The state space, or set of all possible states, can be finite or countably infinite.

Transition Probability Matrix — The transition probability matrix, denoted as "P," represents the probability distribution of state transitions. The sum of probabilities in each row of the matrix is one, implying that this is a stochastic matrix.

Markov Property — A Markov chain must be "memoryless," meaning that the probability of future actions is not dependent on the steps that led up to the present.
Markov chains are widely used in various fields, including game theory, queueing theory, genetics, and finance. They are particularly useful in statistical and informationtheoretical contexts and have applications in areas such as text prediction, which is a common application in natural language processing (NLP).
What is the order of a Markov chain?
The order of a Markov chain refers to the number of preceding states that influence the probability of a given state in a stochastic process. There are three main types of Markov chains:

Firstorder Markov chain — In this type of Markov chain, the probability of a state depends only on the immediately preceding state. The transition probability is represented as
$$P(x_i  x_{i1})$$
. 
Secondorder Markov chain — A secondorder Markov chain takes into account two preceding states, with the transition probability represented as
$$P(x_i  x_{i1}, x_{i2})$$
. 
Variableorder Markov model (VOM) — This model extends the concept of Markov chains by allowing the number of conditioning random variables to vary. It can approximate and generate strings using fewer conditional probabilities compared to higherorder Markov chains.
In practical settings, there is often insufficient data to accurately estimate the order of a Markov chain. However, understanding the order of a Markov chain is crucial for determining the degree to which the generated text will resemble the source text. Higherorder Markov chains can generate more complex and diverse sequences, while firstorder Markov chains tend to produce simpler and more repetitive patterns.
What is a stationary distribution?
A stationary distribution is a special distribution for a Markov chain, such that if the chain starts with its stationary distribution, the marginal distribution of all states at any time will always be the stationary distribution. In other words, the distribution remains the same even after a long time. This concept is crucial in understanding the longterm behavior of Markov chains.
Key points about stationary distributions include:
 They exist when the Markov chain is irreducible and positive recurrent.
 The stationary distribution is unique if it exists.
 Finding a stationary distribution involves solving the system of equations given by the transition matrix.
For example, consider a twostate Markov chain with transition probabilities $$p_{ij}$$. The stationary distribution $$\boldsymbol{\pi}$$ can be found by solving the system of equations $$\pi_j = \sum_{i\in \mathcal S} \pi_i p_{ij}$$, which can be rewritten as $$\boldsymbol{\pi} = \boldsymbol{\pi}\mathsf P$$.
A stationary distribution is a key concept in Markov chain theory, representing the longterm behavior of the chain. It is unique and can be found by solving the appropriate system of equations.
What is a transition matrix?
A transition matrix, also known as a stochastic or probability matrix, is a square (n x n) matrix representing the transition probabilities of a Markov chain. It is a mathematical tool used to model and analyze transitions between different states or conditions. The key components of a transition matrix include:
 Initial State — The row represents the initial state, while the column represents the state it transitions to.
 Transition Probabilities — Each entry in the matrix represents the probability of transitioning from one state to another. The sum of probabilities in each row must equal one.
 Markov Chain — The matrix is used to describe the dynamics of a system in terms of its stability, longterm behavior, and trends. By examining the probabilities of transitioning between different states, we can make predictions about the future behavior of the system and identify any patterns or trends.
Transition matrices are used in various contexts, such as linear algebra, control theory, and Markov chain theory. They allow us to gain a deeper understanding of the system's behavior, make predictions about its future states, and identify any underlying patterns or trends that may exist.
What is the ChapmanKolmogorov equation?
The ChapmanKolmogorov equation (CKE) is a mathematical identity in the field of Markovian stochastic processes that relates the joint probability distributions of different sets of coordinates on a stochastic process. It is named after British mathematician Sydney Chapman and Russian mathematician Andrey Nikolaevich Kolmogorov. The CKE is used in various applications, including Variational Bayesian methods.
The ChapmanKolmogorov equation is particularly useful in understanding the behavior of Markov chains and their applications in various fields, such as probability theory, statistics, and machine learning.
What is the transition matrix of a Markov chain?
The transition matrix of a Markov chain is a square matrix used to describe the transitions of a Markov chain, with each of its entries representing a nonnegative real number representing a probability. It is also known as a stochastic matrix or probability matrix. The transition matrix is usually denoted as P = (pij).
In a Markov chain, the probability of transitioning from state i to state j is given by the (i, j)th element of the transition matrix, represented as pij. The transition matrix is an important tool for analyzing Markov chains, as it allows us to understand the probabilities of moving from one state to another in a dynamic system.
Some properties of the transition matrix include:
 The sum of the elements in each row is 1, as all transition probabilities from a state i to all other states must add up to 1.
 The matrix is a right stochastic matrix, meaning that the product of two right stochastic matrices is also right stochastic.
 The kth power of a right stochastic matrix is also right stochastic, and the probability of transitioning from i to j in k steps is given by the (i, j)th element of the kth power of the matrix.
The transition matrix of a Markov chain is a crucial component for understanding and analyzing the behavior of Markov chains in various applications.
What is the absorption probability of a Markov chain?
The absorption probability of a Markov chain is the probability of eventually reaching an absorbing state, given that the process starts in a particular state. In an absorbing Markov chain, there is at least one absorbing state, and any state can reach this absorbing state.
The absorption probability of a Markov chain is an important concept in probability theory, particularly in the context of absorbing Markov chains. It represents the probability of eventually reaching an absorbing state, given the initial state of the process.