MathGroup Archive 2003

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

Search the Archive

RE: Random Trouble

  • To: mathgroup at
  • Subject: [mg39204] RE: [mg39178] Random Trouble
  • From: "Donald A. Darling" <ddarling at>
  • Date: Mon, 3 Feb 2003 01:10:37 -0500 (EST)
  • Sender: owner-wri-mathgroup at

> I have a program which uses a random number in several places - the same
> number in a given run of the program. When I implement the program however
> the number changes in every new call to it.  I've tried to overcome this
> using "Which", "Hold", "Verbatim", and others, all to no avail.  Any help
> greatly appreciated.

Try using = instead of :=.

r = Random[];

Then use r throughout the program.  Using r := Random[] (or just Random[])
instead would cause a fresh random number to be sampled each time r appears.

Rob Pratt
Department of Operations Research
The University of North Carolina at Chapel Hill

rpratt at

Rob - This doesn't work for me.  If I try


I get a different sequence for F[5] each time I use it.  

Don Darling

  • Prev by Date: RE: Writing a program to hunt for a prime between n^2 and (n+1)^2
  • Next by Date: RE: RealOnly
  • Previous by thread: Re: Random Trouble
  • Next by thread: RE: Random Trouble