hello I work on the probabilities of bivariate normal distribution. I need integrate the following function. f (x, y) = exp [- (x ^ 2 + y ^ 2 + x * y)] with - ∞ ≤ x ≤ 7.44 and - ∞ ≤ y ≤ 1.44 , either software R or matlab Version R 2009a Thank you for helping me Regards Mezouara hicham PhD in Metrology Hicham_dess @ yahoo.fr [[alternative HTML version deleted]]
R. Michael Weylandt
2013-Apr-22 14:05 UTC
[R] numerical integration of a bivariate function
On Mon, Apr 22, 2013 at 2:04 PM, Hicham Mezouara <hicham_dess at yahoo.fr> wrote:> hello > I work on > the probabilities of bivariate normal distribution. I need > integrate the > following function. > f (x, y) = exp [- (x ^ 2 + y ^ 2 + x * y)] with - ? ? x ? > 7.44 and - ? ? y ? 1.44 , either software R or matlab Version R 2009aWell, we're not going to help you with MATLAB, but I might suggest you look at the function pmvnorm() in the mvtnorm package available off CRAN at http://cran.r-project.org/web/packages/mvtnorm/index.html or by the installation methods relevant to your OS and version of R. Best, Michael
On 22-04-2013, at 15:04, Hicham Mezouara <hicham_dess at yahoo.fr> wrote:> > hello > I work on > the probabilities of bivariate normal distribution. I need > integrate the > following function. > f (x, y) = exp [- (x ^ 2 + y ^ 2 + x * y)] with - ? ? x ? > 7.44 and - ? ? y ? 1.44 , either software R or matlab Version R 2009aThis discussion in a far and distant past may help you: https://stat.ethz.ch/pipermail/r-help/2004-October/059494.html I tried this f <- function(x,y) exp(- (x ^ 2 + y ^ 2 + x * y)) integrate(function(y) { sapply(y, function(y) { integrate(function(x) f(x,y), -Inf, 7.44)$value }) }, -Inf, 1.44) # 3.486503 with absolute error < 0.00013 library(cubature) h <- function(z) f(z[1],z[2]) adaptIntegrate(h,c(-10,-10),c(1.44,7.44)) # $integral # [1] 3.486496 # # $error # [1] 3.415381e-05 # # $functionEvaluations # [1] 4267 # # $returnCode # [1] 0 adaptIntegrate doesn't like -Inf so I used -10. Berend