[Prob-commits] r51 - in pkg: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Aug 27 18:33:33 CEST 2018


Author: gkerns
Date: 2018-08-27 18:33:32 +0200 (Mon, 27 Aug 2018)
New Revision: 51

Modified:
   pkg/DESCRIPTION
   pkg/NAMESPACE
   pkg/R/characteristicfunctions.r
   pkg/man/CharFunc.Rd
   pkg/man/prob-package.Rd
Log:
reactivated fAsianOptions dependent code


Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2018-08-27 11:29:26 UTC (rev 50)
+++ pkg/DESCRIPTION	2018-08-27 16:33:32 UTC (rev 51)
@@ -3,7 +3,7 @@
 Date: 2018-08-27
 Title: Elementary Probability on Finite Sample Spaces
 Authors at R: person(given = "G. Jay", family = "Kerns", role = c("aut", "cre", "cph"), email = "gkerns at ysu.edu")
-Depends: combinat
+Depends: combinat, fAsianOptions
 Suggests: VGAM, reshape, MASS, hypergeo
 Description:
  A framework for performing elementary probability

Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE	2018-08-27 11:29:26 UTC (rev 50)
+++ pkg/NAMESPACE	2018-08-27 16:33:32 UTC (rev 51)
@@ -2,18 +2,21 @@
              "dweibull", "dwilcox", "integrate", "rbinom")
 importFrom("utils", "combn")
 importFrom("combinat", "permn")
