sequence of states. ansition matrix as follows: 1 = N - 1|qt = 0) =pVec[0] =n-1|qt :n) = pVec[n] for = n+1|qt = n) = 1-pVec[n] = 0 qt N-1) = 1 - pVec[N rocess where the system either hops one fferent locations. When the system reach ially, the Markov chain is moving on a hat every time t an observation Ot is ma surement is only accurate to within Ms be measured to be in one of the states r If n-M < 0, or n + M > N-1, th

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please do Question 1 and 2 in Python, and please show your code

This is about hidden markov models

1. Write a function Amx_fn that will generate a N by N state transition matrix A as follows:
The function has one input called pVec that is a length N numpy array containing probability values
between 0 and 1. For testing purposes, you may let pVec be the vector with all entries 1/2.
The Markov chain has N states, which we label as 0,...,N-1. (These are the states So,... SN-1)
Let q₁,...qr be a sequence of states.
Define the state transition matrix as follows:
AO,N-1 = P(qt+1 = N1|qt = 0) =pVec[0]
Ann-1 = P(qt+1 = n − 1|qt
= n) pVec[n] for 1 ≤ n ≤N-1
Ann+1 = P(qt+1 = n + 1|qt = n) = 1-pVec[n] for 0≤n≤N-2
AN-1,0 = P(qt+1 = 0 lqt = N − 1) = 1 - pVec[N - 1]
This describes a process where the system either hops one state to the left or right with different
probabilities at different locations. When the system reaches state 0 or N-1, it can hop around to the
other end. (Essentially, the Markov chain is moving on a circle)
We will suppose that every time t an observation Ot is made to determine the state of the Markov chain.
However, the measurement is only accurate to within M steps. For example, if the state is actually n,
then the state will be measured to be in one of the states n M, n-M + 1, ... n + M − 1, n + M with
equal probability. Ifn-M < 0, or n + M > N− 1, then the probabilities will wrap. The
mathematical way to specify this is:
P(0₁ = mod(n + m,N)|qt = n) =
for -M≤ m ≤ M.
1
2M+1
2. Write a function Bmx_fn that has two inputs, N and M and produces as output a matrix Bmx such that
Bmx[j, k] = P(0t = k lqt = j). Note that Bmx[j, k] = b; (k) according to the notation in the video
Transcribed Image Text:1. Write a function Amx_fn that will generate a N by N state transition matrix A as follows: The function has one input called pVec that is a length N numpy array containing probability values between 0 and 1. For testing purposes, you may let pVec be the vector with all entries 1/2. The Markov chain has N states, which we label as 0,...,N-1. (These are the states So,... SN-1) Let q₁,...qr be a sequence of states. Define the state transition matrix as follows: AO,N-1 = P(qt+1 = N1|qt = 0) =pVec[0] Ann-1 = P(qt+1 = n − 1|qt = n) pVec[n] for 1 ≤ n ≤N-1 Ann+1 = P(qt+1 = n + 1|qt = n) = 1-pVec[n] for 0≤n≤N-2 AN-1,0 = P(qt+1 = 0 lqt = N − 1) = 1 - pVec[N - 1] This describes a process where the system either hops one state to the left or right with different probabilities at different locations. When the system reaches state 0 or N-1, it can hop around to the other end. (Essentially, the Markov chain is moving on a circle) We will suppose that every time t an observation Ot is made to determine the state of the Markov chain. However, the measurement is only accurate to within M steps. For example, if the state is actually n, then the state will be measured to be in one of the states n M, n-M + 1, ... n + M − 1, n + M with equal probability. Ifn-M < 0, or n + M > N− 1, then the probabilities will wrap. The mathematical way to specify this is: P(0₁ = mod(n + m,N)|qt = n) = for -M≤ m ≤ M. 1 2M+1 2. Write a function Bmx_fn that has two inputs, N and M and produces as output a matrix Bmx such that Bmx[j, k] = P(0t = k lqt = j). Note that Bmx[j, k] = b; (k) according to the notation in the video
Expert Solution
Step 1: Step

Python function named generate_transition_matrix that follows the described process to create a state transition matrix for a given probability vector pVec:

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Single source shortest path
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education