This notebook contains additional material to the Mathematica GuideBooks  (Springer-Verlag, New York, 2004) http://www.MathematicaGuideBooks.org . It uses the stylesheet of the Mathematica GuideBooks, which is embedded.

Numerics Volume, Chapter 1

Consider a random walk in 1D where the stepsize (Subscript[λ, n]) of the nth step depends on n. For the two functions (Subscript[λ, n])=(n^α) (α<0) and (Subscript[λ, n])=(α^n) (0<α<1), visualize the density of the resulting walker positions after the first 25 steps for various α.

varyingStepSizeRandomWalkData[λList_, max_, δ_] := 
With[{o = Length[λList]},
Compile[{}, Module[{L = Table[0, {δ}], x, k},
               Do[(* final walk position after o steps *) x = #1.λList; 
                  (* bin final walk position *)
                  k = Round[(x + max)/(2max) (δ - 1)] + 1;
                  (* count binned final walk position *)
                  L[[k]] = L[[k]] + 1, ##2];
                  L]][]&[(* left-right steps *) Table[i[k], {k, o}], 
                         (* left-right step iterators *)
                         Sequence @@ Table[{i[k], -1, 1, 2}, {k, o}]]];

The next series of graphics shows the results for (Subscript[λ, n])=(α^n). For larger α, we obtain a smooth bell-shaped curve. For smaller α, we obtain a fractal structure. For a detailed discussion of this case, see [✶].

opts = Sequence[PlotRange -> All, Frame -> True, FrameTicks -> False,
                DisplayFunction -> Identity, Axes -> False,
                PlotStyle -> {PointSize[0.0001]}];

With[{o = 25, δ = 1000}, 
Show[GraphicsArray[
    ListPlot[varyingStepSizeRandomWalkData[
              Table[#^k, {k, o}],  #/(1 - #), δ], opts]& /@ 
                      {0.4, 0.55, 1./GoldenRatio, 0.8}]]];

For (Subscript[λ, n])=(n^α), we see nested structures forming for decreasing α.

With[{o = 25, δ = 1000}, 
Show[GraphicsArray[
    ListPlot[varyingStepSizeRandomWalkData[
              Table[k^#, {k, o}],  Sum[k^#, {k, o}], δ], opts]& /@ 
                                           {-0.4, -1., -1.5, -2.}]]]