[Rd] rpois(9, 1e10)

Spencer Graves @pencer@gr@ve@ @end|ng |rom prod@y@e@com
Sun Jan 19 15:45:46 CET 2020

Hello, All:


Browse[2]> set.seed(1)
Browse[2]> rpois(9, 1e10)
NAs produced[1] NA NA NA NA NA NA NA NA NA

       Should this happen?

       I think that for, say, lambda>1e6, rpois should return rnorm(., 
lambda, sqrt(lambda)).

       For my particular Monte Carlo, I have replaced my call to rpois 
with a call to the following:

  rpois. <- function(n, lambda){
       n2 <- max(length(n), length(lambda))
       n <- rep_len(n, n2)
       lambda <- rep_len(lambda, n2)
       big <- (lambda>1e6)
       out <- rep(NA, n2)
       out[big] <- rnorm(sum(big), lambda[big], sqrt(lambda[big]))
       out[!big] <- rpois(sum(!big), lambda[!big])

       Spencer Graves

More information about the R-devel mailing list