[Rd] Error message for infinite probability parameters in rbinom() and rmultinom()
Christophe Dutang
dut@ngc @end|ng |rom gm@||@com
Sat Apr 8 14:21:53 CEST 2023
Dear all,
Using rmultinom() in a stochastic model, I found this function returns an error message 'NA in probability' for an infinite probability.
Maybe, a more precise message will be helpful when debugging.
> rmultinom(1, 3:5, c(1/2, 1/3, Inf))
Error in rmultinom(1, 3:5, c(1/2, 1/3, Inf)) : NA in probability vector
> rmultinom(1, 3:5, c(1/2, 1/3, NA))
Error in rmultinom(1, 3:5, c(1/2, 1/3, NA)) : NA in probability vector
For rgeom() or rbinom(), we got a warning for infinite probability :
> rbinom(1, 3, Inf)
[1] NA
Warning message:
In rbinom(1, 3, Inf) : NAs produced
> rbinom(1, 3, NA)
[1] NA
Warning message:
In rbinom(1, 3, NA) : NAs produced
> rgeom(1, Inf)
[1] NA
Warning message:
In rgeom(1, Inf) : NAs produced
> rgeom(1, NA)
[1] NA
Warning message:
In rgeom(1, NA) : NAs produced
Maybe, it could be better to harmonize the behavior for infinite probability.
Kind regards, Christophe
> sessionInfo()
R version 4.2.3 (2023-03-15)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.2.1
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.2.3 tools_4.2.3
-------------------------------------------------
Christophe DUTANG
LJK, Ensimag, Grenoble INP, UGA, France
Web: http://dutangc.free.fr
More information about the R-devel
mailing list