<?php
if (isset($nh)) 
  echo "<body text='#000000' bgcolor='#FFFFFF'>"; ?>
<?php
if (!isset($user_dir)) $user_dir='.';
if (!isset($nh)) {
  if ($pde =='0') {
    exit();
  } else {
    echo "<html>
    <head><meta name=robots content=noindex,nofollow>
    <title>1.04 Random walk</title></head>
    <body text='#000000' bgcolor='#FFFFFF'>
<img SRC='../../images/previous_motif_gr.gif' border=0 align=bottom>
    <a href='".$user_dir."/../../../SRC/assign.php'     onMouseover=\"window.status=' # assignments'; return true\">
<img SRC='../../images/up_motif_gr.gif' border=0 align=bottom></a>
<img SRC='../../images/next_motif_gr.gif' border=0 align=bottom>
    <a href='".$user_dir."/../../../SYL/node1.php'      onMouseover=\"window.status=' # course'; return true\">
<img SRC='../../images/contents_motif.gif' border=0 align=bottom></a>
    <br><hr><br>";
  }
} echo "<h1>1.04 Random walk</h1>" ?>
                 
 
<p>
                                                                             
Consider a walk with a large number M of statistically independent 
steps <font face="symbol">x</font
><sub>i</sub> randomly distributed, so that the statistical average of 
the random variable yields  &lt; <font face="symbol">x</font
> &gt;  = 0.
The final position z = <font face="symbol">å</font
><sub>i = 1</sub><sup>M</sup> <font face="symbol">x</font
><sub>i</sub> in average coincides with the 
initial position  &lt; z &gt;  = <font face="symbol">å</font
><sub>i = 1</sub><sup>M</sup>  &lt; <font face="symbol">x</font
><sub>i</sub> &gt;  = 0. The root mean square 
(RMS) displacement, however, is finite

<p>

<br clear="all" /><table border="0" width="100%"><tr><td>
<table align="center"><tr><td nowrap="nowrap" align="center">
 &lt; z<sup>2</sup> &gt;  =  &lt; </td><td align="left" class="cl"><font face="symbol">
æ<br />è
</font></td><td nowrap="nowrap" align="center">
<font size="-1">M</font><!--sup
--><br /><font face="symbol" size="+3">å<br /></font>
<font size="-1">i = 1</font>&nbsp;<br /></td><td nowrap="nowrap" align="center">
<font face="symbol">x</font
><sub>i</sub></td><td align="left" class="cl"><font face="symbol">
ö<br />ø
</font></td><td nowrap="nowrap" align="center">
</td><td align="left" class="cl"><font face="symbol">
æ<br />è
</font></td><td nowrap="nowrap" align="center">
<font size="-1">M</font><!--sup
--><br /><font face="symbol" size="+3">å<br /></font>
<font size="-1">j = 1</font>&nbsp;<br /></td><td nowrap="nowrap" align="center">
<font face="symbol">x</font
><sub>j</sub></td><td align="left" class="cl"><font face="symbol">
ö<br />ø
</font></td><td nowrap="nowrap" align="center">
 &gt;  = </td><td nowrap="nowrap" align="center">
<font size="-1">M</font><!--sup
--><br /><font face="symbol" size="+3">å<br /></font>
<font size="-1">i = 1</font>&nbsp;<br /></td><td nowrap="nowrap" align="center">
 &lt; <font face="symbol">x</font
><sub>i</sub><sup>2</sup> &gt;  + </td><td nowrap="nowrap" align="center">
<font size="-1"></font><!--sup
--><br /><font face="symbol" size="+3">å<br /></font>
<font size="-1">i <font face="symbol">¹</font
> j</font>&nbsp;<br /></td><td nowrap="nowrap" align="center">
 &lt; <font face="symbol">x</font
><sub>i</sub> <font face="symbol">x</font
><sub>j</sub> &gt;  = M  &lt; <font face="symbol">x</font
><sup>2</sup> &gt;  = </td><td nowrap="nowrap" align="center">
t<hr noshade="noshade" /><font face="symbol">t</font
><br /></td><td nowrap="nowrap" align="center">
<font face="symbol">l</font
><sub>mfp</sub><sup>2</sup></td></tr></table>
</td></tr></table>


where <font face="symbol">t</font
> defines the average time elapsed between consecutive steps, 
M = t/<font face="symbol">t</font
> is the number of steps taken during a time interval of duration 
t and <font face="symbol">l</font
><sub>mfp</sub> is the so-called mean free path.

<p>
Now, repeat the calculation with the second moment of the diffusion 
equation and define the total density N as 

<p>

<br clear="all" /><table border="0" width="100%"><tr><td>
<table align="center"><tr><td nowrap="nowrap" align="center">
</td><td nowrap="nowrap" align="center">
<hr noshade="noshade" />z<sup>2</sup><br />&nbsp;<br /></td><td nowrap="nowrap" align="center">
(t) = </td><td nowrap="nowrap" align="center">
1<hr noshade="noshade" />N<br /></td><td nowrap="nowrap" align="center">
</td><td align="left" class="cl"><font face="symbol">
ó<br />õ
</font></td><td nowrap="nowrap" align="center">
<font size="-1">+<font face="symbol">¥</font
></font><!--sup
--><br /><br />
<font size="-1"><font face="symbol">-</font
><font face="symbol">¥</font
></font>&nbsp;<br /></td><td nowrap="nowrap" align="center">
z<sup>2</sup> n(z,t) dz</td></tr></table>
</td></tr></table>



<p>

<br clear="all" /><table border="0" width="100%"><tr><td>
<table align="center"><tr><td nowrap="nowrap" align="center">
N(t) = </td><td align="left" class="cl"><font face="symbol">
ó<br />õ
</font></td><td nowrap="nowrap" align="center">
<font size="-1">+<font face="symbol">¥</font
></font><!--sup
--><br /><br />
<font size="-1"><font face="symbol">-</font
><font face="symbol">¥</font
></font>&nbsp;<br /></td><td nowrap="nowrap" align="center">
n(z,t) dz</td></tr></table>
</td></tr></table>


The first term yields

<p>

<br clear="all" /><table border="0" width="100%"><tr><td>
<table align="center"><tr><td nowrap="nowrap" align="center">
</td><td align="left" class="cl"><font face="symbol">
ó<br />õ
</font></td><td nowrap="nowrap" align="center">
<font size="-1">+<font face="symbol">¥</font
></font><!--sup
--><br /><br />
<font size="-1"><font face="symbol">-</font
><font face="symbol">¥</font
></font>&nbsp;<br /></td><td nowrap="nowrap" align="center">
z<sup>2</sup> <font face="symbol">¶</font
><sub>t</sub> n dz = <font face="symbol">¶</font
><sub>t</sub> </td><td align="left" class="cl"><font face="symbol">
ó<br />õ
</font></td><td nowrap="nowrap" align="center">
<font size="-1">+<font face="symbol">¥</font
></font><!--sup
--><br /><br />
<font size="-1"><font face="symbol">-</font
><font face="symbol">¥</font
></font>&nbsp;<br /></td><td nowrap="nowrap" align="center">
z<sup>2</sup> n dz = N <font face="symbol">¶</font
><sub>t</sub> </td><td nowrap="nowrap" align="center">
<hr noshade="noshade" />z<sup>2</sup><br />&nbsp;<br /></td><td nowrap="nowrap" align="center">
</td></tr></table>
</td></tr></table>


and the second after two integration by parts gives

<p>

<br clear="all" /><table border="0" width="100%"><tr><td>
<table border="0" width="80%" align="right"><tr><td nowrap="nowrap" align="right">
<table border="0"><tr><td nowrap="nowrap" Align="left">
</td><td align="left" class="cl"><font face="symbol">
ó<br />õ
</font></td><td nowrap="nowrap" align="center">
<font size="-1">+<font face="symbol">¥</font
></font><!--sup
--><br /><br />
<font size="-1"><font face="symbol">-</font
><font face="symbol">¥</font
></font>&nbsp;<br /></td><td nowrap="nowrap" align="center">
z<sup>2</sup> D<font face="symbol">¶</font
><sup>2</sup><sub>z</sub> n dz  </td></tr></table></td><td nowrap="nowrap" align="left">
<table border="0"><tr><td nowrap="nowrap" Align="left">
 = </td></tr></table></td><td nowrap="nowrap" align="left">
<table border="0"><tr><td nowrap="nowrap" Align="left">
[z<sup>2</sup> D<font face="symbol">¶</font
><sub>z</sub> n]<sub><font face="symbol">-</font
><font face="symbol">¥</font
></sub><sup>+<font face="symbol">¥</font
></sup> + </td><td align="left" class="cl"><font face="symbol">
ó<br />õ
</font></td><td nowrap="nowrap" align="center">
<font size="-1">+<font face="symbol">¥</font
></font><!--sup
--><br /><br />
<font size="-1"><font face="symbol">-</font
><font face="symbol">¥</font
></font>&nbsp;<br /></td><td nowrap="nowrap" align="center">
<font face="symbol">¶</font
><sub>z</sub> (z<sup>2</sup> D) <font face="symbol">¶</font
><sub>z</sub> n dz </td></tr></table></td><td nowrap="nowrap" align="left">
<table border="0"><tr><td nowrap="nowrap" Align="left">
 = </td></tr></table></td><td nowrap="nowrap" align="left">
<table border="0"><tr><td nowrap="nowrap" Align="left">
[<font face="symbol">¶</font
><sup>2</sup><sub>z</sub>(z<sup>2</sup> D)n]<sub><font face="symbol">-</font
><font face="symbol">¥</font
></sub><sup>+<font face="symbol">¥</font
></sup> + </td><td align="left" class="cl"><font face="symbol">
ó<br />õ
</font></td><td nowrap="nowrap" align="center">
<font size="-1">+<font face="symbol">¥</font
></font><!--sup
--><br /><br />
<font size="-1"><font face="symbol">-</font
><font face="symbol">¥</font
></font>&nbsp;<br /></td><td nowrap="nowrap" align="center">
<font face="symbol">¶</font
><sup>2</sup><sub>z</sub> (z<sup>2</sup> D) n dz  </td></tr></table></td><td nowrap="nowrap" align="left">
<table border="0"><tr><td nowrap="nowrap" Align="left">
 = </td></tr></table></td><td nowrap="nowrap" align="left">
