Re: [S] identical numbers from rnorm()

Alan Zaslavsky (
Wed, 18 Mar 1998 16:27:09 -0500 (EST)

> From: "Jacob A. Wegelin" <>
> Just now I made the following little discovery. If you
> (1) call rnorm() within a function, say, junkfn()
> (2) halt junkfn() with control C
> (3) call junkfn() again right away
> then the "random" number returned by rnorm() within junkfn() is identical
> to what was returned at the previous call to junkfn(). Evidently, halting
> a function with control C keeps .Random.seed from being updated.

Assignments made during the evaluation of an expression are not committed
until the end of the evaluation (unless forced with synchronize()) so if
the evaluation fails, the assignments are cancelled. This includes the
assignment of updated values to .Random.seed. This is actually a pretty
good example for which this is a desirable feature. If you run a function
which uses some random numbers and it crashes, then when you debug you
would like to restart it with the same random numbers, not with a different
set of numbers which might not replicate the behavior.
This message was distributed by To unsubscribe
send e-mail to with the BODY of the
message: unsubscribe s-news