[Rd] bug with rpois (PR#9106)
dolive at math.siu.edu
dolive at math.siu.edu
Thu Jul 27 19:41:53 CEST 2006
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
More information about the R-devel
mailing list