在以下情况下rpois()会做什么?

use*_*312 0 r poisson

rpois()取两个值(nlambda)根据泊松分布生成n个随机数。

但是,rpois()在以下情况下该怎么办?

> n = c(0,1,2,3,4,5,6,7,8,9)
> lamda = 10
> rpois(n, lamda)
 [1] 13 15 10  9 10 11 10 10 11 15
> 
Run Code Online (Sandbox Code Playgroud)

Sam*_*son 5

文档

 The length of the result is determined by ‘n’ for ‘rpois’, and is
 the maximum of the lengths of the numerical arguments for the
 other functions.
Run Code Online (Sandbox Code Playgroud)

因此,它与:

rpois(length(n), lambda)
Run Code Online (Sandbox Code Playgroud)

多一点挖,它结束了通话do_random1src/main/random.c。基本上说:

if (length(param1) == 1) {
  n = as.integer(param1)
} else {
  n = length(param1)
}
Run Code Online (Sandbox Code Playgroud)

但在C语言中,并努力确保它与“长”向量等兼容。