On Thu, 15 Oct 2015, Sven Schreiber wrote:
Am 15.10.2015 um 16:43 schrieb Riccardo (Jack) Lucchetti:
> On Thu, 15 Oct 2015, Sven Schreiber wrote:
>
>> It seems (not proven yet, just tentatively) the small number is coming
>> from the cdf() function.
>
> Now, the remark I'm about to make is so general and abstract that the
> chances that I'm in fact just uttering rubbish is very high, but:
> calculating CDFs in non-trivial cases (eg the Gaussian) works
> *reasonably* well in a *reasonably* small interval. For example, cnorm()
> is to be trusted between -6 and 6, roughly. Outside that range, anything
> can happen. If your model pushes the calculation of a CDF in such a way
> that you need that ridiculously high level of precision, then I would
> guess something's wrong with your model or with your data.
Of course not ;-)
No really, I don't need that precision, I would be fine with treating
anything below 1e-3 as zero. It's the cdf() function which insists on
returning such numbers like 1e-310, and this was propagated. It's like a
t-statistic that sometimes becomes large and thus the p-value also is
reported as ridiculously small.
Perhaps there is a case to introduce a new option for the "set" command,
instructing gretl to set any number to zero which is below some
threshold (in abs value). OTOH this would probably slow down all
calculations (?).
The C library already does that. There are two stages to underflow (as
we head towards zero): first you get a subnormal floating-point
value (with one or more leading zeros in the significand, hence losing
precision), then if the value is too small to be represented by even a
subnormal it collapses to zero.
I think the only real issue for gretl is whether we should consider
underflow an error. Up till now we have done that in some of our
arithmetical functions -- but not quite deliberately, rather as a
side-effect of considering all cases where the C library sets a
non-zero "errno" value as true error conditions. Now (git) we exercise
a more fine-grained judgment, and let underflow pass.
Allin