MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

random walk visualization

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105245] random walk visualization
  • From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
  • Date: Wed, 25 Nov 2009 02:34:33 -0500 (EST)

Dear Community,

I am making a demonstration for a lecture on random walk. This should 
show the random walk evolving in 2D. The following works nicely:

x := 0;
y := 0;
tab = Table[{x += RandomInteger[{-1, 1}],
    y += RandomInteger[{-1, 1}]}, {1000}];
imTab = Table[
   Show[{Graphics[{Blue, Line[tab[[1 ;; i]]]}],
     Graphics[{Red, Thick, Arrowheads[0.03],
       Arrow[{tab[[1]], tab[[i]]}]}]},
    PlotRange -> {{-40, 40}, {-40, 40}}],   {i, 2, 1000}
   ];
ListAnimate[imTab]

It however, takes a lot of memory, and few minutes to generate the 
graphics list. That is too long.

If I could directly Animate the graphics instead of generating initially 
a graphics list, it would be much faster. This intends to do such a 
direct animation:

x := 0;
y := 0;
tab = Table[{x += RandomInteger[{-1, 1}],
    y += RandomInteger[{-1, 1}]}, {1000}];
Animate[Show[{Graphics[{Blue, Line[tab[[1 ;; i]]]}],
   Graphics[{Red, Thick, Arrowheads[0.03],
     Arrow[{tab[[1]], tab[[i]]}]}]},
  PlotRange -> {{-40, 40}, {-40, 40}}],   {i, 2, 1000}
 ]

But it does not work. I cannot understand the reason. Any idea?

Regards, Alexei

-- 
Alexei Boulbitch, Dr., habil.
Senior Scientist

IEE S.A.
ZAE Weiergewan
11, rue Edmond Reuter
L-5326 Contern
Luxembourg

Phone: +352 2454 2566
Fax:   +352 2454 3566

Website: www.iee.lu

This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you are not the intended recipient and have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal from your system. Thank you for your co-operation.




  • Prev by Date: Re: Color depth - Wikipedia, the free encyclopedia
  • Next by Date: Re: Bug associated with Graphics3D???
  • Previous by thread: Silent errors in Mathematica options, I think it should be detected.
  • Next by thread: Re: random walk visualization