Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please Help out with this in Java and ensure it runs without any errors in VSCODE MarkovChain.java This class represents a Markov hain to produce
Please Help out with this in Java and ensure it runs without any errors in VSCODE
MarkovChain.java This class represents a Markov hain to produce a matrix of predicted future states using a state vector and a transition matrix. The class must have these private instance variables: - private Vector stateVector; - private Matrix transitionMatrix; The class must have the following public methods: - public Markovhain (Vector sVector, Matrix tMatrix): constructor - Initialize the instance variables with the given parameters - public boolean isValid () - Check if the instance variables are valid for a Markov chain problem and return a Boolean to indicate its validity (true if valid, false if invalid): Assignment 1 To be valid, the transition matrix must be a square (equal number of rows and columns) and that number must also match the number of columns in the state vector. Further, the sum of values in the state vector must equal 1.0 ("see note below) and the sum of values in each row of the transition matrix must equal 1.0 (*see note below) - public Matrix computeProbabilityMatrix (int numSteps) - First, call isValid() to see if this is a valid Markov chain. If not, return null immediately. Compute the probability matrix of this Markov chain after the given numSteps by multiplying the transition matrix by itself numSteps-1 times and multiplying the state vector by the resulting matrix. Note that you must multiply the state vector by the matrix and not the other way around. Return the resulting vector (note that it will technically be a Matrix object, not a Vector object, but it will be a 1-dimensional matrix with the same dimensions as the state vector). *Note: due to possible roundoff errors, checking if the sum is equal to 1.0 should not be done using == but rather checking if the value is very close to 1.0. For simplicity, you can check if the sum value is between 0.99 and 1.01Step 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