Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: zigzag & random walk

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22334] Re: [mg22292] zigzag & random walk
  • From: "Pascal BAES" <pascal.baes at skynet.be>
  • Date: Fri, 25 Feb 2000 21:13:24 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com


>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 ?

(*Skuse my Destroystyle: I'm Frenchy and Artist.(Not American or German
Scientist)
Cf that old stuf Maeder Package "Random Walk.m"
I used very much it to produce NoisySound (MassOfNonSinusoidaleVibration)
and CrispyAnimation
Thinks to eternal Mader...
there somme modified version, Whith "Seed control"*)

(*MadWalk1D:*)
grange = N[{0, 2Pi}];
randomDelta1 := With[{dir1 = Random[Real, grange]},Sin[ dir1]];
MadWalk1D[i_Integer,n_Integer] :=
      (SeedRandom[i]; NestList[ # + randomDelta1&,0, n ]);

(*Thats Integer one: RandIntWalk*)
RandIntWalk[i_Integer,n_Integer] :=(SeedRandom[i];
    NestList[(#+(-1)^Random[Integer])&,0,n])

(*thats 2D one:
MadWalk2D*)
grange = N[{0, 2Pi}];
randomDelta2 := With[{dir1 = Random[Real, grange]},{Sin[ dir1],Cos[dir1]}];
MadWalk2D[i_Integer,n_Integer] :=
      (SeedRandom[i]; NestList[ # + randomDelta2&,{0,0}, n ]);

(*Thats 2D one funny, from Point[{a,b}] to Point[{c,d}]
MadWalk2DFromTo*)
MadWalk2DFromTo[i_Integer,n_Integer,{a_Real,b_Real},{c_Real,d_Real}]:=
  Plus[Join[{{a,b}},
      N[MapThread[
          Times[Plus[#1,#2],#3]&,{Table[{a,b},{Length[MadWalk2D[i,n]]}],
            MadWalk2D[i,n],
            Table[((1+Cos[k Pi])/2),{k,1/Length[MadWalk2D[i,n]],1,
                1/Length[MadWalk2D[i,n]]}]}]]],
    Reverse[Join[{{c,d}},
        N[MapThread[
            Times[Plus[#1,#2],#3]&,{Table[{c,d},{Length[MadWalk2D[i,n]]}],
              MadWalk2D[i,n],
              Table[((1+Cos[k Pi])/2),{k,1/Length[MadWalk2D[i,n]],1,
                  1/Length[MadWalk2D[i,n]]}]}]]]]];

(*MadWalk3D*)
grange = N[{0, 2Pi}];
randomDelta3 := 
  With[{dir1 = Random[Real, grange],dir2 = Random[Real, grange]},{
      Cos[dir1] Cos[dir2],Cos[dir1]Sin[ dir2],Sin[ dir1]}];
MadWalk3D[i_Integer,n_Integer] :=
      (SeedRandom[i]; NestList[ # + randomDelta3&,{0,0,0}, n ]);

(*ex1:*)
ListPlay[Join[Flatten[MapThread[List,Table[MadWalk1D[i,200],{i,0,90}]]],
Reverse[Flatten[MapThread[List,Table[MadWalk1D[i,200],{i,0,90}]]]]]];

(*ex2:*)
Show[Graphics[{Table[Line[MadWalk2D[i,1000]],{i,110,115}],
{PointSize[0.02],  RGBColor[1,0,0] ,Point[{0,0}]}}]];

(*ex3:*)
A={-10.,-10.};
B={10.,10.};
Table[Show[
    Graphics[{
        Table[Line[MadWalk2DFromTo[i,pe,A,B]],{i,0,10}],{PointSize[0.05], 
          RGBColor[1,0,0] ,Point[A]},{PointSize[0.05], RGBColor[0,0,1] ,
          Point[B]}}],PlotRange->{{-15,15},{-15,15}}],{pe,20,50}]

(*ex4:*)
Table[Show[
    Graphics3D[{
        Table[Line[MadWalk3D[i,n]],{i,0,99}],{PointSize[0.2], 
          RGBColor[1,0,0] ,Point[{0,0,0}]}}],
    PlotRange->{{-10,10},{-10,10},{-10,10}}],{n,10,50,2}];

Hope thats help
Pascal BAES
La Pose Longue
PataPhysik Lab




  • Prev by Date: Riemann Sheets
  • Next by Date: Re: Legend Package
  • Previous by thread: Re: zigzag & random walk
  • Next by thread: Re:Integrate with If--NDSolve