[R-gregmisc-users] SF.net SVN: r-gregmisc:[2021] pkg/gtools/tests/test_ddirichlet.R
Brought to you by:
warnes
From: <wa...@us...> - 2015-05-23 22:21:41
|
Revision: 2021 http://sourceforge.net/p/r-gregmisc/code/2021 Author: warnes Date: 2015-05-23 22:21:39 +0000 (Sat, 23 May 2015) Log Message: ----------- Add regression test ddirichlet() bug for x[i]=0, alpha[i]=1: ddirichlet(x, alpha) was returning NA rather than 0. Added Paths: ----------- pkg/gtools/tests/test_ddirichlet.R Added: pkg/gtools/tests/test_ddirichlet.R =================================================================== --- pkg/gtools/tests/test_ddirichlet.R (rev 0) +++ pkg/gtools/tests/test_ddirichlet.R 2015-05-23 22:21:39 UTC (rev 2021) @@ -0,0 +1,14 @@ +## Bug reported by John Nolan: + +## +## Whenever the pair (x[i], a[i]) == (0,1), NA would be returned, due +## to an internal computation of ( 0 * -Inf ) => NaN +## +## The code now checks for this particular issue and sets the value of +## ( 0 * -Inf ) to 0, which is correct for this calculation. +## +x = c(0,0,1) +alpha = c(1,2,3) + +stopifnot( ddirichlet(x=x, alpha=alpha) == 0 ) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |