Science Courses / Course

Markov Chain | Formula, Application & Examples

Christina Harvey, Shaun Ault
  • Author
    Christina Harvey

    Christina graduated with a Master's in biology from the University of Louisiana at Lafayette. She is a current PhD student in biology at Wake Forest University, and has been teaching undergraduate students biology for the last three years.

  • Instructor
    Shaun Ault

    Shaun is currently an Assistant Professor of Mathematics at Valdosta State University as well as an independent private tutor.

Learn the definition of the Markov chain, understand the Markov chain formula, and discover the use of Markov chain applications through examples.
Frequently Asked Questions

How do you define a Markov chain?

A Markov chain is a modeling tool used to predict a system's state in the future. In a Markov chain, the state of a system is dependent on its previous state. However, a state is not influenced by those prior to the preceding state.

What is Markov chain used for?

Markov chains are modeling tools. They are used to predict the state of a system at a given number of steps in the future given a set of known probabilities.

Theresa designs the monthly menu's appearance for a school cafeteria. She notices that there are trends between a day's main course and the main course of the previous day. For instance, chicken nuggets are more likely to be followed by meatloaf, but spaghetti never comes after fish sticks. Usually, Theresa must wait for the schedule to arrive from the caterer before she can begin the month's menu design. However, after seeing that there are trends between lunch options, Theresa wonders if she could create an algorithm to predict future monthly menus.

An error occurred trying to load this video.

Try refreshing the page, or contact customer support.

Your next lesson will play in 10 seconds
  • 0:04 Definition of a Markov Chain
  • 1:49 The Transition Matrix
  • 3:03 State Vectors
  • 3:56 Main Formula
  • 4:36 Long-Term Predictions
  • 5:17 Lesson Summary

Markov chains can be classified in numerous ways. Two common categories for classifying Markov chains include:

  • Discrete-time Markov chains (DTMCs)
  • Continuous-time Markov chains (CTMCs)

Markov chains generate transition matrices. These matrices have the same number of rows and columns which represent the number of states within a system. The values represent the probability of transitioning from a given row state to a column state. For instance, the rows in the following matrix represent the starting states of chicken nuggets, meatloaf, spaghetti, and fish sticks from top to bottom and the transitioned states of the same order from left to right:

{eq}P=\begin{bmatrix} 0 & 0.6 & 0.4 & 0\\ 0.5 & 0 & 0.5 & 0\\ 0 & 0 & 0 & 1 \\ 1 & 0 & 0 & 0 \end{bmatrix} {/eq}

The use of a Markov Chain is beneficial to multiple fields of study. For instance, Markov chains have important applications in:

  • Science
  • Information Theory
  • Queueing Theory
  • Statistics
  • Sports and Music

Below, these examples are explained in more detail to illustrate how Markov chains are interdisciplinary modeling tools.

Markov Chain in Science

Markov chains have a particularly important role in the physical sciences. In biology, Markov chains are often used to depict life cycles within an ecosystem. For instance, at any given state, an animal has the probability of aging to another year or dying. By understanding these probabilities, biologists can predict trends in population fluctuations over time.

In chemistry, Markov chains can be used to predict the state of a reaction at a particular step. CTMC are especially helpful in chemistry fields, as the amount of time reactants remain in a given state may not always be consistent. In physics, Markov chains are used to predict the series of events within a system in accordance with the laws of thermodynamics.

Markov Chain in Information Theory

Information theory is interested in how messages are transmitted between parties. Shannon Claude found that patterns in language often follow Markov chains, where a letter's likelihood of appearance is dependent on the letter that comes before it. Using a simple Markov chain and random letters, Claude was able to produce strings of letters that more closely resembled English words and phrases.

There are several common Markov chain examples that are utilized to depict how these models work. Two of the most frequently used examples are weather predictions and board games. Below, these examples are explored in more detail to illustrate their application.

