保温功能明显相同,

时间:2018-11-06 13:24:57

标签: r

假设我有

g = function (x) matrix(exp(-(x[1,]^2 + x[2,]^2)/2) / (2*pi))

h = function (x) {(exp(-(x[1]^2 + x[2]^2)/2) / (2 * pi))}
f = function (x) matrix(h(as.vector(x)))

fg是否具有相同的功能?

> f(matrix(c(1,2),ncol=1))
           [,1]
[1,] 0.01306423

> g(matrix(c(1,2),ncol=1))
           [,1]
[1,] 0.01306423

似乎如此,但是我使用hcubature

> hcubature(g, lowerLimit=c(0,0), upperLimit=c(3,3), vectorInterface=TRUE)
$integral
[1] 0.2486516

$error
[1] 1.855633e-06

$functionEvaluations
[1] 6

$returnCode
[1] 0

> hcubature(f, lowerLimit=c(0,0), upperLimit=c(3,3), vectorInterface=TRUE)
$integral
[1] -4.500035e-18

$error
[1] 2.641648e-17

$functionEvaluations
[1] 55

$returnCode
[1] 0

PS我也担心返回码为0。

0 个答案:

没有答案
相关问题