[R] bivariate vector numerical integration with infinite range
baptiste auguie
baptiste.auguie at googlemail.com
Tue Sep 21 22:44:43 CEST 2010
Got it, thanks!
baptiste
On 21 September 2010 22:38, Hans W Borchers <hwborchers at googlemail.com> wrote:
> baptiste auguie <baptiste.auguie <at> googlemail.com> writes:
>
>>
>> Thanks. I am having trouble getting adaptIntegrate to work with a
>> multivalued integrand though, and cannot find a working example.
>> Anyone had better luck with it?
>
> The function to be integrated needs a vector as input:
>
> f <- function(x) {
> res <- 1 / (sqrt(x[1])*(1+x[1]))
> c(res, res/2, 2*res)
> }
>
> adaptIntegrate(f, lowerLimit=c(0.1, 0), upperLimit=c(10, 1), fDim = 3)
> $integral
> [1] 1.9164832 0.9582416 3.8329665
>
> $error
> [1] 1.265252e-05 6.326261e-06 2.530504e-05
>
> $functionEvaluations
> [1] 323
>
> $returnCode
> [1] 0
>
> Hans Werner
>
>> library(cubature)
>> >
>> > f <- function(x, y) {
>> + res <- 1 / (sqrt(x)*(1+x))
>> + c(res, res/2, 2*res)
>> + }
>> >
>> > adaptIntegrate(f, lowerLimit=c(0.1, 0), upperLimit=c(10, 1), fDim = 3)
>> [1] "adaptIntegrate: Error in evaluation function f(x) for x="
>> res
>> [1,] 0.07355275 0.03677638 0.1471055
>> [2,] 0.94280904 0.47140452 1.8856181
>> Error in adaptIntegrate(f, lowerLimit = c(0.1, 0), upperLimit = c(10, :
>> adaptIntegrate: Result f(x) is not numeric or has wrong dimension
>>
>> Best,
>>
>> baptiste
>>
>
> ______________________________________________
> 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