Skip to content

Strange means of numbers drawn from rpois (PR#730)

4 messages · Kjetil Kjernsmo, Peter Dalgaard

#
On 8 Nov 2000, Peter Dalgaard BSA wrote:

            
Great!
Yes, it does that here too.... The following is a verbatim excerpt from my
session:
[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
function (n, lambda)
.Internal(rpois(n, lambda))
_
platform alphaev6-dec-osf4.0e
arch     alphaev6
os       osf4.0e
system   alphaev6, osf4.0e
status
major    1
minor    1.1
year     2000
month    August
day      15
language R
[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 from looking at 11, it is apparent that something happened... Also, by
inspecting the graph produced by plot, it may seem as if it happens in the
plot call... But this is really hard to see, but you might want to have a
look.

Best,

Kjetil
#
kjetil.kjernsmo@astro.uio.no writes:
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:
[1] 14.8692 15.1200
#
Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk> writes:
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.
#
On 8 Nov 2000, Peter Dalgaard BSA wrote:

            
Wow! Great, that was fast!
Ah, I tried to poke at the code, but got confused rather fast...
Great! Thanks, I hope it'll work out. And thanks to all who responded!

Best,

Kjetil