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

Tobias tobias_elbert at hotmail.com
Wed Oct 11 05:59:54 CEST 2006


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.

Regards

Tobias
-- 
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.



More information about the R-help mailing list