A Markov chain is a modeling tool that is used to predict the state (or current status or condition) of a system given a starting state. In a Markov chain, the outcome of a state depends on the state before it. However, states are not dependent on states earlier than the immediately preceding state. The probability of a state transitioning into another state is derived from previous knowledge and can be used to generate transition matrices. In a transition matrix, the rows indicate the starting state, and the columns indicate the transitioned state. The value shared by a row in column is the probability of that row's state transitioning into that column's state. The probability of a state at a known number of steps in the future can be determined using the following equation, where {eq}v_{n} {/eq} is the state vector (probabilities of any given state) at n steps in the future, P is the generated probability matrix, and {eq}v_{0} {/eq} is the original state:

{eq}V_{n}=v_{0}P^{n} {/eq}

Markov chains may be discrete-time Markov chains (DTMC) when each step is constrained to a specific unit of time. When steps are not constrained to a given unit of time or equal among transitions, Markov chains are considered continuous-time Markov chains (CTMC).

Video Transcript

Definition of Markov Chain

When we study a system that can change over time, we need a way to keep track of those changes. A Markov chain is a particular model for keeping track of systems that change according to given probabilities. As we'll see, a Markov chain may allow one to predict future events, but the predictions become less useful for events farther into the future (much like predictions of the stock market or weather). This lesson requires prior knowledge of matrix arithmetic.

A state is any particular situation that is possible in the system. For example, if we are studying rainy days, then there are two states:

  1. It's raining today.
  2. It's not raining today.

The system could have many more than two states, but we'll stick to two for this small example.

The term Markov chain refers to any system in which there are a certain number of states and given probabilities that the system changes from any state to another state. That's a lot to take in at once, so let's illustrate using our rainy days example. The probabilities for our system might be:

  • If it rains today (R), then there is a 40% chance it will rain tomorrow and 60% chance of no rain.
  • If it doesn't rain today (N), then there is a 20% chance it will rain tomorrow and 80% chance of no rain.

It may help to organize this data in what we call a state diagram. In this diagram appearing here, the left circle represents rain (R), and the right represents no rain (N). The arrows indicate the probability to change state. For example, the arrow from R to N is labeled 0.6 because there is a 60% chance that if it rains today, then it won't rain tomorrow.

Rain example

The Transition Matrix

If a Markov chain consists of k states, the transition matrix is the k by k matrix (a table of numbers) whose entries record the probability of moving from each state to another state (in decimal form rather than percentage). The rows of the matrix correspond to the current state and columns correspond to the next state. For example, the entry at row 1 and column 2 records the probability of moving from state 1 to state 2. (Note, the transition matrix could be defined the other way around, but then the formulas would also be reversed.)

Let's build a transition matrix together. First, we choose an order for our states. Let's say R always comes before N. That means the first row and first column will concern R while the second row and column will concern N. Remember, rows mean ''from'' and columns mean ''to.''

As we can see here, the transition from R to R is 0.4, so we put 0.4 in the upper left of the matrix. The transition from R to N is 0.6 (upper right). N to R is 0.2 (lower left) and N to N is 0.8 (lower right).

On the left, the probabilities are shown in table form. On the right, they are shown as a transition matrix.
Transition table and matrix

State Vectors

At the start of the process, we might know exactly which state the system is in (rain or no rain), but starting with the second state and further, we only know probabilities of the system being in any given state. To keep track of these probabilities, we use a state vector.

A state vector is a vector (i.e., list) that records the probabilities that the system is in any given state at a particular step of the process.

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use Study.com

Become a Study.com member and start learning now.

Become a Member  Back

Resources created by teachers for teachers

Over 30,000 video lessons & teaching resources‐all in one place.
Video lessons
Quizzes & Worksheets
Classroom Integration
Lesson Plans

I would definitely recommend Study.com to my colleagues. It’s like a teacher waved a magic wand and did the work for me. I feel like it’s a lifeline.

Jennifer B.
Teacher
Jennifer B.
Create an account to start this course today
Used by over 30 million students worldwide
Create an account