Re: Creating table with multiple lists

*To*: mathgroup at smc.vnet.net*Subject*: [mg7575] Re: [mg7510] Creating table with multiple lists*From*: "David B. Wagner" <dbwagner at princon.com>*Date*: Sun, 15 Jun 1997 16:33:08 -0400 (EDT)*Organization*: Principia Consulting*Sender*: owner-wri-mathgroup at wolfram.com

C. Woll wrote: > > On Sat, 7 Jun 1997, 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. > > You can generate a random walk using NestList: NestList[#+Random[z]&,0,t] The second argument specifies the starting point for the iteration. Note that this expression returns a list of length t+1, where the first element in the list is 0. If this is undesireable, then instead use: NestList[#+Random[z]&,Random[z],t-1] Now you can generate as many random walks as you want with Table[NestList[...], {somenumber}] -- Dave Wagner Principia Consulting http://www.princon.com/princon/ Voice: (500) PRN-CPIA or (303) 258-9178 Fax: (303) 258-3859