+importFrom("fAsianOptions", "kummerU", "kummerM")
 
 # Export all names
 exportPattern(".")
 export(
 addrv,
 cards,
+cfbeta,
 cfbinom,
 cfcauchy,
 cfchisq,
 cfexp,
 cfgamma,
 cfgeom,
+cff,
 cfhyper,
 cflnorm,
 cflogis,

Modified: pkg/R/characteristicfunctions.r
===================================================================
--- pkg/R/characteristicfunctions.r	2018-08-27 11:29:26 UTC (rev 50)
+++ pkg/R/characteristicfunctions.r	2018-08-27 16:33:32 UTC (rev 51)
@@ -3,20 +3,20 @@
 #  Copyright January 2009, G. Jay Kerns
 
 
-# cfbeta <- function(t, shape1, shape2, ncp = 0){
-#     if (shape1 <=0 || shape2 <=0)
-#         stop("shape1, shape2 must be positive")
-#     if (identical(all.equal(ncp, 0), TRUE)){
-#         # require(fAsianOptions)
-#         kummerM(1i*t, shape1, shape1 + shape2)
-#     } else {
-#         fr <- function(x) cos(t*x)*dbeta(x, shape1, shape2, ncp)
-#         fi <- function(x) sin(t*x)*dbeta(x, shape1, shape2, ncp)
-#         Rp <- integrate(fr, lower = 0, upper = 1)$value
-#         Ip <- integrate(fi, lower = 0, upper = 1)$value
-#         return( Rp + 1i*Ip )
-#     }
-# }
+cfbeta <- function(t, shape1, shape2, ncp = 0){
+     if (shape1 <=0 || shape2 <=0)
+         stop("shape1, shape2 must be positive")
+     if (identical(all.equal(ncp, 0), TRUE)){
+         #require(fAsianOptions)
+         kummerM(1i*t, shape1, shape1 + shape2)
+     } else {
+         fr <- function(x) cos(t*x)*dbeta(x, shape1, shape2, ncp)
+         fi <- function(x) sin(t*x)*dbeta(x, shape1, shape2, ncp)
+         Rp <- integrate(fr, lower = 0, upper = 1)$value
+         Ip <- integrate(fi, lower = 0, upper = 1)$value
+         return( Rp + 1i*Ip )
+     }
+ }
 
 
 cfbinom <- function(t, size, prob){
@@ -44,16 +44,16 @@
     cfgamma(t, shape = 1, scale = 1/rate)
 }
 
-# cff <- function(t, df1, df2, ncp, kmax = 10){
-#     if (df1 <= 0 || df2 <= 0  )
-#         stop("df1 and df2 must be positive")
-#     # require(fAsianOptions)
-#     if( identical(all.equal(ncp, 0), TRUE) ){
-#         gamma((df1+df2)/2) / gamma(df2/2) * kummerU(-1i*df2*t/df1, df1/2, 1 - df2/2)
-#     } else {
-#         exp(-ncp/2)*sum((ncp/2)^(0:kmax)/factorial(0:kmax)* kummerM(-1i*df2*t/df1, df1/2 + 0:kmax, -df2/2))
-#     }
-# }
+cff <- function(t, df1, df2, ncp, kmax = 10){
+     if (df1 <= 0 || df2 <= 0  )
+         stop("df1 and df2 must be positive")
+    #require(fAsianOptions)
+     if( identical(all.equal(ncp, 0), TRUE) ){
+         gamma((df1+df2)/2) / gamma(df2/2) * kummerU(-1i*df2*t/df1, df1/2, 1 - df2/2)
+     } else {
+         exp(-ncp/2)*sum((ncp/2)^(0:kmax)/factorial(0:kmax)* kummerM(-1i*df2*t/df1, df1/2 + 0:kmax, -df2/2))
+     }
+ }
 
 
 cfgamma <- function(t, shape, rate = 1, scale = 1/rate){

Modified: pkg/man/CharFunc.Rd
===================================================================
--- pkg/man/CharFunc.Rd	2018-08-27 11:29:26 UTC (rev 50)
+++ pkg/man/CharFunc.Rd	2018-08-27 16:33:32 UTC (rev 51)
@@ -4,10 +4,12 @@
 
 \name{CharFunc}
 \concept{characteristic function}
+\alias{cfbeta}
 \alias{cfbinom}
 \alias{cfcauchy}
 \alias{cfchisq}
 \alias{cfexp}
+\alias{cff}
 \alias{cfgamma}
 \alias{cfgeom}
 \alias{cfhyper}
@@ -32,10 +34,12 @@
 }
 
 \usage{
+cfbeta(t, shape1, shape2, ncp = 0)
 cfbinom(t, size, prob)
 cfcauchy(t, location = 0, scale = 1)
 cfchisq(t, df, ncp = 0)
 cfexp(t, rate = 1)
+cff(t, df1, df2, ncp, kmax = 10)
 cfgamma(t, shape, rate = 1, scale = 1/rate)
 cfgeom(t, prob)
 cfhyper(t, m, n, k)
@@ -54,7 +58,9 @@
 \arguments{
   \item{t}{numeric value.  Some of the above are vectorized functions.}
   \item{df}{degrees of freedom (\eqn{> 0}, maybe non-integer)}
+  \item{df1, df2}{degrees of freedom (\eqn{> 0}, maybe non-integer)}
   \item{k}{the number of balls drawn from the urn.}
+  \item{kmax}{upper limit of summation.}
   \item{lambda}{vector of (positive) means.}
   \item{location, scale}{location and scale parameters; scale must be positive.}
   \item{m}{the number of white balls in the urn.}
@@ -69,9 +75,10 @@
   \item{prob}{probability of success in each trial.}
   \item{rate}{an alternative way to specify the scale; must be positive.}  
   \item{sd}{vector of standard deviations.}
+  \item{shape}{shape parameter, must be positive (gamma, weibull)}
+  \item{shape1, shape2}{shape parameters (beta).}
   \item{size}{number of trials (binom) or target for number of successful trials
     (nbinom).}
-  \item{shape}{shape parameter, must be positive (gamma, weibull)}
 }
 
 \value{

Modified: pkg/man/prob-package.Rd
===================================================================
--- pkg/man/prob-package.Rd	2018-08-27 11:29:26 UTC (rev 50)
+++ pkg/man/prob-package.Rd	2018-08-27 16:33:32 UTC (rev 51)
@@ -23,7 +23,7 @@
 Package: \tab prob\cr
 Version: \tab 1.0-1\cr
 Date: \tab 2018-08-27\cr
-Depends: \tab combinat\cr
+Depends: \tab combinat, fAsianOptions\cr
 Suggests: \tab VGAM, reshape, MASS, hypergeo\cr
 LazyLoad: \tab no\cr
 License: \tab GPL version 3 or newer\cr



More information about the Prob-commits mailing list