Question: Math oreinted C++ question: I need to write a program that will approximate the steady state distribution of a finite state Markov Chain using a

Math oreinted C++ question:

I need to write a program that will approximate the steady state distribution of a finite state Markov Chain using a Monte Carlo method.

The Markov Chain behaves in the following way: A particle begins in one of n states (labeled 0 to n 1), with its initial position being selected uniformly at random. On each step, the particle changes position to one of the n states according to the distribution specified in the row whose index is the particles current position (entry Pij represents the probability of moving from position i to position j on the next step when the particle is in position i).

For example, if we were considering a Markov chain with three states and the following matrix of transition probabilities:

.5 0 .5

.2 .2 .6

.1 .4 .5

If the particle were in position 0, on its next move, it would move to position 0 with 0.5 probability, to position 1 with 0.0 probability, and to position 2 with 0.5 probability. If the particle were in position 1, on its next move, it would move to position 0 with 0.2 probability, to position 1 with 0.2 probability, and to position 2 with 0.6 probability. If the particle were in position 2, on its next move, it would move to position 0 with 0.1 probability, to position 1 with 0.4 probability, and to position 2 with 0.5 probability.

To approximate the steady state distribution of the particle, perform the following Monte Carlo simulation, with each of the N trials carried out according to the following procedure:

(a) Start the particle in one of the n positions, selected uniformly at random.

(b) Move the particle according to the transition probabilities for K total steps.

(c) Record the final position of the particle in an appropriate container of counts of final positions.

The program should take two command line arguments: an integer N for the number of simulations to perform, and an integer K for the number of steps per simulation. The transition probabilities will appear in a file named transitions probabilities.dat. Write the distribution frequencies to a file named steady state frequencies.dat, with the frequencies appearing in order from state 0 to state n 1, with one frequency per line.

The transition probabilites are as follows:

0.0 0.3 0.2 0.5 0.2 0.1 0.3 0.4 0.1 0.4 0.2 0.3 0.0 0.2 0.6 0.2 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!