[adegenet-commits] r324 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed May 27 16:49:53 CEST 2009
Author: jombart
Date: 2009-05-27 16:49:53 +0200 (Wed, 27 May 2009)
New Revision: 324
Modified:
pkg/R/seqTrack.R
Log:
added .pAbeforeB
Modified: pkg/R/seqTrack.R
===================================================================
--- pkg/R/seqTrack.R 2009-05-27 12:11:56 UTC (rev 323)
+++ pkg/R/seqTrack.R 2009-05-27 14:49:53 UTC (rev 324)
@@ -333,6 +333,34 @@
+##############
+## .pAbeforeB
+##############
+.pAbeforeB <- function(dateA, dateB, mu0, L, maxNbDays=100){
+ temp <- .dTimeSeq(mu0, L, maxNbDays)
+ days <- temp[[1]]
+ p <- temp[[2]]/sum(temp[[2]]) # proba distribution
+
+ nbDaysDiff <- as.integer(difftime(dateA,dateB,units="days")) # dateA - dateB, in days
+ daysA <- days
+ daysB <- days - nbDaysDiff
+
+ f1 <- function(i){ # proba A before B for one day
+ idx <- daysB>daysA[i]
+ res <- p[i] * sum(p[idx])
+ return(res)
+ }
+
+ res <- sapply(1:length(p), f1) # proba for all days
+ res <- sum(res) # sum
+ return(res)
+} # end .pAbeforeB
+
+
+
+
+
+
#####################
## optimize.seqTrack
#####################
More information about the adegenet-commits
mailing list