MathGroup Archive 1997

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

Search the Archive

Re: Creating table with multiple lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg7525] Re: [mg7510] Creating table with multiple lists
  • From: "w.meeussen" <w.meeussen.vdmcc at vandemoortele.be>
  • Date: Tue, 10 Jun 1997 23:18:00 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Ed,
you didn't say, but it needs:
In[1]:=<<Statistics`NormalDistribution`
*****************************************************************************
In[2]:=Table[FoldList[Plus,0,Table[z,{10}]],{3}]

Out[2]=
{{0, -0.158061, -1.03532, -0.216971, -0.723981, -0.605499, -1.24241,
0.217406, 0.518954, 0.691122, 1.66242}, {0, 0.069052, -0.805858, 0.139529,
1.72578, 2.75487, 2.803, 2.64175, 
1.44049, 0.632521, 2.71134}, {0, 1.03335, 1.19412, 1.19995, 1.30228,
2.70029, 2.53024, 3.24825, 3.84778, 
3.493, 2.83582}}
******************************************************************************

define z using a delayed assignment, generating a fresh random everytime:
z:=Random[NormalDistribution[0,1]]
now, the bit "Table[z,{10}] gives you 10 fresh random (Gaussian) numbers

The bit "FoldList[operation, starter, LIST]" is well documented;

envelop the whole schtuk in a table, and thats'it.
If you want to flatten the resulting 2-dim table to a 1-dim list, the use
Flatten[%].

my pleasure,

wouter.





At 03:49 7-06-97 -0400, Ed McCarthy wrote:
>I'm trying to create a table with multiple lists that have the same
>starting value. Here's the basic code:
>
>z=NormalDistribution[0,1];
>t=100; x=0;
>path=Table[x=x+Random[z], {t}]
>
>This code will generate a continuous path starting at x=0, which is what I
>want. My goal is to repeat the process multiple times, but starting each
>new iteration with x=0 while storing each path. This For loop works, but
>I'm looking for a better way to do it.
>
>z=NormalDistribution[0,1];
>list1={};
>For[i=0, i<10, i++,
>t=100; x=0;
>path=Table[x=x+Random[z],{t}];
>AppendTo[list1,path]]
>
>Does any have suggestions for generating multiple paths (with x reset to 0
>for each iteration) with a functional approach? I'd like to avoid AppendTo
>if possible.Thanks--any comments appreciated.
>
>Ed McCarthy
>
>
>
>

Dr. Wouter L. J. MEEUSSEN
eu000949 at pophost.eunet.be
w.meeussen.vdmcc at vandemoortele.be



  • Prev by Date: Re: Changing PDE to ODE
  • Next by Date: Re: Won't Read Entire Soundfile; Why?
  • Previous by thread: Re: Creating table with multiple lists
  • Next by thread: Re: Creating table with multiple lists