What Python code will solve the following: The goal of this section is to estimate the probabilities Pij (transition probabilities) associated with finding food from any location (i, j) inside the maze. A rat will be considered successful in finding food if the probability of finding food from a given location exceeds 0.5. 1. Use Equation (1) to write down equations for each probability Pij for i = 1, 2, · · · , 6, j = 1, 2, 3, · · · , 5. Equation 1 is : Pij = 1/4Pi-1j + 1/4 Pi+1j +1/4 Pij-1 + 1/4Pij+1 2. Notice that your equations constitutes a system of linear equations with 30 equations and 30 unknowns, with the unknowns as the transition probabilities. Identify the coefficient matrix for the system of equations and write your system in the form Ap = b, where b is some constant vector and p the vector of transition probabilities, ordered from the upper left hand corner of the maze to the lower right hand corner. The goal is to solve the system for p. 2 3. How would you characterize the coefficient matrix? is it full, sparse, symmetric. 4. Solve the system of equations for the transition probabilities p using Gaussian Elimination. Determine the relative backward error and condition number of the system matrix and use that to estimate the relative forward error. Use the infinity norm to calculate the error and condition number. Will you consider the system matrix to be ill-conditioned? 5. Determine the transition probabilities p by solving the system of equations Ap = b using the Jacobi iterative method and compare with the solution from Gaussian elimination. In particular, how many iterations of Jacobi method will it take to get within 10−3 of the Gaussian elimination solution? Use the infinity norm to calculate the error. 6. From your transition probabilities determine the number of starting positions from which the rat can be expected to find food given that it makes random decisions.
What Python code will solve the following:
The goal of this section is to estimate the probabilities Pij (transition probabilities) associated with finding food from any location (i, j) inside the maze. A rat will be considered successful in finding food if the probability of finding food from a given location exceeds 0.5. 1. Use Equation (1) to write down equations for each probability Pij for i = 1, 2, · · · , 6, j = 1, 2, 3, · · · , 5. Equation 1 is : Pij = 1/4Pi-1j + 1/4 Pi+1j +1/4 Pij-1 + 1/4Pij+1 2. Notice that your equations constitutes a system of linear equations with 30 equations and 30 unknowns, with the unknowns as the transition probabilities. Identify the coefficient matrix for the system of equations and write your system in the form Ap = b, where b is some constant vector and p the vector of transition probabilities, ordered from the upper left hand corner of the maze to the lower right hand corner. The goal is to solve the system for p. 2 3. How would you characterize the coefficient matrix? is it full, sparse, symmetric. 4. Solve the system of equations for the transition probabilities p using Gaussian Elimination. Determine the relative backward error and condition number of the system matrix and use that to estimate the relative forward error. Use the infinity norm to calculate the error and condition number. Will you consider the system matrix to be ill-conditioned? 5. Determine the transition probabilities p by solving the system of equations Ap = b using the Jacobi iterative method and compare with the solution from Gaussian elimination. In particular, how many iterations of Jacobi method will it take to get within 10−3 of the Gaussian elimination solution? Use the infinity norm to calculate the error. 6. From your transition probabilities determine the number of starting positions from which the rat can be expected to find food given that it makes random decisions.
Step by step
Solved in 2 steps