python - Calculating Integral of a linear function with respect to a lognormal distributed variable accurately -


i iteratively calculate fixed point of following functional equation:

enter image description here

where h know function , q lognormal distribution. let f* function solving functional equation. know f(z)/z constant. when calculating f numerically python ratio f*(z)/z monotonically increasing. quantify magnitude of error, calculate difference between last , first point of ratio. think source of problem stems numerical integration of function f:

the integral on function f taken respect lognormal distribution stdv sigma , mean zero. numerically, calculate integral follows:

integrand = lambda z: f(z) * phi.pdf(z) result, error = fixed_quad(integrand, int_min, int_max, n=120) 

the error calculate determined integration bounds int_min , int_max. initially, specify integration bounds be:

int_min, int_max = np.exp( - 1 * sigma), np.exp( 1 * sigma) 

however, when change integration bounds cover 95% of probability mass of lognormal distribution, i.e:

int_min, int_max = np.exp( - 2 * sigma), np.exp( 2 * sigma) 

the difference between highest , lowest point in ratio f*(z)/z increases factor 100. numerical value stdv sigma = 0.012.

there 2 comments want make before stating question:

  1. when use function scipy.quadrature instead of scipy.fixed_quad , define error tolerance integration around 1e-8 (the default value of scipy.quadrature), difference between highest , lowest point in ratio not change. indicate integration procedure not source of problem after all?
  2. the level of solution f* depends heavily on integration bounds. level increases factor 3. change of levels might related following question posted on stackoverlow: discontinuity in results when using scipy.integrate.quad

what other effect changing integration bounds might have 1 accuracy of solution f*? if integration routine used can indeed cause problem, there better way calculate integral numerically?


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -