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. I use Version 1.1.1 (August 15, 2000) Of R on a Dell OptiPlex computer with the Windows XP Professional operating system. Has this bug been fixed in later versions? (I found another reported rpois bug, but it appears to be different and to have been fixed : rpois gives a large number repeatedly kjetikj at astro.uio.no Tue, 15 Feb 2000 12:18:28 +0100 (MET)) The following output helps illustrate the bug. > 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] 9.594 9.552 9.538 9.448 9.438 9.544 9.630 9.474 9.568 9.700 9.720 9.642 [13] 9.624 9.328 9.420 9.492 9.368 9.674 9.528 9.436 9.296 9.502 9.260 9.440 [25] 9.572 9.698 9.372 9.458 9.532 9.570 9.534 9.528 9.572 9.536 9.234 9.416 [37] 9.400 9.370 9.438 9.628 9.672 9.738 9.454 9.478 9.438 9.496 9.672 9.308 [49] 9.632 9.386 9.842 9.452 9.632 9.460 9.660 9.688 9.486 9.492 9.576 9.664 [61] 9.290 9.300 9.304 9.472 9.618 9.480 9.458 9.558 9.782 9.532 9.198 9.258 [73] 9.384 9.630 9.520 9.646 9.554 9.406 9.390 9.554 9.610 9.382 9.604 9.638 [85] 9.304 9.586 9.848 9.434 9.460 9.644 9.450 9.542 9.502 9.446 9.828 9.364 [97] 9.664 9.628 9.704 9.354 Notice that all 100 sample means of size 500 are less than 10, about half should be larger. The following commands also suggest that the rpois function is biased for theta > 10. > hist(zsim(theta=1)$z) > hist(zsim(theta=10)$z) > hist(zsim(theta=100)$z) > hist(zsim(theta=1000)$z) Best Regards, David Olive dolive at math.siu.edu
Technically speaking, your version of R is from the previous century. You might want to check with a more recent version before reporting a bug. -roger dolive at math.siu.edu wrote:> 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. > > I use Version 1.1.1 (August 15, 2000) Of R on a Dell OptiPlex computer > with the > Windows XP Professional operating system. > > Has this bug been fixed in later versions? > > (I found another reported rpois bug, but it appears to be different > and to have been fixed : > > rpois gives a large number repeatedly > kjetikj at astro.uio.no > Tue, 15 Feb 2000 12:18:28 +0100 (MET)) > > > > The following output helps illustrate the bug. > > > 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] 9.594 9.552 9.538 9.448 9.438 9.544 9.630 9.474 9.568 9.700 9.720 9.642 > [13] 9.624 9.328 9.420 9.492 9.368 9.674 9.528 9.436 9.296 9.502 9.260 9.440 > [25] 9.572 9.698 9.372 9.458 9.532 9.570 9.534 9.528 9.572 9.536 9.234 9.416 > [37] 9.400 9.370 9.438 9.628 9.672 9.738 9.454 9.478 9.438 9.496 9.672 9.308 > [49] 9.632 9.386 9.842 9.452 9.632 9.460 9.660 9.688 9.486 9.492 9.576 9.664 > [61] 9.290 9.300 9.304 9.472 9.618 9.480 9.458 9.558 9.782 9.532 9.198 9.258 > [73] 9.384 9.630 9.520 9.646 9.554 9.406 9.390 9.554 9.610 9.382 9.604 9.638 > [85] 9.304 9.586 9.848 9.434 9.460 9.644 9.450 9.542 9.502 9.446 9.828 9.364 > [97] 9.664 9.628 9.704 9.354 > > Notice that all 100 sample means of size 500 are less than 10, about > half should be larger. > > The following commands also suggest that the rpois function is biased > for theta > 10. > > > hist(zsim(theta=1)$z) > > hist(zsim(theta=10)$z) > > hist(zsim(theta=100)$z) > > hist(zsim(theta=1000)$z) > > > Best Regards, > > > David Olive > dolive at math.siu.edu > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- Roger D. Peng | http://www.biostat.jhsph.edu/~rpeng/
<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 ...
On Thu, 27 Jul 2006, Ben Bolker wrote:> <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: >In fact, fixed in 1.2.0, in December 2000. -thomas Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle