MathGroup Archive 2009

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

Search the Archive

Re: Using findroot and NIntegrate with a double integral

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97812] Re: Using findroot and NIntegrate with a double integral
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Sun, 22 Mar 2009 05:49:07 -0500 (EST)
  • References: <gq2eq1$e98$1@smc.vnet.net>

Malcolm,

The errors are caused by FindRoot starting with a symbolic evaluation
of its argument (probably to find derivatives) and Nintegrate doesn't
work symbolically. The following solves this problem:

In[31]:= f[lowlim_?NumericQ] :=
 NIntegrate[lognormpdf gammapdf, {s, 0, Infinity}, {x, 0, lowlim}]

In[38]:= FindRoot[f[lowlim] == 0.159, {lowlim, 0.001}]

Out[38]= {lowlim -> 0.000339793}

Cheers -- Sjoerd

On Mar 21, 12:16 pm, Mac <mwjdavid... at googlemail.com> wrote:
> Hello,
>
> I'm working on a typical compound distribution in radar scattering
> theory which involves the lognormal and gamma distribution. What I
> would like to do is calculate the uncertainty bounds (quantiles) for
> the compound distribution which can only be solved numerically. I'm
> hitting a problem with the combination of NIntegrate[] and FindRoot[]
> which requires the integration over two variables (s which needs to be
> integrated out) and (x the quantile). I get a lot of error messages
> complaining about undefined limits of integration.
>
> ------------------------------------
> (1) Error Messages
>
> In[81]:= lognormpdf
> gammapdf
>
> Out[81]= (0.346517 E^(-0.377223 Log[s]^2))/s
>
> Out[82]= (316.228 E^(-((316.228 x)/s)))/s
>
> In[83]:= FindRoot[
>  NIntegrate[lognormpdf gammapdf, {s, 0, Infinity}, {x, 0, lowlim}] ==
=
>   0.159, {lowlim, 0.001}]
>
> During evaluation of In[83]:= NIntegrate::nlim: x = lowlim is not a
> valid limit of integration. >>
>
> During evaluation of In[83]:= NIntegrate::inumr: The integrand
> (109.578 E^(-((316.228 <<6>>)/s)-0.377223 <<1>>))/s^2 has evaluated to
> non-numerical values for all sampling points in the region with
> boundaries {{\[Infinity],0.}}. >>
>
> During evaluation of In[83]:= NIntegrate::inumr: The integrand
> (109.578 E^(-((316.228 <<6>>)/s)-0.377223 <<1>>))/s^2 has evaluated to
> non-numerical values for all sampling points in the region with
> boundaries {{\[Infinity],0.}}. >>
>
> Out[83]= {lowlim -> 0.000339794}
>
> Many thanks for any help.
>
> Malcolm



  • Prev by Date: Re: Orthogonazlie with Method->"Householder"
  • Next by Date: Re: DirectSum (feature request)
  • Previous by thread: Re: Using findroot and NIntegrate with a double integral
  • Next by thread: R: Re: econometrics with mathematica?