Skip to content

Bug in rnorm. (PR#1664)

4 messages · Duncan Murdoch, Peter Dalgaard, Brian Ripley

#
Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk> writes:
No I do not! My quick check code took the square of the max rather
than the max of the square...

With your script, I get a nice horizontal line both with 1.4.0 and
1.5.0-patched.

(RedHat Linux 7.1 on a PC)
#
On Fri, 14 Jun 2002 00:39:58 +0200 (MET DST), p.dalgaard@biostat.ku.dk
wrote:
I get what Rolf described in 1.5.0-patched for Windows with the
default generators: 

RNGkind()
[1] "Marsaglia-Multicarry" "Kinderman-Ramage"  

I switched to the Ahrens-Dieter normal RNG (using
RNGkind(,'Ahrens-Dieter')), and things were fine.  

Keeping the default normal generator but switching to the
Mersenne-Twister uniform also fixed it:
[1] "Mersenne-Twister" "Kinderman-Ramage"

Is it possible you're not using the default generators?  If you are,
this is quite weird, because we're on the same hardware.  Why would
the OS or compiler matter in a calculation like this??

Duncan Murdoch
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Duncan Murdoch <dmurdoch@pair.com> writes:
Now this is pretty darn odd....

This is what happened to me yesterday with 1.4.0:

[Previously saved workspace restored]
[1] 39
[1] 37
[1] 63
[1] 50
[1] 51
[1] 51

This morning, I get
[1] "Marsaglia-Multicarry" "Kinderman-Ramage"
[1] 27
[1] 23
[1] 29
[1] 29

with the SAME version of R. The only difference is the startup
directory, and hence the saved workspace. This contains:
[1] ".Random.seed" "x"            "y"
[1]     0 25300 11635 10783

..whereas 1.5.0 which now again shows trouble has
[1]         1 196857153 319227924

and 1.4.0 in a clean dir has this after a few iterations of the above
[1]          1 1297109091   47580530


Oho! I think I get it: the "1" in the seed actually *defines* the RNG,
no matter what RNGkind() is telling me??
#
Just so we understand:
[1] "Marsaglia-Multicarry" "Kinderman-Ramage"
[1] "Marsaglia-Multicarry" "Kinderman-Ramage"
[1] 0.03381877
[1] "Wichmann-Hill"    "Kinderman-Ramage"

?RNGkind says

`RNGkind' returns a two-element character vector of the RNG and
normal kinds in use before the call,
                    ^^^^^^
However, any use of the random number generators themselves loads
.Random.seed (if it exist), and that will set the types of random
numbers in use.  So if a user changes .Random.seed (for example by
loading a saved workspace) the types will change.  RNGkind() reports
retrospectively (as it is documented to), not prospectively.

Now we could alter RNGkind() to read in the current .Random.seed (if there
is one) although it is a bit tricky to decide what to do if the value is
invalid.  (The random-number generation code throws an error and
expects thse user to fix, e.g  remove, .Random.seed.)
On 14 Jun 2002, Peter Dalgaard BSA wrote: