SlideShare a Scribd company logo
Markov Chains | Edureka
WHAT IS A MARKOV CHAIN?
UNDERSTANDING MARKOV CHAINS WITH AN EXAMPLE
MARKOV CHAIN IN PYTHON
MARKOV CHAIN APPLICATIONS
TRANSITION MATRIX & TRANSISTION STATE DIAGRAM
www.edureka.co
WHAT IS A MARKOV CHAIN?
www.edureka.co
A stochastic process containing random variables, transitioning from one state to another
depending on certain assumptions and definite probabilistic rules.
What Is A Markov chain?
Markov Property states that the calculated probability of a random process transitioning to the
next possible state is only dependent on the current state and time and it is independent of the
series of states that preceded it.
Let the random process be, { 𝑋 𝑚 , m=0,1,2 … }
This process is a Markov chain only if,
𝑃 𝑋 𝑚+1 = ȁ𝑗 𝑋 𝑚 = ⅈ, 𝑋 𝑚−1 = ⅈ 𝑚−1, … , 𝑋0 = ⅈ0 = 𝑃 𝑋 𝑚+1 = ȁ𝑗 𝑋 𝑚 = ⅈ
𝑃𝑖𝑗 = 𝑃 𝑋 𝑚+1 = ȁ𝑗 𝑋 𝑚 = ⅈ
www.edureka.co
UNDERSTANDING MARKOV CHAINS
www.edureka.co
A Markov Model is a stochastic model that models random variables in such a manner that the variables
follow the Markov property.
• Keys denote the unique words in the sentence, i.e., 5 keys (one, two, hail, happy, edureka)
• Tokens denote the total number of words, i.e. 8 tokens.
one edureka two edureka hail edureka happy edureka
www.edureka.co
A Markov Model is a stochastic model that models random variables in such a manner that the variables
follow the Markov property.
one
edureka
two
hail
happy
1
4
1
1
1
Keys Frequencies
www.edureka.co
A Markov Model is a stochastic model that models random variables in such a manner that the variables
follow the Markov property.
one
edureka
two
hail
happy
1
4
1
1
1
Weighted distributions:
1. 'edureka' is 50% (4/8)
2. (one, two, hail, happy)
is ≈ 13% (1/8)
www.edureka.co
Start one edureka two edureka hail edureka happy edureka end
one
edureka
two
hail
happy
1
4
1
1
1
start
end
1
1
Keys Frequencies
www.edureka.co
(Start, one)
(one, edureka)
(edureka, two)
(two, edureka)
(edureka, hail)
(hail, edureka)
(edureka, happy)
(happy, edureka)
(edureka, end)
(end, none)
(Start, one)
(one, edureka)
(edureka, two) (edureka, hail) (edureka, happy) (edureka, end)
(two, edureka)
(hail, edureka)
(happy, edureka)
(end, none)
www.edureka.co
(Start, one)
(one, edureka)
(edureka, two) (edureka, hail) (edureka, happy) (edureka, end)
(two, edureka)
(hail, edureka)
(happy, edureka)
(end, none)
Start [one]
One [edureka]
Edureka [two, hail, happy, end]
Two [edureka]
Hail [edureka]
Happy [edureka]
End [none]
www.edureka.co
Start
One
hailtwo
happy
end
edureka
1
1
1
1
1
1/4
1/4
1/4
1/4
Start [one]
One [edureka]
Edureka [two, hail, happy, end]
Two [edureka]
Hail [edureka]
Happy [edureka]
End [none]
www.edureka.co
TRANSITION MATRIX & STATE DAIGRAM
www.edureka.co
In a Markov Process, we use a matrix to represent the transition probabilities from one state to
another. This matrix is called the Transition or probability matrix. It is usually denoted by P.
What Is A Transition Matrix?
𝑝11 𝑝12 𝑝1𝑟
𝑝21 𝑝22 𝑝2𝑟
𝑝21 𝑝22 𝑝2𝑟
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
P =
෍
𝑘=1
𝑟
𝑝𝑖𝑘 = ෍
𝑘=1
𝑟
𝑃 𝑋 𝑚+1 = ȁ𝑘 𝑋 𝑚 = ⅈ
Note, 𝑝ij ≥ 0, and 'i' for all values is,
www.edureka.co
Consider a Markov chain with three states 1, 2, and 3.
Transition Matrix & State Diagram Example
Transition matrix
1/4 0 3/4
P = 1/2 0 1/2
1/4 1/2 1/4
1 2
3
1/4
3/4
1/2
1/2
1/4
1/2
1/4
State Transition Diagram
www.edureka.co
DEMO
www.edureka.co
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
www.edureka.co
To apply Markov Property and create a Markov Model that can generate text simulations by
studying Donald Trump speech data set.
Problem Statement
Apply Markov property
Generate Text Simulations
Donald Trump speeches
www.edureka.co
MARKOV CHAIN APPLICATIONS
www.edureka.co
Markov Chain Applications
Google PageRank Autocomplete
www.edureka.co
Markov Chain Applications
Subreddit simulator Text generator
www.edureka.co
www.edureka.co

