File:Randomwalk msd.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(SVG file, nominally 335 × 720 pixels, file size: 181 KB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
English: some trajectories and the mean squared displacement of a random walk with a step size of . the circles sshow the MSD at different times
Date
Source Own work
Author Jkrieger
SVG development
InfoField
 
The SVG code is valid.
 
This diagram was created with MATLAB.
Source code
InfoField

MATLAB code

% timesteps in each random walk
timesteps=10000;
plotstep=10;
% diffusion coefficient for the random walk
D=0.5;
observation_radius=10;
observation_steps=100;
lim_factor=1.4;
plots=10;
plotevery=1;

%calculate grid size
dr=sqrt(2*D);
t=1:timesteps;

% simulate random walks on grid
x=zeros(plots,timesteps);
y=x;
for k=1:plots
    for ct=2:timesteps
        x(k,ct)=x(k,ct-1)+dr*(randi(2)-1.5)*2;
        y(k,ct)=y(k,ct-1)+dr*(randi(2)-1.5)*2;
    end
end

% calculate MSD as ensemble average on a logarihmic lag time scale
msdtau=round(logspace(0,floor(log10(timesteps)),50));
msd(1:length(msdtau))=0;
for tau=1:length(msdtau)
    msd(tau)=mean( (x(:,msdtau(tau))-x(:,1)).^2 + (y(:,msdtau(tau))-y(:,1)).^2 );
end

% plot random walk
figure(1)
subplot(2,1,1)
for k=1:plotevery:plots
    plot(x(k,1:plotstep:timesteps),y(k,1:plotstep:timesteps), 'Color', hsv2rgb([k/(plots+1),1,1]));
    if (k==1) 
        hold on;
    end
end
for k=5:5:length(msdtau)
    drr=sqrt(msd(k));
    rectangle('Position',[-drr,-drr,2*drr,2*drr], 'Curvature',[1,1], 'LineWidth', 2);
end
daspect([1,1,1])
hold off
xlim([-lim_factor*drr lim_factor*drr]);
ylim([-lim_factor*drr lim_factor*drr]);
xlabel('coordinate x');
ylabel('coordinate y');
title('random walk trajectories');

% plot MSD
subplot(2,1,2)
loglog(msdtau, msd, 'LineWidth', 2);
hold on
loglog(msdtau, 4*D*msdtau, 'r--', 'LineWidth', 2);
hold off
xlabel('lag time t')
ylabel('MSD \langle r^2(\tau)\rangle');
M{1}='measured MSD';
M{2}='\langle r^2(\tau)\rangle=4D\cdot\tau';
legend(M,'Location', 'NorthWest');
title('mean squared displacement');
xlim([1 1e4]);
ylim([1 1e4]);
daspect([1,1,1])

Licensing

[edit]
w:en:Creative Commons
attribution
This file is licensed under the Creative Commons Attribution 3.0 Unported license.
Attribution: Jan Krieger
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current14:44, 5 August 2012Thumbnail for version as of 14:44, 5 August 2012335 × 720 (181 KB)Jkrieger (talk | contribs)font problem solved
14:29, 5 August 2012Thumbnail for version as of 14:29, 5 August 2012335 × 720 (197 KB)Jkrieger (talk | contribs)last simulation had wrong step size (factor sqrt(2)=sqrt(d))
12:25, 5 August 2012Thumbnail for version as of 12:25, 5 August 2012335 × 720 (105 KB)Jkrieger (talk | contribs)formating
11:29, 5 August 2012Thumbnail for version as of 11:29, 5 August 2012335 × 720 (114 KB)Jkrieger (talk | contribs){{Information |Description ={{en|1=some trajectories and the mean squared displacement of a random walk with a step size of <math>\sqrt(4\cdot 0.5}=\sqrt(2)</math>. the circles sshow the MSD at different times}} |Source ={{own}} |Author ...

There are no pages that use this file.

File usage on other wikis

The following other wikis use this file: