Skip to content

qbeta function (FYI, compiler bug)

6 messages · terra@diku.dk, Peter Dalgaard, Martin Maechler

#
Hi there,

this is just to let you know that the qbeta function, which was
copied from R into Gnumeric, has been confirmed to be miscompiled
by gcc 2.96 on Linux.  (That's Red Hat's compiler.)

This shows by qbeta(0.025,4,0.5) ending up taking the wrong
branch of "if (alpha <= 0.5)".

We compile things in a different context, so this may or may not
affect you.  The qbeta function was taken from R 0.64.

Morten

http://www.gnome.org/gnumeric/
http://bugzilla.gnome.org/show_bug.cgi?id=68057
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Morten Welinder <terra@diku.dk> writes:
Which version? The ones in RH 7.1 and later has seemed to be quite
solid, whereas the one shipping with 7.0 was worthless (and so was the
first 50 or so fixup revisions of the compiler that should never have
been released...).
0.64 is 2.5 years old! Several things have been fixed since then,
including at least one really bad bug in qbeta(). You might want to
track the development of R a bit closer (&maybe note that R's math
library can now be compiled a a standalone dynlib).

The "if (alpha <= 0.5)" line has disappeared in recent versions, but I
don't see any trouble in the current version, compiled with
gcc-2.96-81:
[1] 0.025
#
> copied from R into Gnumeric, has been confirmed to be miscompiled
   > by gcc 2.96 on Linux.  (That's Red Hat's compiler.)

   Which version? The ones in RH 7.1 and later has seemed to be quite
   solid [...]

The problem is seen with "gcc version 2.96 20000731 (Red Hat Linux 7.1
2.96-98)".  That would appear to be newer than yours.

   0.64 is 2.5 years old!  Several things have been fixed since then,
   [...]

Ahem, :-)  I did look at some point and nothing much had changed.
I've put it on my todo list to have a look.  (We might switch to
GSL since that has more code that we would like to offload from
our backs.  Also, the packing seems to be nicer.  On the other hand,
I have no idea of how reliable it is.)

Thanks,

Morten
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Morten Welinder <terra@diku.dk> writes:
GSL doesn't seem to have the distribution functions. Lots of random
variable generation, but no pbeta/qbeta and friends. In general, the
support for statistical analysis is quite weak and strongly slanted
towards physics applications.
#
>> this is just to let you know that the qbeta function,
    >> which was copied from R into Gnumeric, has been confirmed
    >> to be miscompiled by gcc 2.96 on Linux.  (That's Red
    >> Hat's compiler.)

    Morten>    Which version? The ones in RH 7.1 and later has
    Morten> seemed to be quite solid [...]

    Morten> The problem is seen with "gcc version 2.96 20000731
    Morten> (Red Hat Linux 7.1 2.96-98)".  That would appear to
    Morten> be newer than yours.

    Morten>    0.64 is 2.5 years old!  Several things have been
    Morten> fixed since then, [...]

    Morten> Ahem, :-) I did look at some point and nothing much

if you measure "much" in percentage of changed source code. 
Sometimes a bug is fixed by replacing "<" with "<=" etc... which
is not ``much'' .. :-)
Really, please don't use anything <= R 1.0; and indeed, since
you should upgrade anyway, please use the current 1.4.0.

    Morten> had changed.  I've put it on my todo list to have a
    Morten> look.  (We might switch to GSL since that has more
    Morten> code that we would like to offload from our backs.
    Morten> Also, the packing seems to be nicer.  On the other
    Morten> hand, I have no idea of how reliable it is.)

Well, without wanting to brag, it still must be said:
The things we do with distributions, we do **much** better than
the GSL (which has quite a wider scope of numerical analysis
than we do), at least for the few cases I looked at.

Martin Maechler <maechler@stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Thanks all.

I checked 1.4 and a clever head here noticed that one problem still
seems to be there.  In the !IEEE_754 case, either qbeta should zero
errno or else pbeta_raw should.

A similar problem seems to be in qgamma.

Morten
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._