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

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: [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


  • Prev by Date: Re: combinatorics problem
  • Next by Date: Re: Just another bug in MMA 3.0
  • Previous by thread: Re: Creating table with multiple lists
  • Next by thread: Need a new type of Hold