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 2007/12/02 20:21:02 UTC

svn commit: r600358 - in /commons/proper/math/trunk/src/test/R: README.txt descriptiveTestCases testAll

Author: psteitz
Date: Sun Dec  2 11:21:02 2007
New Revision: 600358

URL: http://svn.apache.org/viewvc?rev=600358&view=rev
Log:
Added some descriptive statistics verification tests.

Added:
    commons/proper/math/trunk/src/test/R/descriptiveTestCases
Modified:
    commons/proper/math/trunk/src/test/R/README.txt
    commons/proper/math/trunk/src/test/R/testAll

Modified: commons/proper/math/trunk/src/test/R/README.txt
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/R/README.txt?rev=600358&r1=600357&r2=600358&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/R/README.txt (original)
+++ commons/proper/math/trunk/src/test/R/README.txt Sun Dec  2 11:21:02 2007
@@ -76,7 +76,7 @@
 
 at an R prompt. Poking about in the test case files and the online docs should 
 bring you up to speed fairly quickly.  Here are some basic things to get 
-you started. I should note at this point that I by no means an expert R 
+you started. I should note at this point that I am by no means an expert R 
 programmer, so some things may not be implemented in the the nicest way. 
 Comments / suggestions for improvement are welcome!
 

Added: commons/proper/math/trunk/src/test/R/descriptiveTestCases
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/R/descriptiveTestCases?rev=600358&view=auto
==============================================================================
--- commons/proper/math/trunk/src/test/R/descriptiveTestCases (added)
+++ commons/proper/math/trunk/src/test/R/descriptiveTestCases Sun Dec  2 11:21:02 2007
@@ -0,0 +1,83 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#------------------------------------------------------------------------------
+# R source file to validate summary statistics tests in
+# org.apache.commons.math.stat.CertifiedDataTest
+#
+# To run the test, install R, put this file and testFunctions
+# into the same directory, launch R from this directory and then enter
+# source("<name-of-this-file>")
+#
+# R functions used
+#  mean(x)
+#  sd(x)
+#------------------------------------------------------------------------------
+tol <- 1E-14                     # error tolerance for tests
+#------------------------------------------------------------------------------
+# Function definitions
+
+source("testFunctions")           # utility test functions
+options(digits=15)                # bump displayed digits to 15
+
+verifyMean <- function(values, expectedMean, tol, desc) {
+    results <- mean(values)
+    if (assertEquals(expectedMean, results, tol, "mean")) {
+        displayPadded(c(desc," mean test"), SUCCEEDED, WIDTH)
+    } else {
+        displayPadded(c(desc, " mean test"), FAILED, WIDTH)
+    } 
+}
+
+verifySigma <- function(values, expectedSigma, tol, desc) {
+    results <- sd(values)
+    if (assertEquals(expectedSigma, results, tol, "std")) {
+        displayPadded(c(desc," std test"), SUCCEEDED, WIDTH)
+    } else {
+        displayPadded(c(desc, " std test"), FAILED, WIDTH)
+    } 
+}
+
+cat("Descriptive test cases\n")
+
+# Michelson data
+values <- c(299.85,299.74,299.90,300.07,299.93,299.85,299.95,299.98,299.98,
+299.88,300.00,299.98,299.93,299.65,299.76,299.81,300.00,300.00,299.96,299.96,
+299.96,299.94,299.96,299.94,299.88,299.80,299.85,299.88,299.90,299.84,299.83,
+299.79,299.81,299.88,299.88,299.83,299.80,299.79,299.76,299.80,299.88,299.88,
+299.88,299.86,299.72,299.72,299.62,299.86,299.97,299.95,299.88,299.91,299.85,
+299.87,299.84,299.84,299.85,299.84,299.84,299.84,299.89,299.81,299.81,299.82,
+299.80,299.77,299.76,299.74,299.75,299.76,299.91,299.92,299.89,299.86,299.88,
+299.72,299.84,299.85,299.85,299.78,299.89,299.84,299.78,299.81,299.76,299.81,
+299.79,299.81,299.82,299.85,299.87,299.87,299.81,299.74,299.81,299.94,299.95,
+299.80,299.81,299.87)
+expectedMean <- 299.852400000000
+expectedSigma <- 0.0790105478190518
+verifyMean(values, expectedMean, tol, "Michelson")
+verifySigma(values, expectedSigma, tol, "Michelson")
+
+# Mavro data
+values <- c(2.00180,2.00170,2.00180,2.00190,2.00180,2.00170,2.00150,2.00140,
+2.00150,2.00150,2.00170,2.00180,2.00180,2.00190,2.00190,2.00210,2.00200,
+2.00160,2.00140,2.00130,2.00130,2.00150,2.00150,2.00160,2.00150,2.00140,
+2.00130,2.00140,2.00150,2.00140,2.00150,2.00160,2.00150,2.00160,2.00190,
+2.00200,2.00200,2.00210,2.00220,2.00230,2.00240,2.00250,2.00270,2.00260,
+2.00260,2.00260,2.00270,2.00260,2.00250,2.00240)
+expectedMean <- 2.00185600000000
+expectedSigma <- 0.000429123454003053
+verifyMean(values, expectedMean, tol, "Mavro")
+verifySigma(values, expectedSigma, tol, "Mavro")
+
+displayDashes(WIDTH)        

Modified: commons/proper/math/trunk/src/test/R/testAll
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/R/testAll?rev=600358&r1=600357&r2=600358&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/R/testAll (original)
+++ commons/proper/math/trunk/src/test/R/testAll Sun Dec  2 11:21:02 2007
@@ -39,6 +39,10 @@
 
 # inference
 source("chiSquareTestCases")
+
+# descriptive
+source("descriptiveTestCases")
+
 #------------------------------------------------------------------------------
 # if output has been diverted, change it back
 if (sink.number()) {