2
$\begingroup$

I want to simulate 3 types of diffusion processes:

  1. normal diffusion $[\langle x^2(t)\rangle \propto t ]$.
  2. subdiffusion $[\langle x^2(t)\rangle \propto t^\alpha ; \alpha<1 ]$
  3. superdiffusion $[\langle x^2(t)\rangle \propto t^\alpha ; \alpha>1]$

credit: wikimedia

I was trying to do the following:

close all
M=1e4;
N=50;
dx=randn(M,N);

sub = dx;
sup = dx;
alpha=0.8;
for i =2:M
    for j=1:N
        if rand > 0.1
            center = (1-alpha) * sub(i,j) + alpha * sub(i-1,1);
            sub(i,j) = mean(random('norm',center,0.1,1,5));
            center = alpha * sup(i,j) + (1-alpha) * sup(i-1,1);
            sup(i,j) = random('norm',1+center,1,1,1);
        end
    end
end


x=cumsum(dx);
xSub=cumsum(sub);
xSup=cumsum(sup);

MSD_x=mean(x.^2,2);
MSD_xSub=mean(xSub.^2,2);
MSD_xSup=mean(xSup.^2,2);

ND = loglog(0:M-1,MSD_x);
hold on
SUB = loglog(0:M-1,MSD_xSub);
SUP = loglog(0:M-1,MSD_xSup);

fit(ND.XData',ND.YData', 'poly1')
fit(SUB.XData',SUB.YData', 'poly1')
fit(SUP.XData',SUP.YData', 'poly1')
figure
subplot(1,3,1)
plot(0:M-1, MSD_x)
subplot(1,3,2)
plot(0:M-1, MSD_xSub)
subplot(1,3,3)
plot(0:M-1, MSD_xSup)

The MSD as function of time:

enter image description here

Here is the loglog scale of the 3 signals:

enter image description here

Why don't I get the right profiles as in the first figure?

$\endgroup$
  • 1
    $\begingroup$ Why is this off topic? $\endgroup$ – 0x90 Jan 5 '18 at 12:10
  • $\begingroup$ Are you asking for help with your MATLAB code, or about how to simulate diffusion using wavelet fractional Brownian motion in general? The former presumably belongs on Stack Overflow, but the latter would be on topic here, even if the thread mentions code. $\endgroup$ – gung Jan 5 '18 at 12:40
  • $\begingroup$ @gung, now it's about the algorithm, not code. $\endgroup$ – 0x90 Jan 5 '18 at 13:14
  • $\begingroup$ @gung, I also created a question for syntax of wfbm on SO: stackoverflow.com/questions/48114511/… $\endgroup$ – 0x90 Jan 5 '18 at 13:22
  • 1
    $\begingroup$ 1) As few as 1000 samples isn't necessarily get you in the neighborhood, you might want 10k or so. MCMC takes around that just to get started. 2) you really should draw independently. 3) If you want the mean or variance of your normal-derived function to move with $\tau$ then put it into the loop. $\endgroup$ – EngrStudent Jan 7 '18 at 4:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.