Python
Markov chains, named after Andrey Markov, a stochastic model that depicts a sequence of possible events where predictions or probabilities for the next state are based solely on its previous event state, not the states before. In simple words, the probability that n+1th steps will be x depends only on the nth steps not the complete sequence of steps that came before n. This property is known as Markov Property or Memorylessness.
Assumptions for Markov Chain :
- The statistical system contains a finite number of states.
- The states are mutually exclusive and collectively exhaustive.
- The transition probability from one state to another state is constant over time.
/*
Developed by: Aishree Ramesh
Registration number: 212220230003
*/
import numpy as np
P0=[0.3,0.2,0.5]
P=[[0,2/3,1/3],[1/2,0,1/2],[1/2,1/2,0]]
n=10
for i in range(1,n+1):
P0=np.multiply(P0,P)
print("The %d -step probability distribution is "%i)
print(P0)
Thus, the program to calculate n-th step probability distribution matrix of the three state Markov chain is implemented.