Skip to content

Commit 6c49787

Browse files
committed
minor bug fix in f.h to no require setting of ncp argument
new unit test for pf() to complement one for pnf()
1 parent 5a6aea0 commit 6c49787

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

ChangeLog

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
2011-11-13 Dirk Eddelbuettel <[email protected]>
22

3-
* inst/unitTests/runit.stats.R: Add unit test for pnf()
3+
* inst/include/Rcpp/stats/f.h: Correct call to not require ncp parameter
4+
5+
* inst/unitTests/runit.stats.R: Add unit test for pf() and pnf()
46

57
2011-11-07 Romain Francois <[email protected]>
68

inst/NEWS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
of them. This work has been sponsored by the Google Open Source
99
Programs Office.
1010

11-
o New unit test for pnf() (ie prob. function of a non-central F dist.)
11+
o New unit test for pf() and pnf()
1212

1313
0.9.7 2011-09-29
1414

inst/include/Rcpp/stats/f.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#ifndef Rcpp__stats__f_h
2323
#define Rcpp__stats__f_h
2424

25-
RCPP_DPQ_3(f,::Rf_df,::Rf_pf,::Rf_qf)
25+
RCPP_DPQ_2(f,::Rf_df,::Rf_pf,::Rf_qf)
2626

2727
#endif
2828

inst/unitTests/runit.stats.R

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,21 @@ definitions <- function(){
148148
signature( x = "numeric" ),
149149
'
150150
NumericVector xx(x) ;
151-
return List::create(_["lowerNoLog"] = pnf( xx, 6.0, 8.0, 0.0, true ),
152-
_["lowerLog"] = pnf( xx, 6.0, 8.0, 0.0, true, true ),
153-
_["upperNoLog"] = pnf( xx, 6.0, 8.0, 0.0, false ),
154-
_["upperLog"] = pnf( xx, 6.0, 8.0, 0.0, false, true ));
151+
return List::create(_["lowerNoLog"] = pnf( xx, 6.0, 8.0, 2.5, true ),
152+
_["lowerLog"] = pnf( xx, 6.0, 8.0, 2.5, true, true ),
153+
_["upperNoLog"] = pnf( xx, 6.0, 8.0, 2.5, false ),
154+
_["upperLog"] = pnf( xx, 6.0, 8.0, 2.5, false, true ));
155+
')
156+
157+
,
158+
"runit_pf" = list(
159+
signature( x = "numeric" ),
160+
'
161+
NumericVector xx(x) ;
162+
return List::create(_["lowerNoLog"] = pf( xx, 6.0, 8.0 ),
163+
_["lowerLog"] = pf( xx, 6.0, 8.0, true, true ),
164+
_["upperNoLog"] = pf( xx, 6.0, 8.0, false ),
165+
_["upperLog"] = pf( xx, 6.0, 8.0, false, true ));
155166
')
156167

157168
,
@@ -383,8 +394,8 @@ test.stats.punif <- function( ) {
383394
# TODO: also borrow from R's d-p-q-r-tests.R
384395
}
385396

386-
test.stats.pnf <- function( ) {
387-
fx <- .rcpp.stats$runit_pnf
397+
test.stats.pf <- function( ) {
398+
fx <- .rcpp.stats$runit_pf
388399
v <- (1:9)/10
389400
checkEquals(fx(v),
390401
list(lowerNoLog = pf(v, 6, 8, lower=TRUE, log=FALSE),
@@ -395,6 +406,18 @@ test.stats.pnf <- function( ) {
395406
msg = "stats.pf" )
396407
}
397408

409+
test.stats.pnf <- function( ) {
410+
fx <- .rcpp.stats$runit_pnf
411+
v <- (1:9)/10
412+
checkEquals(fx(v),
413+
list(lowerNoLog = pf(v, 6, 8, ncp=2.5, lower=TRUE, log=FALSE),
414+
lowerLog = pf(v, 6, 8, ncp=2.5, log=TRUE ),
415+
upperNoLog = pf(v, 6, 8, ncp=2.5, lower=FALSE),
416+
upperLog = pf(v, 6, 8, ncp=2.5, lower=FALSE, log=TRUE)
417+
),
418+
msg = "stats.pnf" )
419+
}
420+
398421
test.stats.pgamma <- function( ) {
399422
fx <- .rcpp.stats$runit_pgamma
400423
v <- (1:9)/10

0 commit comments

Comments
 (0)