Stochastic systems For this assessment I ask you to implement Markov chains and to answer 6 questions relating to those. In order to successfully complete this assessment you will have to write a Java...

1 answer below »
Please program my asssignment


Stochastic systems For this assessment I ask you to implement Markov chains and to answer 6 questions relating to those. In order to successfully complete this assessment you will have to write a Java code to formulate Markov chains. For the assessment, I give you two files. Markov.java and Stochastic.java. The latter class contains the main method, in fact it only contains the main method from which it calls a number of methods in Markov.java. It also contains comments which formulate the questions you need to answer in the form of computer code. You need to read Stochastic.java in detail to understand how to implement the relevant methods. It also contains the questions that you need to answer. Altogether, there are 6 questions you need to answer by writing code. I reproduce only the first one here: //Q1 //Assume a square 3x3 grid on which a turtle performs a random walk in discrete time. //The turtle can walk east, west, south, north. //Translate the grid into a Markov chain. //Assume that the desired steady state probabilities of all states are equal. // Return as A1 the transition probability that the turtle walks from state s1 to state s2 //You must use the method we discussed in the lectures. I do not accept other answers (even if correct). //numStates .... number of states of the Markov state. //s1, s2 ... the states of the Markov chain. int numStates =9; int s1 =1; int s2 = 2; double A1 = Markov.getTransProb(s1,s2,numStates); Here, you are asked to implement the method getTransProb which should return as a single number the transition probability from state s1 to state s2. Note the directionality here. At the moment the parameters are set such that A1 would be the transition probability from state 1 to state 2 for a Markov chain of size 9. Yet, during marking these numbers will change. You must take this into account when coding getTransProb. You can edit Stochastic.java but bear in mind that all changes you make to it will be lost. During marking, I will replace it with a different version. I therefore recommend that you only edit the numerical values of the parameters, not the rest of the code. Your solution should be programmed in Markov.java only. In fact, you do not even need to submit Stochastic.java. You can also add other class files for as long as they are called from within Markov.java and the program compiles as specified below. The version of Markov.java I give you is only the shell of a class which compiles, but actually does not do anything useful. Your task is to change that.
Answered Same DayNov 03, 2021

Answer To: Stochastic systems For this assessment I ask you to implement Markov chains and to answer 6...

Abr Writing answered on Nov 06 2021
135 Votes
import java.lang.Math;
import java.util.*;
import java.io.PrintWriter;
class Markov {
public static void checkIn(String name, String login, double[] sol1, boolean[] sol2) {
System.out.println(
"****************************************************** ");
System.out.println(" ");
System.out.println(" ");
System.out.println("NAME: " + name + " " + login);
//###########
//Write feedback sheet
//##################
try {
PrintWriter writer = new PrintWriter("/home/cur/dfc/feedback" + ".mark", "UTF-8");
String domi = new String("Dominique Chu");
if (name.equals(domi)) {
name = "replacemexxx";
}
writer.println("************************************");
writer.println("************************************");
writer.println("Feedback for CO528 Assessment 1: Genetic Algorithms for " + name + " (" + login + ")");
writer.println("************************************");
writer.println("************************************");
} catch (Exception e) {
System.out.println(e);
}
}
//##################################
public static double getTransProb(int i, int j, int k) {
double g;
double[][] trans;
if (k == 4) {
trans = new double[][] {
{0.2, 0.4, 0.4, 0},
{0.4, 0.2, 0, 0.4},
{0.4, 0, 0.2, 0.4},
{0, 0.4, 0.4, 0.2}
};
g = trans[i-1][j-1];
} else {
trans = new double[][] {
{0.2, 0.2, 0.2, 0.2, 0, 0, 0.2, 0, 0},
{0.2, 0.2, 0.2, 0, 0.2, 0, 0, 0.2, 0},
{0.2, 0.2, 0.2, 0, 0, 0.2, 0, 0, 0.2},
{0.2, 0, 0, 1/4, 0.2, 0.2, 0.2, 0, 0},
{0, 0.2, 0, 0.2, 0.2, 0.2, 0, 0.2, 0},
{0, 0, 0.2, 0.2, 0.2, 0.2, 0, 0, 0.2},
{0.2, 0, 0, 0.2, 0, 0, 0.2, 0.2, 0.2},
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here