Update reference test values for HypergeometricDistribution#logDensity test.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1534369 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
456723dd14
commit
0d3f14e99f
|
@ -34,12 +34,12 @@ source("testFunctions") # utility test functions
|
|||
|
||||
# function to verify density computations
|
||||
|
||||
verifyDensity <- function(points, expected, good, bad, selected, tol) {
|
||||
verifyDensity <- function(points, expected, good, bad, selected, tol, log = FALSE) {
|
||||
rDensityValues <- rep(0, length(points))
|
||||
i <- 0
|
||||
for (point in points) {
|
||||
i <- i + 1
|
||||
rDensityValues[i] <- dhyper(point, good, bad, selected)
|
||||
rDensityValues[i] <- dhyper(point, good, bad, selected, log)
|
||||
}
|
||||
output <- c("Density test good = ", good, ", bad = ", bad,
|
||||
", selected = ",selected)
|
||||
|
@ -76,8 +76,10 @@ bad <- 5
|
|||
selected <- 5
|
||||
|
||||
densityPoints <- c(-1, 0, 1, 2, 3, 4, 5, 10)
|
||||
densityValues <- c(0, 0.003968, 0.099206, 0.396825, 0.396825, 0.099206,
|
||||
0.003968, 0)
|
||||
densityValues <- c(0, 0.00396825396825397, 0.0992063492063492, 0.396825396825397, 0.396825396825397,
|
||||
0.0992063492063492, 0.00396825396825397, 0)
|
||||
logDensityValues <- c(-Inf, -5.52942908751142, -2.31055326264322, -0.924258901523332,
|
||||
-0.924258901523332, -2.31055326264322, -5.52942908751142, -Inf)
|
||||
distributionValues <- c(0, .003968, .103175, .50000, .896825, .996032,
|
||||
1.00000, 1)
|
||||
#Eliminate p=1 case because it will mess up adjustement below
|
||||
|
@ -86,6 +88,7 @@ inverseCumPoints <- c(0, 0.001, 0.010, 0.025, 0.050, 0.100, 0.999,
|
|||
inverseCumValues <- c(-1, -1, 0, 0, 0, 0, 4, 3, 3, 3, 3)
|
||||
|
||||
verifyDensity(densityPoints, densityValues, good, bad, selected, tol)
|
||||
verifyDensity(densityPoints, logDensityValues, good, bad, selected, tol, TRUE)
|
||||
verifyDistribution(densityPoints, distributionValues, good, bad, selected, tol)
|
||||
|
||||
i <- 0
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
WIDTH <- 80 # screen size constant for display functions
|
||||
SUCCEEDED <- "SUCCEEDED"
|
||||
FAILED <- "FAILED"
|
||||
options(digits=12) # display 12 digits throughout
|
||||
options(digits=15) # display 12 digits throughout
|
||||
#------------------------------------------------------------------------------
|
||||
# Comparison functions
|
||||
#------------------------------------------------------------------------------
|
||||
|
|
|
@ -65,6 +65,17 @@ public class HypergeometricDistributionTest extends IntegerDistributionAbstractT
|
|||
0.0992063492063, 0.00396825396825, 0d};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the default probability log density test expected values
|
||||
* Reference values are from R, version 2.14.1.
|
||||
*/
|
||||
@Override
|
||||
public double[] makeLogDensityTestValues() {
|
||||
//-Inf -Inf
|
||||
return new double[] {Double.NEGATIVE_INFINITY, -5.52942908751142, -2.31055326264322, -0.924258901523332,
|
||||
-0.924258901523332, -2.31055326264322, -5.52942908751142, Double.NEGATIVE_INFINITY};
|
||||
}
|
||||
|
||||
/** Creates the default cumulative probability density test input values */
|
||||
@Override
|
||||
public int[] makeCumulativeTestPoints() {
|
||||
|
|
Loading…
Reference in New Issue