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

  • To: mathgroup at
  • Subject: [mg19418] Re: [mg19353] Simulation...Ooops
  • From: "Mark E. Harder" <harderm at>
  • Date: Mon, 23 Aug 1999 13:57:24 -0400
  • Sender: owner-wri-mathgroup at

    Luckily, I decided to plot several runs of our simulation, and all I
could get were Bear Markets!  I made a programming error in ranStep[] which
caused this.  Here's a fix which behaves better:

ranStep[]:= (sample=Random[Real,{0.,1.}];
    If[sample>N[5/6,20],Return[1],Return[0] ] ]

The key change is only calculating the random number once per function call.
The other changes I made were:
1. Increased precision in calculating partitions to 20-digits (probably not
2. re-seeding the generator with time-of-day.

Also, I run the following to plot results:

ListPlot[Transpose[plotData ],Frame->True ]

Buena Suerte!

-----Original Message-----
From: Mark E. Harder <harderm at>
To: mathgroup at
<mathgroup at>
Subject: [mg19418] Re: [mg19353] Simulation

>    First, replace the Random[Integer,...] function with a user-defined
>function ranStep, which returns -1 and 1 1/6 of the time and 0 the
>of the times (Press, "Numerical Recipes in Fortran" describe this
>method of converting a uniform random distribution to one with unequal
>  Random[Real,{0.,1.}]<N[1/6],Return[-1],
>   If[Random[Real,{0.,1.}]>N[5/6],Return[1],Return[0] ] ]
>Then use it in the statement you already wrote:
>  4.97,4.97,4.96,4.96,4.97,4.96,4.96,4.95,4.95}
>-----Original Message-----
>From: Roberto Diego <r-diego at>
To: mathgroup at
>To: mathgroup at <mathgroup at>
>Date: Friday, August 20, 1999 9:41 PM
>Subject: [mg19418] [mg19353] Simulation
>>Hi there,
>>I need help on how the expression:
>>could be modified in order to get -1 with probability 1/6, 0 with p 4/6
>>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: Up-Values with GroebnerBasis
  • Next by thread: Please help me! (Warnings and Messages...)