Skip to main content
deleted 57 characters in body
Source Link
user366312
  • 2.1k
  • 4
  • 22
  • 46

Consider the Markov chain with state space S = {1, 2}, transition matrix

enter image description here

and initial distribution α = (1/2, 1/2).

  1. Simulate 5 steps of the Markov chain (that is, simulate X0, X1, . . . , X5). Repeat the simulation 100 times. Use the results of your simulations to solve the following problems.
  • Estimate P(X1 = 1|X0 = 1). Compare your result with the exact probability.

My solution:

# returns Xn 
func2 <- function(alpha1, mat1, n1) 
{
  xn <- alpha1 %*% matrixpower(mat1, n1+1)
  
  return (xn)
}

alpha <- c(0.5, 0.5)
mat <- matrix(c(0.5, 0.5, 0, 1), nrow=2, ncol=2)
n <- 10


for (variable in 1:100) 
{
   print(func2(alpha, mat, n))
}

 

What is the difference if I run this code once versus 100 times (as is said in the problem-statement)?

How can I have a few questionsfind the conditional probability from here: on?

  1. Is my code correct here?
  2. What is the difference if I run this code once or 100 times (as is said in the problem-statement)?
  3. How can I find the conditional probability from here on?

Consider the Markov chain with state space S = {1, 2}, transition matrix

enter image description here

and initial distribution α = (1/2, 1/2).

  1. Simulate 5 steps of the Markov chain (that is, simulate X0, X1, . . . , X5). Repeat the simulation 100 times. Use the results of your simulations to solve the following problems.
  • Estimate P(X1 = 1|X0 = 1). Compare your result with the exact probability.
# returns Xn 
func2 <- function(alpha1, mat1, n1) 
{
  xn <- alpha1 %*% matrixpower(mat1, n1+1)
  
  return (xn)
}

alpha <- c(0.5, 0.5)
mat <- matrix(c(0.5, 0.5, 0, 1), nrow=2, ncol=2)
n <- 10


for (variable in 1:100) 
{
   print(func2(alpha, mat, n))
}

 

I have a few questions here:

  1. Is my code correct here?
  2. What is the difference if I run this code once or 100 times (as is said in the problem-statement)?
  3. How can I find the conditional probability from here on?

Consider the Markov chain with state space S = {1, 2}, transition matrix

enter image description here

and initial distribution α = (1/2, 1/2).

  1. Simulate 5 steps of the Markov chain (that is, simulate X0, X1, . . . , X5). Repeat the simulation 100 times. Use the results of your simulations to solve the following problems.
  • Estimate P(X1 = 1|X0 = 1). Compare your result with the exact probability.

My solution:

# returns Xn 
func2 <- function(alpha1, mat1, n1) 
{
  xn <- alpha1 %*% matrixpower(mat1, n1+1)
  
  return (xn)
}

alpha <- c(0.5, 0.5)
mat <- matrix(c(0.5, 0.5, 0, 1), nrow=2, ncol=2)
n <- 10


for (variable in 1:100) 
{
   print(func2(alpha, mat, n))
}

What is the difference if I run this code once versus 100 times (as is said in the problem-statement)?

How can I find the conditional probability from here on?

Source Link
user366312
  • 2.1k
  • 4
  • 22
  • 46

Manual simulation of Markov Chain in R

Consider the Markov chain with state space S = {1, 2}, transition matrix

enter image description here

and initial distribution α = (1/2, 1/2).

  1. Simulate 5 steps of the Markov chain (that is, simulate X0, X1, . . . , X5). Repeat the simulation 100 times. Use the results of your simulations to solve the following problems.
  • Estimate P(X1 = 1|X0 = 1). Compare your result with the exact probability.
# returns Xn 
func2 <- function(alpha1, mat1, n1) 
{
  xn <- alpha1 %*% matrixpower(mat1, n1+1)
  
  return (xn)
}

alpha <- c(0.5, 0.5)
mat <- matrix(c(0.5, 0.5, 0, 1), nrow=2, ncol=2)
n <- 10


for (variable in 1:100) 
{
   print(func2(alpha, mat, n))
}

I have a few questions here:

  1. Is my code correct here?
  2. What is the difference if I run this code once or 100 times (as is said in the problem-statement)?
  3. How can I find the conditional probability from here on?