Science:Math Exam Resources/Courses/MATH152/April 2010/Question A 26
• QA 1 • QA 2 • QA 3 • QA 4 • QA 5 • QA 6 • QA 7 • QA 8 • QA 9 • QA 10 • QA 11 • QA 12 • QA 13 • QA 14 • QA 15 • QA 16 • QA 17 • QA 18 • QA 19 • QA 20 • QA 21 • QA 22 • QA 23 • QA 24 • QA 25 • QA 26 • QA 27 • QA 28 • QA 29 • QA 30 • QB 1(a) • QB 1(b) • QB 1(c) • QB 2(a) • QB 2(b) • QB 3(a) • QB 3(b) • QB 3(c) • QB 3(d) • QB 4(a) • QB 4(b) • QB 4(c) • QB 4(d) • QB 4(e) • QB 5(a) • QB 5(b) • QB 6(a) • QB 6(b) • QB 6(c) • QB 6(d) • QB 6(e) •
Question A 26
Suppose P was the transition matrix for a random walk with 12 states that had been entered into MATLAB. What commands would you use to compute the probability that if the system started in state 1, it would be in state 5 after 10 time steps?
Make sure you understand the problem fully: What is the question asking you to do? Are there specific conditions or constraints that you should take note of? How will you know if your answer is correct from your work only? Can you rephrase the question in your own words in a way that makes sense to you?
If you are stuck, check the hint below. Consider it for a while. Does it give you a new idea on how to approach the problem? If so, try it!
If P is the transition matrix and is the initial state then gives the probabilities of being in each state after one transition. What would we do for 10 transitions?
Checking a solution serves two purposes: helping you if, after having used the hint, you still are stuck on the problem; or if you have solved the problem and would like to check your work.
We are told we have a transition matrix that represents the transition probabilities of a 12-state transition matrix. Therefore the matrix will be 12 x 12 which we will assume has been initialized for us as P in Matlab. We are also told that we are initially in state 1. Since the initial state vector, , lists the probability of being in any of the 12 states, we should have
x = [1;0;0;0;0;0;0;0;0;0;0;0];
Now, we are interested in knowing the probability of being in state 5 after 10 time steps (or transitions).
Solution 1: Matrix Powers
Recall that if is the initial state vector with , the transition matrix then returns the vector corresponding to the probability of being in each of the 12 states after one time step. If we apply the transition matrix again then we get how the transition vector from the first time step transitions to the second time step. Notice I can write,
b = P^(10)*x;
Now this returns the whole vector. Since we are interested in the probability of being in the 5th state after 10 time steps, we want to know the 5th entry of . Therefore we type
Notice the lack of the semicolon tells us that the entry of b(5) will be output to the screen for us to see.
Solution 2: For Loops
Recall that if is the initial state vector with , the transition matrix then returns the vector corresponding to the probability of being in each of the 12 states after one time step. If I want to know the transition to the second time step, I just need to perform a single transition on the new transition vector . Therefore, for each new time step I want a transition, I just have to multiply the previous transition vector with the transition matrix P. This type of iterated operation is perfectly suited for a for loop in Matlab. Notice, I want 10 time steps so I would keep applying the transition matrix to the generated transition vectors until I've done that 10 times.
for k = 1:10 x = P*x; end
Notice here that I reinitialize to be the new transition vector so that I can minimize the amount of code I have to write. Once this is done we have the transition vector after 10 time steps. However, we're interested in the probability of being in the 5th state. This is the 5th entry of the vector. Therefore we type,
Notice the lack of semicolon tells us that the entry of x(5) will be output to the screen for us to see.