Displaying 1 result from an estimated 1 matches for "vaverage".
Did you mean:
average
2010 Sep 21
3
bivariate vector numerical integration with infinite range
...) for y. Since the integrand has values in R^N I did not
find a built-in function to perform numerical quadrature, so I wrote
my own after some inspiration from a post in R-help,
library(statmod)
## performs 2D numerical integration
## using Gauss-Legendre quadrature
## with N points for x and y
vAverage <- function(f, a1,b1, a2,b2, N=5, ...){
GL <- gauss.quad(N)
nodes <- GL$nodes
weights <- GL$weights
C2 <- (b2 - a2) / 2
D2 <- (b2 + a2) / 2
y <- nodes*C2 + D2
C1 <- (b1 - a1) / 2
D1 <- (b1 + a1) / 2
x <- nodes*C1 + D1
value <- 0
for (ii i...