<table><tr><td nowrap="nowrap" align="right" colspan="0">2D </td><td align="left" class="cl"><font face="symbol">
ó<br />õ
</font></td><td nowrap="nowrap" align="center">
<font size="-1">+<font face="symbol">¥</font
></font><!--sup
--><br /><br />
<font size="-1"><font face="symbol">-</font
><font face="symbol">¥</font
></font>&nbsp;<br /></td><td nowrap="nowrap" align="center">
n(z,t) dz = 2DN</td></tr></table></TD></TR></table>
</td></tr></table>


where a constant diffusion has been assumed for simplicity D <font face="symbol">¹</font
> D(x).
Reassembling both terms and integrating in time leads to

<p>

<br clear="all" /><table border="0" width="100%"><tr><td>
<table align="center"><tr><td nowrap="nowrap" align="center">
N</td><td nowrap="nowrap" align="center">
<table border="0"><tr><td nowrap="nowrap" align="center">
d</td><td nowrap="nowrap" align="center">
<hr noshade="noshade" />z<sup>2</sup><br />&nbsp;<br /></td></tr></table><hr noshade="noshade" />dt<br /></td><td nowrap="nowrap" align="center">
 = 2DN &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font face="symbol">Þ</font
> &nbsp;&nbsp;&nbsp;&nbsp;</td><td nowrap="nowrap" align="center">
<hr noshade="noshade" />z<sup>2</sup><br />&nbsp;<br /></td><td nowrap="nowrap" align="center">
 = 2Dt</td></tr></table>
</td></tr></table>


The ergodicity theorem is finally used to identify the statistical 
average  &lt; X &gt;  with the mean value of a continuous variable [<font face="symbol">`</font
>X], 
leading to the well known identity

<p>

<br clear="all" /><table border="0" width="100%"><tr><td>
<table align="center"><tr><td nowrap="nowrap" align="center">
D = </td><td nowrap="nowrap" align="center">
<font face="symbol">l</font
><sub>mfp</sub><sup>2</sup><hr noshade="noshade" />2<font face="symbol">t</font
><br /></td><td nowrap="nowrap" align="center">
.</td></tr></table>
</td></tr></table>



<p>
The theory of stochastic processes behind the Monte-Carlo Method is 
rather sophisticated and will be introduced later in sect.5. 
From the calculation above, it is however possible to conclude now 
already that the evolution of a large number of independent particles 
following a random walk implemented in <font face="helvetica">JBONE</font> as

<pre>
      for(int j = 0; j &lt; numberOfParticles; j++){
        particlePosition[j] += random.nextGaussian() *
          Math.sqrt(2 * diffusCo * timeStep);
      }

</pre>
describes a diffusion.
</font></font><br><p><applet codebase="<?php echo $user_dir ?>/applet/" code=jbone align=center width=780 height=400>
       <param name=Velocity            value=0.>
       <param name=Diffusion           value=0.5>
       <param name=TimeStep            value=0.5>
       <param name=MeshPoints          value=64>
       <param name=Walkers             value=1>
       <param name=ICAmplitude         value=1.>
       <param name=ICPosition          value=32.>
       <param name=ICWidth             value=3.>
       <param name=RunTime             value=100.>
       <param name=MeshLeft            value=0.>
       <param name=MeshLength          value=64.>
       <param name=method              value="Particle methods*">
       <param name=scheme              value="MC norm. walk">
       <param name=ic                  value="Gaussian">
       <param name=pde                 value="Advection">
</applet><br><p><br>Press <B>START/STOP</B> for execution. Now increase 
the number of <I>Walkers</I> to <I>100</I> and press <I>initialise</I> 
to distribute the positions with a narrow Gaussian density. Repeat the 
same random walk evolution of independent particles and check what happens!
<?php
echo "<br><hr><address>
<img SRC='../../images/previous_motif_gr.gif' border=0 align=bottom>
<a href='".$user_dir."/../../../SRC/assign.php'    onMouseover=\"window.status=' # assignments'; return true\">
<img SRC='../../images/up_motif_gr.gif' border=0 align=bottom></a>
<img SRC='../../images/next_motif_gr.gif' border=0 align=bottom>
<a href='".$user_dir."/../../../SYL/node1.php'    onMouseover=\"window.status=' # course'; return true\">
<img SRC='../../images/contents_motif.gif' border=0 align=bottom></a>
<i>&copy;&nbsp; 
Doc Andre Jaun &amp; <a href='http://pde.fusion.kth.se/'    onMouseover=\"window.status=' # home'; return true\">Lifelong-Learners/pde</a> at  21:18:51,  February 02nd, 2003</i></address>
</body>
</html>"; ?>
