Question: Please help solve this coding question. Please show the script and the result. Thank you 2 Markov Chairn (50 points) l1 Pik Markov chain transition
2 Markov Chairn (50 points) l1 Pik Markov chain transition matrix P, and probability distribution on the states p 1. 0s Pli,j] s1: probability to go from state i to statej 2. Transition rule: ewPT pold 3. normalization : all (sum (Paris-|)-= 1), psum ()-= 1 Write a Python script named markov chain.py that works with 5 states, and: Constructs a random matrix, and normalizes each row so that it is a transition matrix Starts from a random (normalized) probability distribution p and take 50 steps to obtain p 50. Computes the stationary distribution: the eigenvector of P.T with eigenvalue 1 (numerically the eigenvalue closest to 1) to obtain p stationary (remember to normalize the eigenvector). Check if p 50 and p_stationary are equal to tolerance le-5. The following functions may be useful: np.random.rand, dot0, np.linalg.eig, etc. 2 Markov Chairn (50 points) l1 Pik Markov chain transition matrix P, and probability distribution on the states p 1. 0s Pli,j] s1: probability to go from state i to statej 2. Transition rule: ewPT pold 3. normalization : all (sum (Paris-|)-= 1), psum ()-= 1 Write a Python script named markov chain.py that works with 5 states, and: Constructs a random matrix, and normalizes each row so that it is a transition matrix Starts from a random (normalized) probability distribution p and take 50 steps to obtain p 50. Computes the stationary distribution: the eigenvector of P.T with eigenvalue 1 (numerically the eigenvalue closest to 1) to obtain p stationary (remember to normalize the eigenvector). Check if p 50 and p_stationary are equal to tolerance le-5. The following functions may be useful: np.random.rand, dot0, np.linalg.eig, etc
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
