MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Integrate query


"A. E. Siegman" wrote:
> 
> I have a non-negative analytic function f[x] whose area (integral of
> f[x] from 0 to Infinity) is unity.
> 
> I want to find the upper limit such that the integral up to that limit
> will contain a fixed fraction of the total area, i.e. find  a  such that
> 
>    Integrate[f[x], {x,0,a}] == f         (f<=1)
> 
> The question is, what's the most efficient way to program this, if I
> want to find  a  with fair accuracy, and with a variety of different
> functions f[x]?
> 
> Thanks . . .

Not sure this is most efficient, but I'd use a root-finder on an
NIntegrate expression. Here is an example.

In[1]:= f[x_] := 2/Pi * 1/(1+x^2)

In[2]:= Integrate[f[x], {x,0,Infinity}]
Out[2]= 1

In[3]:= cdf[a_] /; 0<=a<1 := FindRoot[NIntegrate[f[x], {x,0,k}]==a,
{k,1,2}]

In[4]:= cdf[.4]
Out[4]= {k -> 0.726543}

I gave FindRoot two points so it would use a secant method, so it would
not issue error messages trying to get a gradient (which I believe
happens because NIntegrate cannot deal with a symbolic upper bound).


Daniel Lichtblau
Wolfram Research


  • Prev by Date: Re: Integrate query
  • Next by Date: Re: Gif file?
  • Previous by thread: Integrate query
  • Next by thread: Re: Integrate query