[R] unexpected behaviour of rnorm()

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Tue Nov 26 22:25:20 CET 2002


Robin Hankin <r.hankin at auckland.ac.nz> writes:

> 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. 
> 
> anyone got an explanation?

This is also illuminative:

  plot(sort(sapply(rep(2000,2000),f)),type="l")

We've seen odd behaviour of max(rnorm()) with the default random generators
before. Switching to RNGkind("Wichmann-Hill") made the effect
disappear here. Same thing switching the normal generator with
RNGkind("Marsaglia-Multicarry","Box-Muller").

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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