Exercise 6 (4 points): **Create a function in a file that begins with function q-markov (P, x0) format [n,-]-size (P); q

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Exercise 6 (4 points): **Create a function in a file that begins with function q-markov (P, x0) format [n,-]-size (P); q

Post by answerhappygod »

Exercise 6 4 Points Create A Function In A File That Begins With Function Q Markov P X0 Format N Size P Q 1
Exercise 6 4 Points Create A Function In A File That Begins With Function Q Markov P X0 Format N Size P Q 1 (93.96 KiB) Viewed 41 times
Exercise 6 (4 points): **Create a function in a file that begins with function q-markov (P, x0) format [n,-]-size (P); q=11; The input P is an n x n matrix and the input xo is the initial state vector of the size n x 1. First, set a conditional statement to check if the given matrix P, which will have positive entries, is stochastic, that is, left-stochastic. **If P is not left-stochastic, the display a message disp('P is not a stochastic matrix') and the empty output for q will stay. **If P is left-stochastic (then it will be regular stochastic), display a message disp('P is a stochastic matrix') and, then, output the unique steady-state vector q, which is the probability vector that forms a basis for the Null space of the matrix (P-eye (n)). Employ here a MATLAB command null, 'r') to output a basis for the Null space and, then, scale the vector in the basis to get the required probability vector q. Display q with a message: disp('the steady-state vector is') q **Next, initialize k=0; and verify that the Markov chain converges to q by calculating consecutive iterations X₁ = P = x0, X₂ = P * X₁, X3 = P * X2, **To make the code simple, you can set up a "while" loop and assign each consecutive iteration to x0 again. The loop will run while the condition below holds: any (closetozeroroundoff (x0-q, 7)) Count the number of iterations k that is required to archive the required accuracy and display k in your code with a message: fprintf('number of iterations to archive required accuracy is i\n',k) Note: if x0=q, then k=0. This is the end of your function markov. **Print the function markov and closetozeroroundoff in your Live Script. **Run the function q-markov (P, x0); on the sets of variables as indicated below: %(a) P=[.6 .3;.5 .7], x0=[.4;.6] q=markov (P, x0); % (b) P=[.5 .3;.5.7],x0=[.5;.5] q=markov (P, x0); % (c) Difficulty: Easy P=[.9.2;.1.8], x0=[.11;.89] q=markov (P, x0); % (d) P=[.9.2;.1.8], x0=[.90;.10] q=markov (P, xe); %(e) P=[.90 .01 .09; .01 .90 .01;.09.09 .90], x0=[.5; 3; .2] q=markov (P, xe); 276) % (f) P=magic (5); P=P./sum (P), x0=randi (10,5,1); x0=x0./sum(x0) q=markov (P, x0); %(8) xe=q q=markov (P, x0); Note: in choice (g), the input matrix P is same as in (f) and the input vector x0 is the output q from the choice (f).
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply