Skip to contents

Expected value of a function of two independent standard Gaussian variables

Usage

integrate2_normal(f, ...)

Arguments

f

Function to integrate over. Input to f should be a length 2 vector.

...

Additional arguments to hcubature

Value

A numeric value $$ \int \int f(x, y) \varphi(x) \varphi(y) dx dy, $$

where \( \varphi(\cdot)\) is the standard Gaussian density.

Examples

if (FALSE) {
# Second moment of a Gaussian
# tol = 0.0001, true value = 2, evaluated = 2.000001
f <- function(x) x[1]^2 + x[2]^2
integrate2_normal(f, tol = 1e-4)
}