integrand <- nimbleFunction(
run = function(x = double(1), theta = double(1)) {
return(x*theta[1])
returnType(double(1))
}
)
fun <- nimbleFunction(
run = function(theta = double(0), lower = double(0), upper = double(0)) {
param = c(theta, 0) # cannot be scalar, so pad with zero.
output = integrate(integrand, lower, upper, param)
returnType(double(1))
return(output)
})
fun(3.1415927, 0, 1)
if (FALSE) {
cfun <- compileNimble(fun)
cfun(3.1415927, 0, 1)
}
Run the code above in your browser using DataLab