[Rcpp-commits] r3343 - in pkg/Rcpp: . inst inst/unitTests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Nov 13 20:46:12 CET 2011


Author: edd
Date: 2011-11-13 20:46:11 +0100 (Sun, 13 Nov 2011)
New Revision: 3343

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/NEWS
   pkg/Rcpp/inst/unitTests/runit.stats.R
Log:
new unit tests for pchisq() and pnchisq()


Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2011-11-13 19:05:49 UTC (rev 3342)
+++ pkg/Rcpp/ChangeLog	2011-11-13 19:46:11 UTC (rev 3343)
@@ -2,7 +2,8 @@
 
 	* inst/include/Rcpp/stats/f.h: Correct call to not require ncp parameter
 
-	* inst/unitTests/runit.stats.R: Add unit test for pf() and pnf() 
+	* inst/unitTests/runit.stats.R: Add unit tests for pf(), pnf(),
+	pchisq() and pnchisq()
 
 2011-11-07  Romain Francois  <romain at r-enthusiasts.com>
 

Modified: pkg/Rcpp/inst/NEWS
===================================================================
--- pkg/Rcpp/inst/NEWS	2011-11-13 19:05:49 UTC (rev 3342)
+++ pkg/Rcpp/inst/NEWS	2011-11-13 19:46:11 UTC (rev 3343)
@@ -8,7 +8,7 @@
         of them. This work has been sponsored by the Google Open Source
         Programs Office. 
 
-    o   New unit test for pf() and pnf() 
+    o   New unit test for pf(), pnf(), pchisq() and pnchisq()
 
 0.9.7   2011-09-29
 

Modified: pkg/Rcpp/inst/unitTests/runit.stats.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.stats.R	2011-11-13 19:05:49 UTC (rev 3342)
+++ pkg/Rcpp/inst/unitTests/runit.stats.R	2011-11-13 19:46:11 UTC (rev 3343)
@@ -166,6 +166,28 @@
 				  ')
 
 				  ,
+				  "runit_pnchisq" = list(
+				  signature( x = "numeric" ),
+				  '
+				  NumericVector xx(x) ;
+				  return List::create(_["lowerNoLog"] = pnchisq( xx, 6.0, 2.5, true ),
+									  _["lowerLog"]	  = pnchisq( xx, 6.0, 2.5, true, true ),
+									  _["upperNoLog"] = pnchisq( xx, 6.0, 2.5, false ),
+									  _["upperLog"]	  = pnchisq( xx, 6.0, 2.5, false, true ));
+				  ')
+
+				  ,
+				  "runit_pchisq" = list(
+				  signature( x = "numeric" ),
+				  '
+				  NumericVector xx(x) ;
+				  return List::create(_["lowerNoLog"] = pchisq( xx, 6.0 ),
+									  _["lowerLog"]	  = pchisq( xx, 6.0, true, true ),
+									  _["upperNoLog"] = pchisq( xx, 6.0, false ),
+									  _["upperLog"]	  = pchisq( xx, 6.0, false, true ));
+				  ')
+
+                  ,
 				  "runit_pnorm" = list(signature( x = "numeric" ),
 				  '
 				  NumericVector xx(x) ;
@@ -418,6 +440,30 @@
                 msg = "stats.pnf" )
 }
 
+test.stats.pchisq <- function( ) {
+    fx <- .rcpp.stats$runit_pchisq
+    v <- (1:9)/10
+    checkEquals(fx(v),
+                list(lowerNoLog = pchisq(v, 6, lower=TRUE, log=FALSE),
+                     lowerLog   = pchisq(v, 6, log=TRUE ),
+                     upperNoLog = pchisq(v, 6, lower=FALSE),
+                     upperLog   = pchisq(v, 6, lower=FALSE, log=TRUE)
+                     ),
+                msg = "stats.pchisq" )
+}
+
+test.stats.pnchisq <- function( ) {
+    fx <- .rcpp.stats$runit_pnchisq
+    v <- (1:9)/10
+    checkEquals(fx(v),
+                list(lowerNoLog = pchisq(v, 6, ncp=2.5, lower=TRUE, log=FALSE),
+                     lowerLog   = pchisq(v, 6, ncp=2.5, log=TRUE ),
+                     upperNoLog = pchisq(v, 6, ncp=2.5, lower=FALSE),
+                     upperLog   = pchisq(v, 6, ncp=2.5, lower=FALSE, log=TRUE)
+                     ),
+                msg = "stats.pnchisq" )
+}
+
 test.stats.pgamma <- function( ) {
     fx <- .rcpp.stats$runit_pgamma
     v <- (1:9)/10
@@ -539,5 +585,5 @@
 }
 
 # TODO: test.stats.qgamma
-# TODO: test.stats.(dpq)chisq
+# TODO: test.stats.(dq)chisq
 



More information about the Rcpp-commits mailing list