From p.dalgaard at biostat.ku.dk  Fri Apr 25 15:06:23 2003
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard BSA)
Date: Fri Apr 25 14:03:36 2003
Subject: [Rd] Kinderman-Ramage (PR#2846)
In-Reply-To: <200304251119.h3PBJ4pD015872@pubhealth.ku.dk>
References: <200304251119.h3PBJ4pD015872@pubhealth.ku.dk>
Message-ID: <x23ck6u6gw.fsf@biostat.ku.dk>

leydold@statistik.wu-wien.ac.at writes:

> Hi,
> 
> Our department has detected a bug in the implementation of the
> Kinderman-Ramage generator for normal random variates in version
> 1.7.0, which can be seen from the below R session.
> (Consecutive calls for chisq.test(...) always gives p-values very
> close to 0.)
> We have already encountered this bug in version 1.6.2
> 
> The error is in file 
> R-1.7.0/src/nmath/snorm.c
> 
> Here is a patch for this file to correct the error
> (the added two lines are crucial):

Thanks. Both look like transcription errors. What was the source of
the corrected constants? The JASA paper cited in snorm.c? 

(Another way of seeing the effect is

 m <- sapply(1:50,function(i)table(trunc(100*pnorm(rnorm(1e6)))))
 matplot(m,type="l")

Two small, but clear, spikes at around 30 and 70 can be seen. The
effect is not seen with the Inversion method, which is the default in
R-1.7.0.) 


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


[Rd] Kinderman-Ramage (PR#2846)
Peter Dalgaard BSA