[Random Walks Plot] - A New Kind of Science: The NKS Forum

A New Kind of Science: The NKS Forum

Pages:1



Random Walks Plot

(Click here to view the original thread with full colors/images)



Posted by: pietro

How can I plot random walks as at page 328-330 of nks, once done:

Block[{t = 10, k = 4, e}, SeedRandom[1]; e = Table[{
Cos[2 ð s/k], Sin[2 ð s/k]}, {s, 0, k - 1}];
FoldList[Plus, {0, 0}, Table[e[[Random[Integer, {1, k}]]], {t}]]]

ListPlot is the ony way?
Let me know asap.
Thanks PietroG.



Posted by: Todd Rowland

Your random walk is in two dimensions not one, so ListPlot is not the right thing to use. It is better to just use Graphics primitives, in this case use Line. For instance,

walk1=Module[{t = 10, k = 4, e}, SeedRandom[1]; e = Table[{Cos[2 ð s/k], Sin[2 ð s/k]}, {s, 0, k - 1}]; FoldList[Plus, {0, 0}, Table[e[[Random[Integer, {1, k}]]], {t}]]]

Show[Graphics[Line[walk1]]]

If you just want to see the points of the random walk,

Show[Graphics[Point/@walk1]]

It is more appropriate to use Module than Block in this example. For more on Module, Block, Line, Point, Graphics, and so on, see the documentation at http://documents.wolfram.com/.



Posted by: Richard Phillips

Plotting the data using ListPlot:


ListPlot[With[{t=80, k=4}, SeedRandom[1]; e = Table[{
Cos[2 Pi s/k], Sin[2 Pi s/k]}, {s, 0, k - 1}];
FoldList[Plus, {0, 0}, Table[e[[Random[Integer, {1, k}]]], {t}]]],
  PlotJoined->True,PlotRange->All,AspectRatio->Automatic]


