Displaying 1 result from an estimated 1 matches for "consecpmf".
2007 May 12
1
Area() artefacts??
...ers. Maybe someone
can show me how to use integrate in this particular code? THanks in
advance!
#Computes the p.m.f. via (10.53) of the number of i.i.d. Ber(p) trials
#required until m consecutive successes occur.
#Requires MASS package
#==========================================================#
consecpmf <- function(xvec, m, p, eps=1e-05){
library(MASS)
f<-numeric()
for(j in seq(xvec)){
x <- xvec[j]
f[j] <- area(fun, -pi, pi, limit=1000, eps=eps, x, m, p)
}
f<-Re(f)
round(f,4)
}
fun <- function(t,x,m,p){
I <- exp(-1i*t*x)*cf(t,m,p)/(2*pi)
I
}
cf <- function(t,m,p){
q <...