Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This coding exercise is to perform a tiny simulation given a Markov chain transition matrix. Create a Python function named mc simulation that can simulate
This coding exercise is to perform a tiny simulation given a Markov chain transition matrix. Create a Python
function named mc simulation that can simulate a history sequence of states given any transition matrix. The specific requirements are as follows.
Two inputs: i A: a Markov chain transition matrix; ii t: the number of steps to simulate. You can
use the row indices n of matrix A as the set of states.
IE Probabilistic Operations Research
One output: a list of states H s s s st where si represents the state occurred at time i in
this simulation. You need to randomly pick an arbitrary state from S as the initial state s
Test instance: test your algorithm with inputs S and A being the state set and transition matrix of
Gamblers Ruin class example with p and use t as the number of simulation steps. Run
five times of your function, and check how is the simulated history of each run.
Packages and functions you may need to use click will lead you to the webpages:
numpy.shape
numpy.random.choice The input parameter p of this function allows you to provide a probability
distribution over possible choices
range
list.append
Note: adding comment in each line of code will receive one extra point given that code runs correctly.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started