[R] adaptIntegrate - how to pass additional parameters to the integrand
baptiste auguie
baptiste.auguie at googlemail.com
Tue May 3 22:54:24 CEST 2011
Hi,
The package maintainer is aware of this feature request. In the
meantime, I've used Currying,
require(cubature)
f <- function(x, a) cos(2*pi*x*a) # a simple test function
adaptIntegrate(roxygen::Curry(f, a=0.2), lower=0, upper=2)
HTH,
baptiste
On 4 May 2011 05:57, Ravi Varadhan <rvaradhan at jhmi.edu> wrote:
> Ok, I get it.
>
> require(cubature)
>
> f <- function(x, a) cos(2*pi*x*a) # a simple test function
>
> # this works
> a <- 0.2
> adaptIntegrate(function(x, argA=a) f(x, a=argA), lower=0, upper=2)
>
> # but this doesn't work
> rm(a)
> adaptIntegrate(function(x, argA=a) f(x, a=argA), lower=0, upper=2, a=0.2)
>
> Ravi.
>
> ________________________________________
> From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of Uwe Ligges [ligges at statistik.tu-dortmund.de]
> Sent: Tuesday, May 03, 2011 7:17 AM
> To: HC
> Cc: r-help at r-project.org
> Subject: Re: [R] adaptIntegrate - how to pass additional parameters to the integrand
>
> On 03.05.2011 06:43, HC wrote:
>> Hello,
>>
>> I am trying to use adaptIntegrate function but I need to pass on a few
>> additional parameters to the integrand. However, this function seems not to
>> have the flexibility of passing on such additional parameters.
>>
>> Am I missing something or this is a known limitation. Is there a good
>> alternative to such restrictions, if there at all are?
>
>
> Looks like you are talking about the cubature package rather than about
> base R. Frr the latter question: Please ask the package maintainer
> rather than the list. Ideally send him code to implement the requested
> feature and the maintainer will probably add your code. Not all package
> maintainers read R-help.
>
> For an ad hoc solution:
>
> Just use
>
> adaptIntegrate(function(x, argA=a, argB=b) f(x, argA=argA, argB=argB),
> ......)
>
> in order to set additional arguments for the function call.
>
> Uwe Ligges
>
>
>
>
>
>
>
>
>
>
>> Many thanks for your time.
>> HC
>>
>>
>> --
>> View this message in context: http://r.789695.n4.nabble.com/adaptIntegrate-how-to-pass-additional-parameters-to-the-integrand-tp3491701p3491701.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at 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.
>
> ______________________________________________
> R-help at 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.
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list