R Problem Solving
R Problem Solving
Problem Solving
Solving
With
PRESENTED BY
Answer :
Let’s model this Markov Chain using R.
We will start by creating a transition matrix
Code:
Output:
Code:
Output:
Now, to plot the above transition matrix we can use the R package,
“diagram”.The “diagram” package has a function called
“plot at” that can help us plot a state space diagram of the
transition matrix in an easy-to-understand manner.
Code:
Output:
Now, the above Markov Chain can be used to answer some of the future state
questions. Like P(𝑥_2 =1 | 𝑥_1 = 0) = 1
We can similarly calculate for two steps. Let’s calculate the
probability of coming back to the 0 state in the second step.
Code: markov.p^2
Output:
Since the probabilities in the 20th and 21st steps are coming to be
equal, we can say that we have reached the stationary state.
Answer :
Let’s model this Markov Chain using R.
We will start by creating a transition matrix of the zone movement
probabilities.
Code:
Output:
We called the “Markov chain” function
Now, to plot the above transition matrix we can use the R package,
“diagram”.The “diagram” package has a function called
“plotmat” that can help us plot a state space diagram of the
transition matrix in an easy-to-understand manner.
Code:
Output:
Code:
Output: