MathGroup Archive 1999

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

Search the Archive

Re: Simulation

  • To: mathgroup at
  • Subject: [mg19427] Re: Simulation
  • From: tdelling at (Tim Dellinger)
  • Date: Mon, 23 Aug 1999 13:57:30 -0400
  • Organization: University of Illinois at Urbana-Champaign
  • References: <7pl679$>
  • Sender: owner-wri-mathgroup at

"Roberto Diego" <r-diego at> writes:

>I need help on how the expression:


>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.


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                      
tdelling at

  • 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