strange behavior of quad ?



Dear All,

I am trying to do some analysis involving lognormal (and other)
distributions which often involves indefinite integrals (i.e. integrals with
limits -inf and/or +inf).
I was trying to do this like

quadl(@(x)(lognpdf(x,1,2)),lowlim, hilim)

where lowlim and hilim are very small or very large numbers supposedly
proxies for -inf and +inf.
I noticed the following oddity of quad and quadl:

First Test:
----------------------------------------------
quad(@(x)(lognpdf(x,1,2)),0, 1e40)

ans =

0
----------------------------------------------
This sure looks strange, doesn't it ? But it did not give us any warning or
error.

Second test:
----------------------------------------------
quadl(@(x)(lognpdf(x,1,2)),0.0000001, 1e13)

ans =

1.0000

quadl(@(x)(lognpdf(x,1,2)),0.00000000001, 1e13)

ans =

1.2222e-016

quad(@(x)(lognpdf(x,1,2)),0.00000000001, 1e13)

ans =

9.8571e-017

quadl(@(x)(lognpdf(x,1,2)),0, 1e13)

ans =

1.7873e-039
----------------------------------------------

Question:
- Is it fair to say that the implementation of quad and quadl is somewhat
crummy, since it gives us wrong answers without warning ?
- Is there a better way to compute those indefinite integrals ? Especially
considering the fact that I know beforehand that all integrals will
converge.

Note that it might be possible to come up with more or less ingenious ways
to "preprocess" the integrals, so that quad or quadl might work. But
generally my integrands will be more complicated than logn. In addition I
would like to program something generic, which does not require intelligent
intervention.

Thank you for any hints and help
gg


.



Relevant Pages

  • Re: strange behavior of quad ?
    ... distributions which often involves indefinite integrals (i.e. integrals with ... Is it fair to say that the implementation of quad and quadl is somewhat ... - Is there a better way to compute those indefinite integrals? ...
    (comp.soft-sys.matlab)
  • Re: how does numerical integration work for infinite limits?
    ... But Matlab doesnot work it out correctly: ... Wow, what a hardcore hack! ...
    (comp.soft-sys.matlab)
  • Re: strange behavior of quad ?
    ... distributions which often involves indefinite integrals (i.e. integrals ... QUAD is an adaptive quadrature routine. ... integration into two subintervals, ... QUADL works using a similar algorithm to the one QUAD uses, ...
    (comp.soft-sys.matlab)
  • Re: quadl integration plot
    ... like to use quadl. ... Here's an example I just threw together using QUADGK. ... % Y is the array of from integrals from Xto X. ...
    (comp.soft-sys.matlab)
  • Re: Wanted: Lazarus Long rebuttal quote
    ... In rec.arts.sf.written Mike Schilling wrote: ... was the fact that in integrating there were perfectly valid ... Did the exams really give you difficult indefinite integrals? ...
    (rec.arts.sf.written)

Loading