MathGroup Archive 2000

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

Search the Archive

Re: zigzag & random walk

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22309] Re: zigzag & random walk
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Thu, 24 Feb 2000 03:01:24 -0500 (EST)
  • References: <88vtt5$mcg@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Arthur

The following version works with any number of dimensions. The walk starts
at s (default {0,0}), and stops after n steps (default 40) or when the
function b gives False (default , always True).

RandomWalk[s_List:{0, 0}, n_Integer:40, b_:(True &)] :=
  NestWhileList[# + (Random[] (#/Sqrt[#.#]) &[
            Table[Random[Real, {-1, 1}], {Length[s]}]]) &,
    s,
    b, {1, 1}, n
    ]

Show[Graphics3D[Line[
      RandomWalk[{0, 0, 0}, 100, Sqrt[ #.#] < 5 &]
      ]], Boxed -> True, Axes -> True, PlotRange -> All]

Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565



"Arthur Habraken" <ArthurHabraken at yahoo!.com> wrote in message
news:88vtt5$mcg at smc.vnet.net...
> I'm searching for the formulas known as ZigZag and Long Random Walk.
> Can anyone help me to get the formulas or to a place where I can find
> more in formation ?
>
> thanks a lot,
>
>
> Arthur Habraken
> a.habraken at delion.com
>
>



  • Prev by Date: Re: J/Link Examples ??
  • Next by Date: Re:Integrate with If--NDSolve
  • Previous by thread: Re: Transformation Methods for Pi
  • Next by thread: Re: zigzag & random walk