File: test_ddirichlet.R

package info (click to toggle)
gtools 3.9.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 748 kB
  • sloc: ansic: 190; makefile: 2
file content (14 lines) | stat: -rw-r--r-- 418 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
## Regression test for 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.
##
library(gtools)

x <- c(0, 0, 1)
alpha <- c(1, 2, 3)

stopifnot(ddirichlet(x = x, alpha = alpha) == 0)