Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*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 1999

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

Search the Archive

Re: Simulation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19380] Re: [mg19353] Simulation
  • From: "Andrzej Kozlowski" <andrzej at tuins.ac.jp>
  • Date: Mon, 23 Aug 1999 13:57:04 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

First, what is Table doing in 

Table[NestList[#+0.01*Random[Integer,{-1,1}]&,5,1000]]

There are of course lots of ways to modify your code to do what you want.
Here is one that immediately comes to my mind:


p := Module[{v = Random[]}, Which[v < 1/6, 1, v < 5/6, 0, True, -1]]

data = NestList[# + 0.01*p &, 5, 20];

Slightly less obviously you can also use

p := Which[Random[] < 1/6, 1, Random[] < 1/5, -1, True, 0]

and lots of other ways.

--
Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp
http://eri2.tuins.ac.jp


----------
>From: "Roberto Diego" <r-diego at develnet.es>
To: mathgroup at smc.vnet.net
>To: mathgroup at smc.vnet.net
>Subject: [mg19380] [mg19353] Simulation
>Date: Sat, Aug 21, 1999, 4:09 AM
>

> Hi there,
>
> I need help on how the expression:
>
> data=Table[NestList[#+0.01*Random[Integer,{-1,1}]&,5,1000]];
>
> could be modified in order to get -1 with probability 1/6, 0 with p 4/6 and
> 1 with p 1/6 instead of 1/3,1/3,1/3
>
> Thanks a lot
>
> Roberto Diego
> Sociedad de Bolsas
>
>
>
> 


  • Prev by Date: Re: Simulation
  • Next by Date: Re: Magnitude of Vector
  • Previous by thread: Re: Simulation
  • Next by thread: Re: Simulation