MathGroup Archive 2009

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

Search the Archive

Re: random walk visualization

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105258] Re: random walk visualization
  • From: Norbert Marxer <marxer at mec.li>
  • Date: Wed, 25 Nov 2009 06:21:21 -0500 (EST)
  • References: <heimn8$5mc$1@smc.vnet.net>

On Nov 25, 8:35 am, Alexei Boulbitch <Alexei.Boulbi... at iee.lu> wrote:
> 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.

Hello

All you have to do is to include a step size in Animate: i.e.  {i, 2,
1000, 1}

This works.

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,1}
 ]

Best Regards
Norbert Marxer


  • Prev by Date: Re: random walk visualization
  • Next by Date: Re: part assigned sequence behavior puzzling
  • Previous by thread: Re: random walk visualization
  • Next by thread: Re: Re: random walk visualization