[Rd] bug with rpois (PR#9106)

Ben Bolker bolker at ufl.edu
Thu Jul 27 22:29:12 CEST 2006


 <dolive <at> math.siu.edu> writes:

> 
> 
> The R poisson random generator rpois appears to have a bug for
> theta 10 or larger. The sample mean of the pseudo variates is too
> small: sample mean approx theta - 0.5.
> 

  Certainly fixed by 2.3.1:

 zsim <- function(nc = 100, nr = 500, theta = 1)
+ {# check rpois function
+   x <- matrix(rpois(nr*nc, theta),nrow=nr,ncol=nc)
+   z<-apply(x,2,mean)
+   list(z=z)}
> zsim(theta=10)
$z
  [1] 10.064 10.084 10.338  9.848  9.740 10.052  9.954  9.960 10.080 10.062
 [11]  9.702  9.936  9.808 10.100  9.982  9.954  9.854 10.226  9.872 10.280
 [21] 10.236 10.116  9.992  9.904 10.116 10.168 10.144 10.018  9.982 10.016
 [31] 10.148 10.128 10.234 10.030  9.882  9.922 10.150 10.062 10.152  9.804
 [41] 10.178 10.106 10.092 10.080 10.112 10.012 10.074 10.276 10.086 10.048
 [51] 10.072 10.086 10.204  9.974 10.020 10.104  9.792 10.154 10.042 10.046
 [61]  9.882 10.014  9.654 10.126 10.068 10.040 10.094 10.250  9.854  9.966
 [71]  9.852  9.974  9.732  9.986  9.912 10.048  9.750 10.068 10.024  9.842
 [81]  9.640 10.114 10.238 10.138  9.876  9.750 10.310 10.026 10.024 10.132
 [91] 10.088  9.970 10.044  9.912  9.850 10.022  9.970 10.052  9.938  9.994

   it's surprising that such a large bug would have persisted
even up to version 1.1.1.  You should certainly upgrade your version,
but in the meantime you might try starting R in "vanilla" mode to
make sure you don't have a wonky local version of rpois or something
else lying around ...



More information about the R-devel mailing list