The following code gives plots very similar to the ones in the book on page 330 (http://www.wolframscience.com/nksonline/page-330):


walkGraphic[data_]:=
  With[{c=Max[First/@Abs[data]]+2,r=Max[Last/@Abs[data]]+2},
    Graphics[{Table[Line[.5+{{-c-1,i},{c,i}}],{i,-r-1,r}],
        Table[Line[.5+{{i,-r-1},{i,r}}],{i,-c-1,c}],PointSize[.016],
        Point/@data,Line[data]}]]


Show[walkGraphic[With[{t=80,k=4}, SeedRandom[1]; e = Table[{
Cos[2 Pi s/k], Sin[2 Pi s/k]}, {s,0,k-1}];
FoldList[Plus, {0,0}, Table[e[[Random[Integer, {1,k}]]], {t}]]]],
  AspectRatio->Automatic]




Posted by: pietro

First of all thanks a lot for suggestion to All repliers,

Than I might ask:

- if is possible to impose specific constrains to the walk so that some cells in the grid cannot be occupied i.e. giving some “keep off “ coordinates.
- if is possible to have with a simple string a range of step displayed so that an animation is allowed without the fore coming math6 , but just by selecting separately each graph and than Animate Selected Graphics.

Again thanks a lot for previous and future help

P.G.



Posted by: Richard Phillips

Pietro,

As to your first question:

You can use the same method as the function selfAvoidingRandomWalk2D on thread http://forum.wolframscience.com/sho...s=&threadid=512 which includes the variable visitedQ. Any position {i,j} for which visitedQ[{i,j}]=Null will not be visited.
It is worthwhile studying the function to understand how it works, as it is simpler than it looks.

As to your second question:

To plot a movie generate a list of Graphics and then do  Scan[Show, list of graphics].

I'll leave you to work out the details.



Posted by: Richard J. Gaylord

i have two programs for generating 2D SAW's which are commonly used for polymers. you can create graphics or calculate the exponent of the mean square end-to-end distance.

i've tried pasting the code into a posting but it comes out looking like an unreadable mess.

if you e-mail me at gaylord@uiuc.edu, i will send you the notebook if you are willing to figure it out how to post the code to this forum



Posted by: Richard Phillips

Here are two notebooks based on a chapter from the book "Computer Simulations with Mathematica" by Richard Gaylord that he asked me to post.



Posted by: Richard Phillips

There are many references in NKS to random walks.

Typing "random walks" in the "Look up in index" of NKS|Online at http://www.wolframscience.com/nksonline/toc.html returns about 19 entries. For example, self-avoiding random walks are mentioned on page 978 http://www.wolframscience.com/nksonline/page-978a-text.

Although random walks are undoubtably interesting in their own right, from a pure NKS point of view it is perhaps more interesting to investigate systems that are purely deterministic. Mobile automata and Turing machines are obvious places to look. On page 75 (http://www.wolframscience.com/nksonline/page-75) a mobile automaton is given whose motion is seemingly random, with no injection of outside randomness into the rule.



Posted by: Richard J. Gaylord

as a theoretical polymer physicist for a few decades i am welll familiar with the differences between SAW and RW (in fact, SAW and RW have been my specialty)

minor correction to NKOS: an SAW's mean square end-to-end distance becaome the same as that of RW for d = 4, not just for d > 4. this is totally unsurprising to someone familiar with the field.

eg., the probability of a RW returning to its origin eventually is 1 in one- and two- dimensions but < 1 in 3 dimensions (the value depends on the lattice the walk is executed on).

btw - all the d = 4 means is that the probability of a a RW intersecting itself is essentially 0 in 4 dimensions which is perfectly understandable in view of dimensionality properties of a lattice walk.

other properties (eg., the symmetry of the shape) of of an SAW do not equal that of a RW in any dimensions.

anyway, what is the physical significance of a RW in more than 3 dimensions?

the NKS approach may find 'seemingly random' behavior arising from deterministic rules interesting. but that is a purely philosophical stance. it in no way invalidates the other philosophical view that the origin of some processes are random.

why should one choose determinism over randomness as a basis for studying rules? it is not 'simpler', whatever that means.

i think it would extremely interesting for NKS workersto focus on 2D CA's or even 3D rules if it wished to make a connection to the 'real world', whatever that is.



Posted by: Richard Phillips

I think we agree that both deterministic and non-deterministic (random) rules are interesting. The results of investigating one may be interesting in light of the results of investigating another of course!



Posted by: Richard J. Gaylord

of course you're right that stephen shows that complexity arises from one-dimensional rule systems even if the rule is deterministic.

the only realquestion is whether you can use 1D systems to model 2D and 3D 'real' systems.

i know that for certain systems where the process consists of deposition on successive layers (eg., seashells? and thin film vacuum deposition) you can but for other layer depositions (the snowflake) 2D CA's have had to bed employed.

it goes without saying (noticde how this phrase is always used just before proceeding to say whatever it is), that the 1D systems are well worth studying for thier own interest, aesthetics.

just as i have gone from studying RW and SAW for their appplication to rubber elastic behavior to now studying them for thier own interesting properties, even if they don't apply to the 'real' world. and i use computer experiments to study these systems as well since they are much to complicated to study analytical without having to make extreme approximations that destroy the essense of the system.

so there's alot in common between us.

i just wish steven hadn't blurred the matter by his applications chapters. maybe one day he can abstract from the BIG book a smaller book which excludes applications to physical systems....... and maybe even fewer 'I''s in it :) -though in this case the I would be more justifed since he did esential create the field of the study of the behavior of simple programs.





Forum Sponsored by Wolfram Research

© 2004-2009 Wolfram Research, Inc. | Powered by vBulletin 2.3.0 © 2000-2002 Jelsoft Enterprises, Ltd. | Disclaimer
vB Easy Archive Final - Created by Xenon and modified/released by SkuZZy from the Job Openings