[R] rnorm??
Liaw, Andy
andy_liaw at merck.com
Tue Feb 22 01:40:36 CET 2005
I don't see anything suspicious (R 2.0.1 on Windows XP Pro, Pentium M):
> set.seed(1)
> res <- replicate(50, {x <- rnorm(1e6); c(sum(x < -4), sum(x > 4))})
> apply(res, 1, summary)
[,1] [,2]
Min. 20.0 21.00
1st Qu. 27.0 30.00
Median 30.0 33.50
Mean 30.7 33.74
3rd Qu. 34.0 37.00
Max. 42.0 48.00
> pnorm(-4) * 1e6
[1] 31.67124
> res2 <- replicate(50, {x <- qnorm(runif(1e6)); c(sum(x < -4), sum(x >
4))})
> apply(res2, 1, summary)
[,1] [,2]
Min. 18.00 19.00
1st Qu. 30.00 27.25
Median 32.00 31.00
Mean 32.60 31.38
3rd Qu. 35.75 35.00
Max. 47.00 45.00
> RNGkind()
[1] "Mersenne-Twister" "Inversion"
Andy
> From: Scholz, Fritz
>
> I am wondering whether there is a bug in rnorm.
> When generating rnorm(1000000) and counting
> the cases > 4 and the cases < (-4) I get rather
> unexpectedly low counts for the latter. The problem goes away
> when using qnorm(runif(1000000)).
>
> Fritz Scholz, PhD
> Applied Statistics Group
> Boeing Phantom Works
> fritz.scholz at pss.boeing.com
> 425-865-3623
> Tu/We 206-542-6545 (most likely)
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
More information about the R-help
mailing list