[R] Using integrate() with vectors as boundaries rather than scalars

From: Tobias <tobias_elbert_at_hotmail.com>
Date: Wed 11 Oct 2006 - 03:59:54 GMT

Hi all

my apologies if above title is misleading, but here is my problem anyways:

I need to evaluate an integral n times. Since I can't get my head around vectorization as of yet, I have coded it up in a loop, i.e.:

for (i in 1:n)


    z[i] <- integrate(dnorm,x[i],Inf)


Since n is quite large in my operation, ~40000, I would rather stack all the elements of x into a vector and then evaluate the integral for each vector element in x up to infinity. So that the operation would look something like this:

z <- integrate(dnorm,x,Inf)

I am not sure if this works, as I am new to R, however managed the equivalent in MatLab. Is this possible at all? If yes, your input would be highly appreciated.



View this message in context: http://www.nabble.com/Using-integrate%28%29-with-vectors-as-boundaries-rather-than-scalars-tf2421074.html#a6749926
Sent from the R help mailing list archive at Nabble.com.

R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed Oct 11 14:02:44 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 11 Oct 2006 - 05:30:09 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.