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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 14 01:58:45 CET 2011


Author: edd
Date: 2011-11-14 01:58:44 +0100 (Mon, 14 Nov 2011)
New Revision: 3345

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/NEWS
   pkg/Rcpp/inst/unitTests/runit.stats.R
Log:
added test for pcauchy


Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2011-11-13 19:59:09 UTC (rev 3344)
+++ pkg/Rcpp/ChangeLog	2011-11-14 00:58:44 UTC (rev 3345)
@@ -3,7 +3,7 @@
 	* inst/include/Rcpp/stats/f.h: Correct call to not require ncp parameter
 
 	* inst/unitTests/runit.stats.R: Add unit tests for pf(), pnf(),
-	pchisq() and pnchisq()
+	pchisq(), pnchisq() and pcauchy()
 
 2011-11-07  Romain Francois  <romain at r-enthusiasts.com>
 

Modified: pkg/Rcpp/inst/NEWS
===================================================================
--- pkg/Rcpp/inst/NEWS	2011-11-13 19:59:09 UTC (rev 3344)
+++ pkg/Rcpp/inst/NEWS	2011-11-14 00:58:44 UTC (rev 3345)
@@ -9,7 +9,7 @@
         This work has been sponsored by the Google Open Source Programs
         Office.
 
-    o   New unit tests for pf(), pnf(), pchisq() and pnchisq()
+    o   New unit tests for pf(), pnf(), pchisq(), pnchisq() and pcauchy()
 
 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:59:09 UTC (rev 3344)
+++ pkg/Rcpp/inst/unitTests/runit.stats.R	2011-11-14 00:58:44 UTC (rev 3345)
@@ -122,6 +122,19 @@
 				  ')
 
 				  ,
+				  "runit_pcauchy" = list(
+				  signature( x = "numeric", location = "numeric", scale = "numeric" ),
+				  '
+				  double loc = as<double>(location);
+				  double scl = as<double>(scale);
+				  NumericVector xx(x) ;
+				  return List::create(_["lowerNoLog"] = pcauchy(xx, loc, scl ),
+									  _["lowerLog"]	  = pcauchy(xx, loc, scl, true, true ),
+									  _["upperNoLog"] = pcauchy(xx, loc, scl, false ),
+									  _["upperLog"]	  = pcauchy(xx, loc, scl, false, true ));
+				  ')
+
+				  ,
 				  "runit_punif" = list(
 				  signature( x = "numeric" ),
 				  '
@@ -403,6 +416,20 @@
                 msg = " stats.pbinom")
 }
 
+test.stats.pcauchy <- function( ) {
+    fx <- .rcpp.stats$runit_pcauchy
+    location <- 0.5
+    scale <- 1.5
+    vv <- 1:5
+    checkEquals(fx(vv, location, scale),
+                list(lowerNoLog = pcauchy(vv, location, scale),
+                     lowerLog   = pcauchy(vv, location, scale, log=TRUE),
+                     upperNoLog = pcauchy(vv, location, scale, lower=FALSE),
+                     upperLog   = pcauchy(vv, location, scale, lower=FALSE, log=TRUE)
+                     ),
+                msg = " stats.pcauchy")
+}
+
 test.stats.punif <- function( ) {
     fx <- .rcpp.stats$runit_punif
     v <- qunif(seq(0.0, 1.0, by=0.1))
@@ -522,7 +549,7 @@
     n <- 20
     p <- 0.5
     vv <- seq(0, 1, by = 0.1)
-    checkEquals(fx(vv, n, p),
+    checkEquals(fx(vv, location, scale),
                 list(lower = qbinom(vv, n, p),
                      upper = qbinom(vv, n, p, lower=FALSE)
                      ),



More information about the Rcpp-commits mailing list