strange behavior of quad ?
- From: "Gg" <nc-schuetes@xxxxxxxxxxxxx>
- Date: Mon, 24 Apr 2006 21:24:09 +0200
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
.
- Follow-Ups:
- Re: strange behavior of quad ?
- From: Steven Lord
- Re: strange behavior of quad ?
- From: Roger Stafford
- Re: strange behavior of quad ?
- From: John D'Errico
- Re: strange behavior of quad ?
- Prev by Date: One more question about positive definite matrices
- Next by Date: Re: best optimization
- Previous by thread: One more question about positive definite matrices
- Next by thread: Re: strange behavior of quad ?
- Index(es):
Relevant Pages
|
Loading