[R] unexpected behaviour of rnorm()

Thomas Lumley tlumley at u.washington.edu
Tue Nov 26 23:09:00 CET 2002


On Wed, 27 Nov 2002, Robin Hankin wrote:

> Hello everyone.
>
> If I do
>
> f <- function(n){max(rnorm(n))}
> plot(sapply(rep(5000,4000),f))   #[this takes my PC about 30 seconds]
>
> then I get something quite unexpected: gaps in the distribution.  For
> me, the most noticable one is at about 3.6.
>
> Do others get this?  Is it an optical illusion?  It can't be right,
> can it?  Or maybe I just don't understand the good ol' Gaussian very
> well.

This is substantially the same as PR#1664.  The Marsaglia-Multicarry and
Kinderman-Ramage options don't play nicely together in the extreme tails
of the Normal distribution.

Changing the Normal generator
  RNGkind(normal="Inversion")
  RNGkind(normal="Box-Muller")
or the underlying uniform stream
  RNGkind(kind="Wichmann-Hill")
  RNGkind(kind="Super-Duper")
gives better looking results.


	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list