Question: In this assignment I would like you to implement a certain computational task using a programming language of your choice. For everyone in INSY 3010
In this assignment I would like you to implement a certain computational task using a programming language of your choice. For everyone in INSY 3010 I would strongly suggest that you use Python. The following instructions are written with Python in mind. If you are not taking, or have never taken INSY 3010, youare free to use any programming language you choose and feel free to talk to me about your situation andoptions. Assignment overview. Our goal is to perform an analysis of long-term (or steady-state) performance ofa Markov Chain. Suppose you are given a transition matrixP. Your task is toestimatethe long-runproportions by observation. Of cause, you can achieve the same result using analytical methods. The purposehere is to illustrate the principle, so that you can then apply it to more complex systems, where analyticalmethods are intractable.The direct approach to obtain long-run performance profile is to perform a simulation, i.e., trace the transi-tions of the Markov chain for a certain number of iterations, until the long-run behavior has been established,counting the proportion of time that the system spends in each state. According to the theoretical result, if this simulation is performed for a long enough time, these proportions will converge to the long-run probabilities that you can find by solving the system of equations as discussed in class. In your assignment youare asked to first, perform a simulation estimating these probabilities, and then analyze the number of transitions that is required for you to achieve a reasonable accuracy. You can estimate the long-run proportions bytracking the state of the system over a long period of time and counting the number of times that the systementers each state.
Directions:
As the underlying model consider Bonus-Malus insurance policy described in class and in your book(example 4.7). Each of you should use their own, individual value of the Poisson parameter.To obtain your, follow the linkhttp://www.wolframalpha.com/input/?i=random+number+between+0.1+and+2.0 using the value in the Result filed .
Define transition matrixP. For example, in Python a33matrix can be defined by: p = [ [ . 4 , . 4 , . 2 ] , [ . 0 , . 5 , . 5 ] , [ . 0 , . 4 , . 6 ] ] Here the first row is(0.4,0.4,0.2), second row is(0,0.5,0.5), etc. In your case, you will need todefine a44matrix. To obtain the specific values for matrix elements, you can either precomputethe transition probabilities according to the Poisson distribution or do it in Python according to thePoisson formula (the latter is the preferred method), see example 4.7 in the book and class discussionfor details. Note that in Pythonlambdais a reserved word, so you will need to use a different namefor the corresponding variable.
Define an array of state counters (I will call itscnt); the number of simulation steps that you will use(I will call itnsteps); and the current state (state). Originally set1
s c n t = [ 0 , 0 , 0 , 0 ]
n s t e p s = 1 0 0
s t a t e = 0
The array will be used to count the amount of time that the systems spends in each state, if observedfornstepsiterations. Variablestatekeeps track of the current state.
Now, perform transitionsnstepstimes according to the transition matrix, recording the progression,i.e., repeat the following nsteps times.
increment the state counter that corresponds to the current state, i.e., record the current location
perform a transition. The next state is determined by the current state (state) and the corre-sponding row of the transition matrix. There are different ways to do that, one of which is to usea uniform random variable.
draw a realization of a uniform random variable (functionu = random.random()) in Python
for the row of the transition matrix that corresponds to the current state, add the transitionprobabilities one by one from left to right until the sum exceeds the value ofu. The firsttime when that happens determines the next state
Compute the long run proportions by dividing eachscntbynsteps.
Analyze how the values you obtain change with the value ofnsteps. Identify the value ofnstepsthatis enough to determine the long-run proportions with at least two digits of accuracy.
Submission instructions. Submit your code and a brief (not more than one page) report on Canvas. In thereport clearly identify the value of lambda that you used, the long-run proportions that you obtained and theconclusions that you have made based on varying the value of the number of steps. The report should be in.pdf, .doc or .docx format. If you are using Python submit your .py file, otherwise, submit all of the filesrequired to recreate your experiments.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
