R integrate: returns wrong solution (is using wrong quadrature points?)

后端 未结 1 658
梦毁少年i
梦毁少年i 2020-12-12 03:41

I have a function in R which I am trying to integrate, but for some (extreme) values of the function parameters, integrate returns the incorrect solution. I bel

相关标签:
1条回答
  • 2020-12-12 04:29

    you could shift the integration variable to centre the peak,

    wrapper <- function(x, func_mean_v, ...)
       integrandFunc_F(x+func_mean_v, func_mean_v=func_mean_v, ...)
    
    
    integrate(wrapper, rel.tol = 1e-8, lower=-Inf, upper=Inf, func_u= 8, func_u_lowerBar= 8, 
              func_u_upperBar= 8, func_mean_v= 50, func_sigma_v= .1, func_sigma_epsilon= 2, 
              func_sigma_y= 1, func_gamma= 1/1.1, func_rho= .05)
    # 1 with absolute error < 1.3e-09
    
    0 讨论(0)
提交回复
热议问题