You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2015/11/23 21:56:51 UTC

[math] Fixed syntax / coding errors to make tests agree exactly with Java tests; added missing tests to testAll.

Repository: commons-math
Updated Branches:
  refs/heads/master 23b351c89 -> 03326f611


Fixed syntax / coding errors to make tests agree exactly with Java tests; added missing tests to testAll.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/03326f61
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/03326f61
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/03326f61

Branch: refs/heads/master
Commit: 03326f61164669a84197d6808522e089c20b6a8b
Parents: 23b351c
Author: Phil Steitz <ph...@gmail.com>
Authored: Mon Nov 23 13:56:27 2015 -0700
Committer: Phil Steitz <ph...@gmail.com>
Committed: Mon Nov 23 13:56:27 2015 -0700

----------------------------------------------------------------------
 src/test/R/LevyDistributionTestCases.R |  1 -
 src/test/R/nakagamiTestCases.R         |  4 ++--
 src/test/R/paretoTestCases             | 11 +++++++----
 src/test/R/testAll                     | 12 +++++++++++-
 4 files changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/03326f61/src/test/R/LevyDistributionTestCases.R
----------------------------------------------------------------------
diff --git a/src/test/R/LevyDistributionTestCases.R b/src/test/R/LevyDistributionTestCases.R
index ed7c367..caf9a8c 100644
--- a/src/test/R/LevyDistributionTestCases.R
+++ b/src/test/R/LevyDistributionTestCases.R
@@ -31,7 +31,6 @@ tol <- 1E-9
 # Function definitions
 
 source("testFunctions")           # utility test functions
-library(rmutil)
 
 # function to verify distribution computations
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/03326f61/src/test/R/nakagamiTestCases.R
----------------------------------------------------------------------
diff --git a/src/test/R/nakagamiTestCases.R b/src/test/R/nakagamiTestCases.R
index e1dd2be..31133d7 100644
--- a/src/test/R/nakagamiTestCases.R
+++ b/src/test/R/nakagamiTestCases.R
@@ -39,7 +39,7 @@ verifyDistribution <- function(points, expected, m, s, tol) {
   i <- 0
   for (point in points) {
     i <- i + 1
-    rDistValues[i] <- pnaka(point, m, s)
+    rDistValues[i] <- pnaka(point, s, m)
   }
   output <- c("Distribution test m = ",m,", s = ", s)
   if (assertEquals(expected, rDistValues, tol, "Distribution Values")) {
@@ -55,7 +55,7 @@ verifyDensity <- function(points, expected, m, s, tol) {
   i <- 0
   for (point in points) {
     i <- i + 1
-    rDensityValues[i] <- dnaka(point, m, s)
+    rDensityValues[i] <- dnaka(point, s, m)
   }
   output <- c("Density test m = ",m,", s = ", s)
   if (assertEquals(expected, rDensityValues, tol, "Density Values")) {

http://git-wip-us.apache.org/repos/asf/commons-math/blob/03326f61/src/test/R/paretoTestCases
----------------------------------------------------------------------
diff --git a/src/test/R/paretoTestCases b/src/test/R/paretoTestCases
index 7360b9a..0eabf5e 100644
--- a/src/test/R/paretoTestCases
+++ b/src/test/R/paretoTestCases
@@ -23,6 +23,9 @@
 #
 # R functions used
 # ppareto(q, mean=0, sd=1, lower.tail = TRUE, log.p = FALSE) <-- distribution
+# The VGAM library which includes the function above must be installed to run
+# this test.
+# See https://cran.r-project.org/web/packages/VGAM/index.html
 #-----------------------------------------------------------------------------
 tol <- 1E-9
 
@@ -78,7 +81,7 @@ verifyDistribution(distributionPoints, distributionValues, mu, sigma, tol)
 verifyDensity(distributionPoints, densityValues, mu, sigma, tol)
 
 distributionValues <- c(0, 0, 0, 0.510884134236, 0.694625688662, 0.785201995008, 0.837811522357, 0.871634279326)
-densityValues <- c(0, 0, 0, 0.195646346305, 0.0872498032394, 0.0477328899983, 0.0294888141169, 0.0197485724114)
+densityValues <- c(0, 0, 0.666666666, 0.195646346305, 0.0872498032394, 0.0477328899983, 0.0294888141169, 0.0197485724114)
 distributionPoints <- c(mu - 2 *sigma, mu - sigma, mu, mu + sigma,
 		mu + 2 * sigma,  mu + 3 * sigma, mu + 4 * sigma,
                     mu + 5 * sigma)
@@ -91,17 +94,17 @@ distributionPoints <- c(mu - 2 *sigma, mu - sigma, mu, mu + sigma,
 		mu + 2 * sigma,  mu + 3 * sigma, mu + 4 * sigma,
                     mu + 5 * sigma)
 distributionValues <- c(0, 0, 0, 0.5, 0.666666666667, 0.75, 0.8, 0.833333333333)
-densityValues <- c(0, 0, 0, 0.25, 0.111111111111, 0.0625, 0.04, 0.0277777777778)
+densityValues <- c(0, 0, 1, 0.25, 0.111111111111, 0.0625, 0.04, 0.0277777777778)
 verifyDistribution(distributionPoints, distributionValues, mu, sigma, tol)
 verifyDensity(distributionPoints, densityValues, mu, sigma, tol)
 
 mu <- 0.1
 sigma <- 0.1
-distributionPoints <- c(mu - 2 *sigma, mu - sigma, mu, mu + sigma,
+distributionPoints <- c(mu - 2 *sigma, 0, mu, mu + sigma,
 		mu + 2 * sigma,  mu + 3 * sigma, mu + 4 * sigma,
                     mu + 5 * sigma)
 distributionValues <- c(0, 0, 0, 0.0669670084632, 0.104041540159, 0.129449436704, 0.148660077479, 0.164041197922)
-densityValues <- c(0, 0, 0, 0.466516495768, 0.298652819947, 0.217637640824, 0.170267984504, 0.139326467013)
+densityValues <- c(0, 0, 1, 0.466516495768, 0.298652819947, 0.217637640824, 0.170267984504, 0.139326467013)
 verifyDistribution(distributionPoints, distributionValues, mu, sigma, tol)
 verifyDensity(distributionPoints, densityValues, mu, sigma, tol)
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/03326f61/src/test/R/testAll
----------------------------------------------------------------------
diff --git a/src/test/R/testAll b/src/test/R/testAll
index 9af417b..49c460b 100644
--- a/src/test/R/testAll
+++ b/src/test/R/testAll
@@ -21,6 +21,12 @@
 # directory, launch R from this directory and then enter
 # source("<name-of-this-file>")
 #
+# The KolmogorovSmirnov and Pareto distribution tests require the following
+# packages to be installed:
+#
+# https://cran.r-project.org/web/packages/Matching/index.html
+# https://cran.r-project.org/web/packages/VGAM/index.html
+#
 # To redirect output to a file, uncomment the following line, substituting
 # another file path if you like (default behavior is to write the file to the
 # current directory).
@@ -31,6 +37,8 @@
 source("binomialTestCases")
 source("normalTestCases")
 source("poissonTestCases")
+source("paretoTestCases")
+source("logNormalTestCases")
 source("hypergeometricTestCases")
 source("exponentialTestCases")
 source("cauchyTestCases.R")
@@ -45,6 +53,7 @@ source("gumbelTestCases.R")
 source("laplaceTestCases.R")
 source("logisticsTestCases.R")
 source("nakagamiTestCases.R")
+source("zipfTestCases")
 
 # regression
 source("regressionTestCases")
@@ -52,7 +61,8 @@ source("regressionTestCases")
 # inference
 source("chiSquareTestCases")
 source("anovaTestCases")
-source("KolmogorovSmirnovTestCases")
+source("KolmogorovSmirnovTestCases.R")
+source("TTestCases")
 
 # descriptive
 source("descriptiveTestCases")