# [R] Area() artefacts??

From: Sergey Goriatchev <sergeyg_at_gmail.com>
Date: Sat, 12 May 2007 16:15:21 +0200

I run the following program, and depending on the size of eps I get different results.
With eps=1e-05, the program calculates wrong values for x=65:67 and others. The program runs fine with eps=1e-07. Why is this so? Also, I am using area() instead of integrate() because I cannot make integrate to work, especially with imaginary numbers. 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
}

```#===================TESTING================================#
```
consecpmf(seq(0,200),3,0.5)

R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 12 May 2007 - 14:22:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 12 May 2007 - 17:31:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.