44
3 Biased Brownian Motion
3.7.3 Program 3.3, Dichotomous Noise, Matlab Code
% Dichotomous noise: To visualize the pattern make N=100, NR=1, to verify
= 0,leave as it is.
N=100; NR=1; dt=0.1; tau=0.5, a=-1; b=1. %tau=1/(2*mu);
t=(1:N)*dt;
eta=zeros(N,NR);
for j=1:NR;
for i=1:N-1;
Pat1at = 0.5*(1. + exp(-i*dt/tau)); % Probability to stay in (-1)
Pat2at1 = Pat1at;
Pat1bt = 0.5*(1. - exp(-i*dt/tau)); % Transition Probability (1) to (-1)
Pat2bt1 = Pat1bt;
Pbt2bt1 = 0.5*(1. + exp(-i*dt/tau)); % Probability to stay in (1)
Pbt1bt = Pbt2bt1;
Pbt1at = 0.5*(1. - exp(-i*dt/tau)); % Transition Probability (-1) to (1)
Pbt2at1 = Pbt1at;
R=unifrnd(0,1);
if(Pat1at R)
eta(i+1,j)=-1.;
else eta(i+1,j)=1.;
end
if(Pat1at ≺ R || Pat1at R)
R1=unifrnd(0,1);
elseif(Pat2bt1 R1 || Pat2at1 R1)
eta(i+2,j)=-1.;
else eta(i+2,j)=1.;
end
end
end
save t.DAT t -ascii; MEANeta=(sum(eta,2))/NR; % stochastic mean, over NR
realizations.
figure(1); plot(MEANeta); grid;
figure(2); plot(t,eta); grid;
ylim([-1.1 1.1]); grid %save MEANeta.dat Meaneta -ascii;
3.7.4 Program 3.4, Flashing Ratchet, Matlab Code
% Flashing ratchet
N=10000; NR=1000; dt=0.01;
F=0.; Vo=5.; D=5.; tau=0.4;
eta=zeros(N,NR);
3 Biased Brownian Motion
3.7.3 Program 3.3, Dichotomous Noise, Matlab Code
% Dichotomous noise: To visualize the pattern make N=100, NR=1, to verify
N=100; NR=1; dt=0.1; tau=0.5, a=-1; b=1. %tau=1/(2*mu);
t=(1:N)*dt;
eta=zeros(N,NR);
for j=1:NR;
for i=1:N-1;
Pat1at = 0.5*(1. + exp(-i*dt/tau)); % Probability to stay in (-1)
Pat2at1 = Pat1at;
Pat1bt = 0.5*(1. - exp(-i*dt/tau)); % Transition Probability (1) to (-1)
Pat2bt1 = Pat1bt;
Pbt2bt1 = 0.5*(1. + exp(-i*dt/tau)); % Probability to stay in (1)
Pbt1bt = Pbt2bt1;
Pbt1at = 0.5*(1. - exp(-i*dt/tau)); % Transition Probability (-1) to (1)
Pbt2at1 = Pbt1at;
R=unifrnd(0,1);
if(Pat1at R)
eta(i+1,j)=-1.;
else eta(i+1,j)=1.;
end
if(Pat1at ≺ R || Pat1at R)
R1=unifrnd(0,1);
elseif(Pat2bt1 R1 || Pat2at1 R1)
eta(i+2,j)=-1.;
else eta(i+2,j)=1.;
end
end
end
save t.DAT t -ascii; MEANeta=(sum(eta,2))/NR; % stochastic mean, over NR
realizations.
figure(1); plot(MEANeta); grid;
figure(2); plot(t,eta); grid;
ylim([-1.1 1.1]); grid %save MEANeta.dat Meaneta -ascii;
3.7.4 Program 3.4, Flashing Ratchet, Matlab Code
% Flashing ratchet
N=10000; NR=1000; dt=0.01;
F=0.; Vo=5.; D=5.; tau=0.4;
eta=zeros(N,NR);
