From 2a94c8656e68353eb088d1f8db7adf2108e61e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pelletier?= Date: Sat, 8 Mar 2014 22:37:11 -0500 Subject: [PATCH] Correction vectorisation du calcul --- R/psaddleapproxGAL.R | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/R/psaddleapproxGAL.R b/R/psaddleapproxGAL.R index 966d400..5d27351 100644 --- a/R/psaddleapproxGAL.R +++ b/R/psaddleapproxGAL.R @@ -22,13 +22,8 @@ psaddleapproxGAL <- function(x,param,eval.time=1,type="mu",log=FALSE) u <- s * sqrt(diffcgfGAL(s,2,param,eval.time,type,log)) w <- sign(s)*sqrt(2*(s*x-cgfGAL(s,param,type,log))) - if(x==mGAL(1,param,type,log)) - { - return(1/2 + diffcgfGAL(0,3,param,eval.time,type,log)/ - (6*sqrt(2*pi)*diffcgfGAL(0,2,param,eval.time,type,log)^(3/2))) - } - else - { - return(pnorm(w)+dnorm(w)*(1/w-1/u)) - } + (x==mGAL(param,1,type,log)) * (1/2 + diffcgfGAL(0,3,param,eval.time,type,log)/ + (6*sqrt(2*pi)*diffcgfGAL(0,2,param,eval.time,type,log)^(3/2))) + + (x!=mGAL(param,1,type,log)) * pnorm(w)+dnorm(w)*(1/w-1/u) + }