More Related Content

PPTX
Markov process
PPTX
Eigenstates of 2D Random Walk with Multiple Absorbing States
PPTX
Complex processes
PPTX
Markov chain
PDF
Introduction To Markov Chains | Markov Chains in Python | Edureka
PDF
Markor chain presentation
PDF
makov chain_basic
 
PDF
Probabilistic Models of Time Series and Sequences
Markov process
Eigenstates of 2D Random Walk with Multiple Absorbing States
Complex processes
Markov chain
Introduction To Markov Chains | Markov Chains in Python | Edureka
Markor chain presentation
makov chain_basic
 
Probabilistic Models of Time Series and Sequences

More from Edureka! (20)

PDF
What to learn during the 21 days Lockdown | Edureka
PDF
Top 10 Dying Programming Languages in 2020 | Edureka
PDF
Top 5 Trending Business Intelligence Tools | Edureka
PDF
Tableau Tutorial for Data Science | Edureka
PDF
Python Programming Tutorial | Edureka
PDF
Top 5 PMP Certifications | Edureka
PDF
Top Maven Interview Questions in 2020 | Edureka
PDF
Linux Mint Tutorial | Edureka
PDF
How to Deploy Java Web App in AWS| Edureka
PDF
Importance of Digital Marketing | Edureka
PDF
RPA in 2020 | Edureka
PDF
Email Notifications in Jenkins | Edureka
PDF
EA Algorithm in Machine Learning | Edureka
PDF
Cognitive AI Tutorial | Edureka
PDF
AWS Cloud Practitioner Tutorial | Edureka
PDF
Blue Prism Top Interview Questions | Edureka
PDF
Big Data on AWS Tutorial | Edureka
PDF
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
PDF
Kubernetes Installation on Ubuntu | Edureka
PDF
Introduction to DevOps | Edureka
What to learn during the 21 days Lockdown | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Tableau Tutorial for Data Science | Edureka
Python Programming Tutorial | Edureka
Top 5 PMP Certifications | Edureka
Top Maven Interview Questions in 2020 | Edureka
Linux Mint Tutorial | Edureka
How to Deploy Java Web App in AWS| Edureka
Importance of Digital Marketing | Edureka
RPA in 2020 | Edureka
Email Notifications in Jenkins | Edureka
EA Algorithm in Machine Learning | Edureka
Cognitive AI Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Blue Prism Top Interview Questions | Edureka
Big Data on AWS Tutorial | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Kubernetes Installation on Ubuntu | Edureka
Introduction to DevOps | Edureka
Ad

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Empathic Computing: Creating Shared Understanding
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
1. Introduction to Computer Programming.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
Encapsulation_ Review paper, used for researhc scholars
Spectral efficient network and resource selection model in 5G networks
Empathic Computing: Creating Shared Understanding
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Mobile App Security Testing_ A Comprehensive Guide.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
1. Introduction to Computer Programming.pptx
Spectroscopy.pptx food analysis technology
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Programs and apps: productivity, graphics, security and other tools
Reach Out and Touch Someone: Haptics and Empathic Computing
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
The Rise and Fall of 3GPP – Time for a Sabbatical?
Digital-Transformation-Roadmap-for-Companies.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Assigned Numbers - 2025 - Bluetooth® Document
Ad

