MATH152 April 2015
• 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 2(c) • QB 3(a) • QB 3(b) • QB 3(c) • QB 4(a) • QB 4(b) • QB 4(c) • QB 5(a) • QB 5(b) • QB 5(c) • QB 5(d) • QB 6(a) • QB 6(b) • QB 6(c) •
Question A 10
Consider the following lines of MATLAB code:
A = zeros(10, 10);
A(i, i) = 1/2;
A(i+1, i) = 1/2;
A(10, 10) = 1;
Circle the answer below that best describes the resulting matrix :
- (a) an error occurs in the last line above.
- (b) is the transition matrix for a random walk.
- (c) is an upper triangular matrix.
- (d) is a diagonal matrix with diagonal entries 1/2.
- (e) contains the solution of a differential equation system.
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!
Recall the following definitions:
- The transition matrix for a random walk (in the convention used in MATH 152) is a left-stochastic matrix, i.e., a nonnegative real matrix wherein each column sums to 1.
- An upper triangular matrix has for all , i.e., all entries below its diagonal are zero.
- A diagonal matrix has for all , i.e., all its off-diagonal entries are zero.
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.
- If you are stuck on a problem: Read the solution slowly and as soon as you feel you could finish the problem on your own, hide it and work on the problem. Come back later to the solution if you are stuck or if you want to check your work.
- If you want to check your work: Don't only focus on the answer, problems are mostly marked for the work you do, make sure you understand all the steps that were required to complete the problem and see if you made mistakes or forgot some aspects. Your goal is to check that your mental process was correct, not only the result.
Found a typo? Is this solution unclear? Let us know here.
Please rate my easiness! It's quick and helps everyone guide their studies.
We see from the first line
A = zeros(10, 10);
that is initialized as a 10-by-10 matrix of zeroes.
In the first iteration of the loop (when i = 1), we set and the entry below it, , to also. Continuing in this manner for , at the end of the loop we obtain
where the last two entries modified by the loop are and . We finally set , forming the matrix
which is seen to be left-stochastic, and hence (b) the transition matrix for a random walk.