[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-devel
Subject:    [Rd] Error message for infinite probability parameters in rbinom() and rmultinom()
From:       Christophe Dutang <dutangc () gmail ! com>
Date:       2023-04-08 12:21:53
Message-ID: 3D1EFD77-1BA5-46E3-B69A-EE754906FAFD () gmail ! com
[Download RAW message or body]

Dear all,

Using rmultinom() in a stochastic model, I found this function returns an e=
rror 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 probabilit=
y.

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/li=
bRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/li=
bRlapack.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

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic