Re: Using findroot and NIntegrate with a double integral

• To: mathgroup at smc.vnet.net
• Subject: [mg97825] Re: [mg97770] Using findroot and NIntegrate with a double integral
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Sun, 22 Mar 2009 05:51:41 -0500 (EST)

```You need to insure that numerical techniques are only called with numerical rather than symbolic arguments.

lognormpdf[s_] = (0.346517 E^(-0.377223 Log[s]^2))/s;

gammapdf[x_, s_] = (316.228 E^(-316.228 x/s))/s;

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

FindRoot[f[lowlim] == 0.159, {lowlim, 0.001}]

{lowlim->0.000339793}

f[lowlim] /. %

0.159

Bob Hanlon

---- Mac <mwjdavidson 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: Problem using a dialog and dynamic
• Next by Date: Re: Orthogonazlie with Method->"Householder"
• Previous by thread: Using findroot and NIntegrate with a double integral
• Next by thread: Re: Using findroot and NIntegrate with a double integral