[R] Strange means of numbers drawn from rpois

Alan Arnholt arnholt at math.appstate.edu
Wed Nov 8 15:55:23 CET 2000


Kjetil,

I get "expected" results using a windows machine version 
1.1.1.


> sapply(1:15, function(n) mean(rpois(1000000, n)))
 [1]  1.000284  1.999766  3.001319  4.000618  5.000408  6.003184  7.000026  7.997165  9.000461  9.514773 11.000396
[12] 12.128740 13.160210 14.177194 15.193355
> sapply(1:15, function(n) mean(rpois(1000000, n)))
 [1]  1.000726  2.000776  3.000708  4.000043  5.001959  6.001235  7.002085  7.998147  9.000528  9.901534 10.999140
[12] 12.124794 13.152148 14.182332 15.007930
> sapply(1:15, function(n) mean(rpois(1000000, n)))
 [1]  1.000320  2.001331  3.002032  4.004577  4.999679  6.000778  6.997700  8.002213  9.005890  9.764240 10.786886
[12] 11.822689 12.863624 13.904637 15.000833
>  sapply(1:15, function(n) mean(rpois(100000, n)))
 [1]  1.00049  1.99307  2.99624  3.99277  5.00063
 [6]  6.00018  6.99672  8.01585  8.98921  9.76499
[11] 10.76767 11.78713 12.82248 13.85002 14.89385
>  sapply(1:15, function(n) mean(rpois(100000, n)))
 [1]  0.99788  2.00799  3.00712  3.98751  4.99152
 [6]  5.99747  7.01120  7.99749  9.00031  9.73359
[11] 10.75011 12.00378 13.11141 14.14407 15.17481
>  sapply(1:15, function(n) mean(rpois(100000, n)))
 [1]  1.00198  1.98872  3.00582  3.99331  4.99453
 [6]  6.01429  6.99885  7.98966  8.99976  9.87061
[11] 10.90451 11.99415 13.13388 14.15692 15.16398
>  sapply(1:15, function(n) mean(rpois(100000, n)))
 [1]  0.99634  1.99840  3.00492  3.99907  4.99878
 [6]  6.00134  7.00225  7.98363  8.99210  9.85822
[11] 10.89415 12.00827 13.12437 14.16350 14.99912



On Wed, 8 Nov 2000 15:09:24 +0100 (MET) Kjetil Kjernsmo 
<kjetil.kjernsmo at astro.uio.no> wrote:

> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

----------------------
Alan T. Arnholt
Associate Professor
Dept. of Mathematical Sciences
TEL: (828) 262-2863
FAX: (828) 265-8617
arnholt at math.appstate.edu

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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