I'm going to try to put this nicely:

What you provided is not a problem with integrate. Instead, you provided a
rather unintelligible and badly-written piece of code that (miraculously)
seems to work, though it's not well documented so I have no idea if 1.3e-21
is what you want to get.

Let's try this again: per your original request, what is the problem with
integrate?

If instead you feel there's something wrong with your code, might I suggest
you just say that and ask for help, rather than passing the blame onto a
perfectly useful base function.

Oh, and since you asked that I propose something: comment your code.

Michael

On Thu, Sep 1, 2011 at 10:33 AM, . . <xkziloj@gmail.com> wrote:

> Hi Michael,
>
> This is the problem:
>
> func <- Vectorize(function(x, a, sad, samp="pois", trunc=0, ...) {
>  result <- function(x) {
>    f1 <- function(n) {
>                        f <- function() {
>        dcom <- paste("d", sad, sep="")
>        dots <- c(as.name("n"), list(...))
>        do.call(dcom, dots)
>                        }
>      g <- function() {
>        dcom <- paste("d", samp, sep="")
>        lambda <- a * n
>        dots <- c(as.name("x"), as.name("lambda"))
>        do.call(dcom, dots)
>      }
>      f() * g()
>    }
>    integrate(f1,0,2000)$value
> #     adaptIntegrate(f1,0,2000)$integral
>
> #     n <- 0:2000
> #     trapz(n,f1(n))
>
> #     area(f1, 0, 2000, limit=10000, eps=1e-100)
>  }
>  return(result(x) / (1 - result(trunc)))
> }, "x")
> func(200, 0.05, "exp", rate=0.001)
>
> If you could propose something I will be gratefull.
>
> Thanks in advance.
>
> On Thu, Sep 1, 2011 at 10:55 AM, R. Michael Weylandt
> <michael.weylandt@gmail.com> wrote:
> > Mr ". .",
> >
> > MASS::area comes to mind but it may be more helpful if you could say what
> > you are looking for / why integrate is not appropriate it is for whatever
> > you are doing.
> >
> > Strictly speaking, I suppose there are all sorts of "alternatives" to
> > integrate() if you are willing to be really creative and build something
> > from scratch: diff(), cumsum(), lm(), hist(), t(), c(), ....
> >
> > Michael Weylandt
> >
> > On Thu, Sep 1, 2011 at 9:53 AM, B77S <bps0002@auburn.edu> wrote:
> >>
> >> package "caTools"
> >> see ?trapz
> >>
> >>
> >> . wrote:
> >> >
> >> > Hi all,
> >> >
> >> > is there any alternative to the function integrate?
> >> >
> >> > Any comments are welcome.
> >> >
> >> > Thanks in advance.
> >> >
> >> > ______________________________________________
> >> > R-help@r-project.org 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.
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://r.789695.n4.nabble.com/Alternatives-to-integrate-tp3783624p3783645.html
> >> Sent from the R help mailing list archive at Nabble.com.
> >>
> >> ______________________________________________
> >> R-help@r-project.org 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.
> >
> >
>

	[[alternative HTML version deleted]]

