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: [mg19427] Re: Simulation
  • From: tdelling at ews.uiuc.edu (Tim Dellinger)
  • Date: Mon, 23 Aug 1999 13:57:30 -0400
  • Organization: University of Illinois at Urbana-Champaign
  • References: <7pl679$cdc@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Roberto Diego" <r-diego at develnet.es> writes:


>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


Well, then here's help:

1) You could use Round[] on your random integers, and put in a pre-factor
to re-scale the probabilities of getting 0 or 1 after rounding.

or

2) Make a list of 0's and 1's in the right proportions, and randomly
pick a list element instead of using Random[Integer,{-1,1}].

So there are two ideas.  Hope they help.
Oh, and if want the answers, these should work:

1) Table[NestList[#+0.01*Round[0.75 Random[Real,{-1,1}]]&,5,1000]]
2) Table[NestList[#+0.01*{-1,0,0,0,1}[[Random[Integer,{1,5}]]&,5,100]]

My guess is that #2 is slightly faster.

--
Tim Dellinger                                www.ews.uiuc.edu/~tdelling
tdelling at uiuc.edu


  • Prev by Date: Re: Control Function With NDsolve
  • Next by Date: Re: Finding Solution to Set of Equations with Inequality Constraints
  • Previous by thread: Re: Simulation
  • Next by thread: Re: Re: Simulation