[Rd] BUG report : 'rnorm' (LINUX, R 1.6.2) (PR#2682)
ripley at stats.ox.ac.uk
ripley at stats.ox.ac.uk
Tue Mar 25 12:49:51 MET 2003
Try R-devel, as this has already been changed (after several related
reports).
Be aware though that *all* pseudo-random number generators have some
deficiencies, and R does provide you with many other choices.
On Tue, 25 Mar 2003 tirler at statistik.wu-wien.ac.at wrote:
> Dear colleague,
>
> unfortunately 'rnorm' does not create normal distributed numbers as
> you can see with following histogramm:
>
> > hist(rnorm(1000000),breaks=100)
>
> and
>
> > hist(pnorm(rnorm(1000000)),breaks=100)
>
> I have done several chi^2-tests which have all failed:
>
> > chi2unif<- function(x,N)
> > {
> > anz=length(x)
> > f0<-rep(anz/N,times=N)
> > fi<-(hist(x,g<-seq(length(N+1),from=0, by=1/N), plot=FALSE)[2])
> > fin<-fi[[1]][1:N]
> > chi2=sum( ((f0-fin)^2)/f0 )
> > pchisq(chi2,N-1)
> > }
>
> > chi2unif(x<-pnorm(rnorm(1000000)),100)
>
> The result is the p-value of a goodness of fit test (chisquare test).
> It should be a uniform random number in [0,1].
> However, if this test is repeated, one almost every time gets an
> number near one (0.99...)
>
> This problems happens only by using normal.kind="Kindermann-Ramage"
> (the default). This bug also appears in all random variate generation
> that depend on 'rnorm', like 'rgamma'.
>
> With regards,
> Günter Tirler
>
>
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel
mailing list