(*definitions for graphical representations*)

color[n_]=(1-n) Blue+n Green;

tabconf[conf_]:=Table[{color[conf[[i]]],Rectangle[{i,0}]},{i,1,Length@conf}]

plotconf[conf_]:=Graphics@tabconf@conf

plotconf[{0,0,1,1,0,1,0,0,1}]

colorhist[n_]=(1-n) Lighter@Blue+n Lighter@Green;

tabconfhist[hist_]:=Table[
confj=hist[[j]];Table[{colorhist[confj[[i]]],Rectangle[{i,-j}]},{i,1,Length@confj}],
{j,1,Length@hist}]

tabconfhist[hist_,times_]:=Table[
confj=hist[[j]];{tinit,tfin}=times[[j;;j+1]];
Table[{colorhist[confj[[i]]],Rectangle[{i,tinit},{i+1,tfin}]},{i,1,Length@confj}],
{j,1,-1+Length@hist}]

(*evolution of configurations*)

L=30;ninit=Table[RandomChoice[{0,1}],{L}]

evolve[m_,c_]:=Module[{tabprob,tabevent,event,n=m},
(*event {i} is change of state in i*)
tabprob=Table[(  (1-c)n[[i]]+c(1-n[[i]])  )(n[[Mod[i+1,L,1]]]+n[[Mod[i-1,L,1]]]),{i,1,L}];
tabevent=Table[i,{i,1,L}];
event=RandomChoice[tabprob->tabevent];
n[[event]]=1-n[[event]];
n
]

(*to stop the animation: suppress the result from this cell*)
Manipulate[
DynamicModule[{nn=ninit},
Framed[Show[Graphics[Pause[.01];Dynamic[tabconf[nn=evolve[nn,c];nn]]],
ImageSize->800
]]]
,
{{c,.5},.01,.99}
]

(*evolution, including past*)

L=20;ninit=Table[RandomChoice[{0,1}],{L}];

escaperate[m_,c_]:=Module[{r,n=m},
(*event {i} is change of state in i*)
r=Sum[(  (1-c)n[[i]]+c(1-n[[i]])  )(n[[Mod[i+1,L,1]]]+n[[Mod[i-1,L,1]]]),{i,1,L}];
r
]

(*duration is the number of configurations that are remembered*)
IS=500;duration=10;
Manipulate[
DynamicModule[{nn=ninit,hist=Table[ninit,{duration}],times=Table[0,{duration}],r,Δt,resc=7.},
Framed[Dynamic[Column[{
Graphics[tabconf[nn=evolve[nn,c];nn],ImageSize->IS],
Graphics[
hist=(Prepend[hist,nn])[[;;duration]];
r=escaperate[nn,c];
Δt=resc RandomVariate[ExponentialDistribution[r]];
times=(Prepend[times-Δt,0])[[;;duration]];
tabconfhist[hist,times]
,ImageSize->IS]
}]
]]]
,
{{c,.3},.01,.99}
]

(*dynamical histogram*)
(*comment/uncomment pair of lines so as to switch representations *)

IS=500;
Klist={};t=0.;k=0.;
Manipulate[
DynamicModule[{nn=ninit,r,Δt,(*Klist={},t=0.,k=0.,*)lastduration},
Dynamic[
If[Length@Klist<maxlength,
lastduration=duration;
While[t<duration,
nn=evolve[nn,c];
r=escaperate[nn,c];
Δt=RandomVariate[ExponentialDistribution[r]];
t=t+Δt;k++;
];
(*histogram of activity K*)Klist=Append[Klist,k];
(*histogram of K/t*)(*Klist=Append[Klist,k/duration];*)
t=0.; k=0.; 
If[lastduration≠duration,t=0.;k=0.;Klist={};];
];
(*log representation*)(*Histogram[Klist,Automatic,{"Log","Probability"},ImageSize->IS,Frame->True]*)
(*linear representation*)Histogram[Klist,Automatic,"Probability",ImageSize->IS,Frame->True]
]]
,
{{c,.3},.01,.99},
{{duration,1.},1.,100.,1,Manipulator[Dynamic[duration,(t=0.;k=0.;Klist={};duration=#)&],##2]&},
{{maxlength,1000},1,2000}
]