Markov Chains | Edureka

  • 2. WHAT IS A MARKOV CHAIN? UNDERSTANDING MARKOV CHAINS WITH AN EXAMPLE MARKOV CHAIN IN PYTHON MARKOV CHAIN APPLICATIONS TRANSITION MATRIX & TRANSISTION STATE DIAGRAM www.edureka.co
  • 3. WHAT IS A MARKOV CHAIN? www.edureka.co
  • 4. A stochastic process containing random variables, transitioning from one state to another depending on certain assumptions and definite probabilistic rules. What Is A Markov chain? Markov Property states that the calculated probability of a random process transitioning to the next possible state is only dependent on the current state and time and it is independent of the series of states that preceded it. Let the random process be, { 𝑋 𝑚 , m=0,1,2 … } This process is a Markov chain only if, 𝑃 𝑋 𝑚+1 = ȁ𝑗 𝑋 𝑚 = ⅈ, 𝑋 𝑚−1 = ⅈ 𝑚−1, … , 𝑋0 = ⅈ0 = 𝑃 𝑋 𝑚+1 = ȁ𝑗 𝑋 𝑚 = ⅈ 𝑃𝑖𝑗 = 𝑃 𝑋 𝑚+1 = ȁ𝑗 𝑋 𝑚 = ⅈ www.edureka.co
  • 6. A Markov Model is a stochastic model that models random variables in such a manner that the variables follow the Markov property. • Keys denote the unique words in the sentence, i.e., 5 keys (one, two, hail, happy, edureka) • Tokens denote the total number of words, i.e. 8 tokens. one edureka two edureka hail edureka happy edureka www.edureka.co
  • 7. A Markov Model is a stochastic model that models random variables in such a manner that the variables follow the Markov property. one edureka two hail happy 1 4 1 1 1 Keys Frequencies www.edureka.co
  • 8. A Markov Model is a stochastic model that models random variables in such a manner that the variables follow the Markov property. one edureka two hail happy 1 4 1 1 1 Weighted distributions: 1. 'edureka' is 50% (4/8) 2. (one, two, hail, happy) is ≈ 13% (1/8) www.edureka.co
  • 9. Start one edureka two edureka hail edureka happy edureka end one edureka two hail happy 1 4 1 1 1 start end 1 1 Keys Frequencies www.edureka.co
  • 10. (Start, one) (one, edureka) (edureka, two) (two, edureka) (edureka, hail) (hail, edureka) (edureka, happy) (happy, edureka) (edureka, end) (end, none) (Start, one) (one, edureka) (edureka, two) (edureka, hail) (edureka, happy) (edureka, end) (two, edureka) (hail, edureka) (happy, edureka) (end, none) www.edureka.co
  • 11. (Start, one) (one, edureka) (edureka, two) (edureka, hail) (edureka, happy) (edureka, end) (two, edureka) (hail, edureka) (happy, edureka) (end, none) Start [one] One [edureka] Edureka [two, hail, happy, end] Two [edureka] Hail [edureka] Happy [edureka] End [none] www.edureka.co
  • 12. Start One hailtwo happy end edureka 1 1 1 1 1 1/4 1/4 1/4 1/4 Start [one] One [edureka] Edureka [two, hail, happy, end] Two [edureka] Hail [edureka] Happy [edureka] End [none] www.edureka.co
  • 13. TRANSITION MATRIX & STATE DAIGRAM www.edureka.co
  • 14. In a Markov Process, we use a matrix to represent the transition probabilities from one state to another. This matrix is called the Transition or probability matrix. It is usually denoted by P. What Is A Transition Matrix? 𝑝11 𝑝12 𝑝1𝑟 𝑝21 𝑝22 𝑝2𝑟 𝑝21 𝑝22 𝑝2𝑟 . . . . . . . . . . . . . . . . . P = ෍ 𝑘=1 𝑟 𝑝𝑖𝑘 = ෍ 𝑘=1 𝑟 𝑃 𝑋 𝑚+1 = ȁ𝑘 𝑋 𝑚 = ⅈ Note, 𝑝ij ≥ 0, and 'i' for all values is, www.edureka.co
  • 15. Consider a Markov chain with three states 1, 2, and 3. Transition Matrix & State Diagram Example Transition matrix 1/4 0 3/4 P = 1/2 0 1/2 1/4 1/2 1/4 1 2 3 1/4 3/4 1/2 1/2 1/4 1/2 1/4 State Transition Diagram www.edureka.co
  • 17. Copyright © 2017, edureka and/or its affiliates. All rights reserved. www.edureka.co
  • 18. To apply Markov Property and create a Markov Model that can generate text simulations by studying Donald Trump speech data set. Problem Statement Apply Markov property Generate Text Simulations Donald Trump speeches www.edureka.co
  • 20. Markov Chain Applications Google PageRank Autocomplete www.edureka.co
  • 21. Markov Chain Applications Subreddit simulator Text generator www.edureka.co