Re: NIntegrate[UnitStep[...]PDF[...],{x,...}] hard to integrate
- To: mathgroup at smc.vnet.net
- Subject: [mg93468] Re: NIntegrate[UnitStep[...]PDF[...],{x,...}] hard to integrate
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Mon, 10 Nov 2008 03:30:01 -0500 (EST)
On 11/9/08 at 5:26 AM, erwann.rogard at gmail.com (er) wrote: >Much helpful, thanks! >OK, but you have to assume that there are exactly 2 roots to f[x]- >t,right? >That may be the case for particular values of t, but for others I >may have, for example, a left interval (only 1 root) etc. So, what >if I need say g[t]==0.95, instead of 0.25? If there is only one root, then it follows your integral is either CDF[NormalDistribtuon[0,1/2],x] or 1 - CDF[NormalDistribution[0,1/2],x] depending on where you set t. In any case, it will always be faster to find the appropriate roots of t-f[x] then use the CDF function to compute g rather than doing the numerical integration. >and what if I need to carry out these computations for various definitions= of f? That simply changes the part where you find the roots. When you use UnitStep[t - f[x]] PDF[NormalDistribution the effect of the UnitStep is to programmatically set the limits for the integration. Selecting a different f[x] simply selects different limits, different points where the cumulative distribution function needs to be evaluated. It is far less computational effort to find the points where UnitStep[t - f[x]] is one than it is to do the numerical integration problem.