[R] Strange means of numbers drawn from rpois
Kjetil Kjernsmo
kjetil.kjernsmo at astro.uio.no
Wed Nov 8 15:09:24 CET 2000
Dear all,
I think I must be going crazy.... If I do
> mean(rpois(1000000, 14))
I get:
[1] 13.50420
and again:
> mean(rpois(1000000, 14))
[1] 13.49896
> mean(rpois(1000000, 14))
[1] 13.50161
> mean(rpois(1000000, 15))
[1] 14.49250
> mean(rpois(1000000, 15))
[1] 14.49897
> mean(rpois(1000000, 14.5))
[1] 13.99689
> mean(rpois(1000000, 14.5))
[1] 13.9963
This was on a
platform alphaev6-dec-osf4.0e
major 1
minor 1.1
checking out on a
platform sparc-sun-solaris2.7
major 1
minor 1.0
I get the same
> mean(rpois(100000, 14.5))
[1] 14.00347
> mean(rpois(100000, 14.5))
[1] 14.00667
> mean(rpois(100000, 14.5))
[1] 14.00675
It's fishy, isn't it...? I have generated lots of numbers, but I haven't
seen anything like this before....
I have also done
> sapply(1:15, function(n) mean(rpois(1000000, n)))
[1] 1.000052 1.999150 2.996975 4.003843 4.996136 5.999065 6.999725
[8] 7.998869 9.003127 9.518397 10.512347 11.500405 12.510494 13.499788
[15] 14.504661
So, something happens at 10... And again:
> sapply(1:15, function(n) mean(rpois(1000000, n)))
[1] 1.000173 2.001639 2.997016 4.000163 5.000802 5.992751 6.999794
[8] 7.997315 8.998479 9.517824 10.508328 11.507336 12.501885 13.502146
[15] 14.496810
Starting with --vanilla gives pretty much the same result...
trying different RNGs:
> RNGkind("Mersenne")
> sapply(1:15, function(n) mean(rpois(1000000, n)))
[1] 1.000563 1.998802 2.998526 3.997537 4.999230 5.996591 6.999596
[8] 7.998982 9.000783 9.510220 10.509562 11.505009 12.505001 13.504522
[15] 14.500956
> RNGkind("Knut")
> sapply(1:15, function(n) mean(rpois(1000000, n)))
[1] 0.999031 2.000444 3.002296 3.997795 4.998880 5.995267 7.001894
[8] 7.999983 9.000267 9.513537 10.507142 11.502634 12.498944 13.498615
[15] 14.502410
After printing rpois (to see that I haven't replaced it with something
strange) and version, I call
> plot(sapply(1:15, function(n) mean(rpois(1000000, n))), t='l')
getting a plot that isn't a straight line, and then:
> sapply(1:15, function(n) mean(rpois(1000000, n)))
[1] 0.997961 1.999509 3.000748 3.999825 5.002983 6.004424 6.998825
[8] 7.997999 8.998341 9.766942 10.781751 11.817181 12.856154 13.900369
[15] 14.999378
and again:
> sapply(1:15, function(n) mean(rpois(1000000, n)))
[1] 0.998570 2.000155 2.999534 4.002987 4.997999 5.996326 6.996761
[8] 7.996728 8.997265 9.764972 10.793913 11.822874 12.859886 13.903846
[15] 15.000311
Weird....?
Best,
Kjetil
--
Kjetil Kjernsmo
Graduate astronomy-student Problems worthy of attack
University of Oslo, Norway Prove their worth by hitting back
E-mail: kjetikj at astro.uio.no - Piet Hein
Homepage <URL:http://www.astro.uio.no/~kjetikj/>
Webmaster at skepsis.no
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list