Clear all symbols from previous evaluations to avoid problems

Clear["Global`*"]

Examples of simple Markov Chains

Problematic network

See Nezbeda, Kolafa and Kotrla: Introduction to Molecular Simulations, Prague 2002 (in Czech), page 46

Let there be a network which is not very reliable:
1) the probability the network will work tomorrow if it works today is 60%
2) and the probability the network will not work tomorrow if it does not work today is 70%.

Questions:
1) What is the probability the network will work in k days if it works today?
2) Does this probability depend on k? Does it depend on the initial state of the network?

(* initial state - the network certainly works today *)
p={1.0,0.0}; (* vector p contains probabilities whether the network works or doesn't *)
(* transition matrix - probabilities of going from one state to another *)
W={{0.6,0.4},{0.3,0.7}} ;
MatrixForm[W]
kfin=20; (* number of days - the length of the Markov chain *)
Do[
p=N[p.W];
Print[p],
{k,1,kfin}
];

(* left eigenvectors (in rows, normalized to be sum of elements = 1) and corresponding eigenvalues *)
{λ,v}=Eigensystem[Transpose[W]];
Do[ 
If[
Abs[Total[v[[i]]]]>0.0,v[[i]]=v[[i]]/Total[v[[i]]]],(* normalization *)
{i,1,2}
]
{λ,v}

Random flipping of a die over an edge

Let us have a regular six-sided die. Put it on the table and start flipping each time over a random edge. Thus
1) the probability the vertical side will appear at the top is 1/4
2) and the probability the top or bottom side will appear at the top is 0.

Questions:
1) What is the probability a certain side will appear at the top after k flips if there is 1 at the beginning?
2) Again: Does this probability depend on k? Does it depend on the initial state?

(* initial state - the side 1 is certaily up *)
p={1.0,0.0,0.0,0.0,0.0,0.0};(* vector p contains probabilities of each side to be at the top *)
(* transition matrix - probabilities of going from one state to another *)
n=6;
W=ConstantArray[1/4,{n,n}];
Do[
W[[i,i]]=0;
W[[i,n-i+1]]=0,
{i,1,n}
];
MatrixForm[W]
kfin=20; (* number of flips - the length of the Markov chain *)
Do[
p=N[p.W];
Print[p],
{k,1,kfin}
];

(* left eigenvectors (in rows, normalized to be sum of elements = 1) and corresponding eigenvalues *)
{λ,v}=N[Eigensystem[Transpose[W]]];
Do[ 
If[
Abs[Total[v[[i]]]]>0.0,v[[i]]=v[[i]]/Total[v[[i]]]],(* normalization *)
{i,1,2}
]
{λ,v}