Laboratoria z Modelowania Matematycznego, cwiczenie 3. “Ergodyczność”

n=600;
F=Sin;
Integrate[F[x],{x,0,2π}]
Show[ListPlot[Accumulate[F/@NestList[Mod[#+1,2π]&,N@(Sqrt[2]),n]]/Range[n+1],Joined->True,Mesh->Full],Plot[%,{x,0,n},PlotStyle->Directive[Thick,Red]]]

n=60;
F=((Cos[#])^2)&;
Integrate[F[x],{x,0,2π}]
Show[ListPlot[Accumulate[F/@NestList[Mod[#+1,2π]&,N@(Sqrt[2]),n]]/Range[n+1],Joined->True,Mesh->Full,PlotRange->{0,1}],Plot[%/(2π),{x,0,n},PlotStyle->Directive[Thick,Red]]]

DiscreteMarkovProcess[1,{{1/2,1/2},{0,1}}]
Graph[%]
MarkovProcessProperties[%%]

DiscreteMarkovProcess[1,{{0,1/2,0,0,1/2},{1/2,0,1/2,0,0},{1/3,1/3,0,1/3,0},{0,0,1/2,0,1/2},{1/2,0,0,1/2,0}}]
Graph[%]
MarkovProcessProperties[%%]

DiscreteMarkovProcess[1,{{0,1/2,1/4,1/4,0},{1,0,0,0,0},{1/2,1/4,0,0,1/4},{1/4,1/4,0,0,1/2},{1,0,0,0,0}}]
Graph[%]
MarkovProcessProperties[%%]

DiscreteMarkovProcess[1,{{0,1/2,1/2,0,0},{0,0,1/2,1/2,0},{0,0,0,1/2,1/2},{1/2,0,0,0,1/2},{1/2,1/2,0,0,0}}]
Graph[%]
MarkovProcessProperties[%%]

NestList[#.{{0,(1/2),0,0,(1/2)},{(1/2),0,(1/2),0,0},{(1/3),(1/3),0,(1/3),0},{0,0,(1/2),0,(1/2)},{(1/2),0,0,(1/2),0}}&,{1,0,0,0,0.},100]

{0.2588235295753479`,0.1882352940165465`,0.17647058823529382`,0.1647058824540411`,0.211764705718769`}.{{0,(1/2),0,0,(1/2)},{(1/2),0,(1/2),0,0},{(1/3),(1/3),0,(1/3),0},{0,0,(1/2),0,(1/2)},{(1/2),0,0,(1/2),0}}
%-{0.2588235295753479`,0.1882352940165465`,0.17647058823529382`,0.1647058824540411`,0.211764705718769`}

Eigensystem[Transpose@{{0,(1/2),0,0,(1/2)},{(1/2),0,(1/2),0,0},{(1/3),(1/3),0,(1/3),0},{0,0,(1/2),0,(1/2)},{(1/2),0,0,(1/2),0}}]

#/Total@#&@{(11/9),(8/9),(5/6),(7/9),1}//N

DiscreteMarkovProcess[1,{{0,(1/2),0,(1/2),0,0,0,0,0},{(1/3),0,(1/3),0,(1/3),0,0,0,0},{0,0,1,0,0,0,0,0,0},{(1/3),0,0,0,(1/3),0,(1/3),0,0},{0,(1/4),0,(1/4),0,(1/4),0,(1/4),0},{0,0,(1/3),0,(1/3),0,0,0,(1/3)},{0,0,0,0,0,0,1,0,0},{0,0,0,0,(1/3),0,(1/3),0,(1/3)},{0,0,0,0,0,(1/2),0,(1/2),0}}]
Graph[%]
MarkovProcessProperties[%%]

mat={{0,(1/2),0,(1/2),0,0,0,0,0},{(1/3),0,(1/3),0,(1/3),0,0,0,0},{0,0,1,0,0,0,0,0,0},{(1/3),0,0,0,(1/3),0,(1/3),0,0},{0,(1/4),0,(1/4),0,(1/4),0,(1/4),0},{0,0,(1/3),0,(1/3),0,0,0,(1/3)},{0,0,0,0,0,0,1,0,0},{0,0,0,0,(1/3),0,(1/3),0,(1/3)},{0,0,0,0,0,(1/2),0,(1/2),0}};

NestList[RandomChoice[mat[[#]]->{1,2,3,4,5,6,7,8,9}]&,1,10]

n=60;
F=(Sqrt[#])&;
Integrate[((F[x])/(π(Sqrt[x(1-x)]))),{x,0,1}]
Show[ListPlot[Accumulate[F/@NestList[4#(1-#)&,0.2,n]]/Range[n+1],Joined->True,Mesh->Full,PlotRange->{0,1}],Plot[%,{x,0,n},PlotStyle->Directive[Thick,Red]]]