You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2013/10/21 23:00:04 UTC

svn commit: r1534369 - in /commons/proper/math/trunk/src/test: R/hypergeometricTestCases R/testFunctions java/org/apache/commons/math3/distribution/HypergeometricDistributionTest.java

Author: tn
Date: Mon Oct 21 21:00:03 2013
New Revision: 1534369

URL: http://svn.apache.org/r1534369
Log:
Update reference test values for HypergeometricDistribution#logDensity test.

Modified:
    commons/proper/math/trunk/src/test/R/hypergeometricTestCases
    commons/proper/math/trunk/src/test/R/testFunctions
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/distribution/HypergeometricDistributionTest.java

Modified: commons/proper/math/trunk/src/test/R/hypergeometricTestCases
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/R/hypergeometricTestCases?rev=1534369&r1=1534368&r2=1534369&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/R/hypergeometricTestCases (original)
+++ commons/proper/math/trunk/src/test/R/hypergeometricTestCases Mon Oct 21 21:00:03 2013
@@ -34,12 +34,12 @@ source("testFunctions")           # util
 
 # 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
 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

Modified: commons/proper/math/trunk/src/test/R/testFunctions
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/R/testFunctions?rev=1534369&r1=1534368&r2=1534369&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/R/testFunctions (original)
+++ commons/proper/math/trunk/src/test/R/testFunctions Mon Oct 21 21:00:03 2013
@@ -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
 #------------------------------------------------------------------------------

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/distribution/HypergeometricDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/distribution/HypergeometricDistributionTest.java?rev=1534369&r1=1534368&r2=1534369&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/distribution/HypergeometricDistributionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/distribution/HypergeometricDistributionTest.java Mon Oct 21 21:00:03 2013
@@ -65,6 +65,17 @@ public class HypergeometricDistributionT
             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() {