On 09/04/2009 8:07 AM, Richard Morey wrote:
Hi everyone,
I saw this problem dealt with here:
http://markmail.org/search/list:r-project?q=integrate#query:list%3Ar-project%20integrate+page:1+mid:qczmyzr676pgmaaw+state:results
but no one answered that request that I can tell. I'm having the same
p
On 09/04/2009 10:19 AM, Ravi Varadhan wrote:
Richard,
Your function f() is already vectorized, and it works well (see below). Therefore, you don't need to create f2().
He did say that this was a simplified example.
The problem appears to be in Vectorize, which uses match.call() to get
the
Richard,
I didn't read the last part of your email that you "do" want to Vectorize your
function. Sorry about that.
Here is a solution using "sapply" to vectorize your function.
f <- function(x, const) 2^x + const
f2 <- function(x, ...) sapply(x, function(x) f(x, ...) )
> integrate(f2, 0.5,
Richard,
Your function f() is already vectorized, and it works well (see below).
Therefore, you don't need to create f2().
f = function(x, const) 2^x + const
testval = 2
> integrate(f, 0.5, 1, const=testval)
1.845111 with absolute error < 2.0e-14
Ravi.
__
On 09/04/2009 8:07 AM, Richard Morey wrote:
Hi everyone,
I saw this problem dealt with here:
http://markmail.org/search/list:r-project?q=integrate#query:list%3Ar-project%20integrate+page:1+mid:qczmyzr676pgmaaw+state:results
but no one answered that request that I can tell. I'm having the same
p
5 matches
Mail list logo