Solving double (n-tuple) multivariate integrals in R -
i write code solve kind of equations:
for wrote code below, not solve problem. have ideas possibility solve kind of integrals in r?
t_0 = 15 mu = 0.1 lambda = 0.8 f = function(x1,x2) exp(mu*(x1+x2))*dexp(log(lambda)*(x1+x2)) f_comp = function(x2) f(x1,x2) f_1 = function(x1) {integrate(f_comp,upper = t_0, lower = x1)} result = integrate(f = f_1, lower = 0, upper = t_0)$value
--------- edit:
given answer below, adapt code example, still think not correct one, @ least value 0 integral not make sense.
integrate(function(x1) { sapply(x1, function(x1){ integrate(function(x2) exp(mu*(x1+x2))*dexp(log(lambda)*(x1+x2)), lower = x1, upper = t_0)$value }) }, 0, t_0)
by way, buid general procedure (that why not calculate integral hand). not double integrals, n-tuples integrals, need general procedure kind of calculations.
Comments
Post a Comment