>Consider the Markov chain with state space *S = {1, 2}*, transition matrix
>
>[![enter image description here][1]][1]
>
> and initial distribution *α = (1/2, 1/2)*.
>
> 1. Simulate 5 steps of the Markov chain (that is, simulate *X<sub>0</sub>*, *X<sub>1</sub>*, . . . , *X<sub>5</sub>*). Repeat the simulation 100
times. Use the results of your simulations to solve the following problems.
>
> - Estimate *P(X<sub>1</sub> = 1|X<sub>0</sub> = 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?

  [1]: https://i.sstatic.net/eUeSB.png