From p.dalgaard@biostat.ku.dk  Wed Nov  8 17:51:59 2000
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 08 Nov 2000 18:51:59 +0100
Subject: [Rd] Re: [R] Strange means of numbers drawn from rpois (PR#730)
In-Reply-To: Peter Dalgaard BSA's message of "08 Nov 2000 17:51:04 +0100"
References: <200011081623.RAA06926@pubhealth.ku.dk> <x2ofzqtnk7.fsf@blueberry.kubism.ku.dk>
Message-ID: <x2itpytkqo.fsf@blueberry.kubism.ku.dk>

Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk> writes:

> kjetil.kjernsmo@astro.uio.no writes:
> 
> > On 8 Nov 2000, Peter Dalgaard BSA wrote:
> > 
> > >Done...
> > 
> > Great!
> 
> However, be careful not to reply to the version of the mail without a
> PR# if there's a Cc: to R-bugs. Now there are *two* reports in the
> repository...
> 
> I've poked around a bit and it seems that the problem has to do with
> the code that tries to save time by reusing calculations if mu ==
> muprev: 
> 
> > range(sapply(1:2000, function(n) mean(rpois(10000, c(15,15+1e-8)))))
> [1] 14.8692 15.1200

AHA! Spotted, I think. It is possible to return from rpois in step N,
in which case the initialisations in step P are not performed in that
invokation and not the next times either because it thinks that it has
been done previously.

I'm not quite sure what is the best way to fix it, though. Either kill
muprev when exiting in step N, or make the initialisations currently
in step P before entering step N. Or maybe save two versions of muprev
.. yes, that might be it - will try.
-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] Re: [R] Strange means of numbers drawn from rpois (PR#730)
Peter Dalgaard BSA