Re: strange behavior of quad ?



In article <e2j8kh$4rc$1@xxxxxxxxxxxxxxxxxxxxxxxxx>, "Gg" <nc-schuetes@xxxxxxxxxxxxx> wrote:

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)

(snip example)

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

Congratulations! This is the millionth time your question
has been asked! You win an all expenses paid virtual tour
of the internet.

No, quad is not crummy because it does not succeed. Quad
is an adaptive (numerical) quadrature rule. Any such rule
can be caused to fail by someone who chooses their functions
artfully. Numerical computation is sometimes more of a craft
than a science. The craft is in how to make a computational
tool provide the correct answers rapidly while working in
floating point arithmetic.

HTH,
John D'Errico


--
The best material model of a cat is another, or preferably the same, cat.
A. Rosenblueth, Philosophy of Science, 1945

Those who can't laugh at themselves leave the job to others.
Anonymous
.



Relevant Pages

  • 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: quadrature errors
    ... I am using MATLAB's quad function to compute the integrals in the ... which are not done exactly by quad, whatever your differential equation ... its adaptive refinement and if you require a too small tol option, ...
    (sci.math.num-analysis)
  • 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: 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)
  • Re: Explanation of this hypothesis of SUBSTITUTION RULE requested
    ... Arturo Magidin wrote: ... If u=gis a differentiable function whose ... equality of the two integrals as indefinite integrals, ...
    (sci.math)

Loading