bugGNU Octave - Bugs: bug #51157, betainc.cc: Inaccurate double...


bug #51157: betainc.cc: Inaccurate double precision results

Submitted by:  None
Submitted on:  Thu 01 Jun 2017 12:59:31 PM UTC  
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Inaccurate Result
Status: ConfirmedAssigned to: None
Originator Name: SchinzilordOriginator Email: -unavailable-
Open/Closed: OpenRelease: dev
Operating System: Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Thu 15 Jun 2017 04:18:43 PM UTC, comment #4:

Octave has a Google Summer of Code programmer this year who's project is improving special functions. He will be taking a look at replacing the Fortran code with something more accurate.

Rik <rik5>
Project Administrator
Sat 10 Jun 2017 01:44:37 AM UTC, comment #3:

I checked the dispatch sequence and Octave is passing the arguments to the dbetai.f function. This function comes from slatec (http://www.netlib.org/slatec/fnlib/). I looked a bit more and the version of the Fortran code used by Octave is up to date. However, the last modification was in 1992 so this is some very old code. It appears that the Fortran code itself is the source of the innaccuracies.

Rik <rik5>
Project Administrator
Sat 10 Jun 2017 01:33:22 AM UTC, comment #2:

Just to check, I made a quick C program which uses the GNU Scientific Library to calculate betainc and it arrives at the same values as Matlab and Wolfram Alpha. So, it would appear that the Fortran code is simply too old and it should be replaced.

Rik <rik5>
Project Administrator
Thu 01 Jun 2017 04:30:45 PM UTC, comment #1:

It's more complicated than that. The actual code that should be called for double precision values is dbetai.f.

Perhaps there is a dispatch problem when passing execution between the Octave interpreter written in C++ (betainc.cc), to liboctave also written in C++ (lo-specfun.cc), and finally to Fortran (dbetai.f). That would be the first thing to check.

If it is dispatching to the correct Fortran code, then maybe the slatec Fortran routines are simply too old.

Rik <rik5>
Project Administrator
Thu 01 Jun 2017 12:59:31 PM UTC, original submission:

Double precision results of function betainc seem to be incorrect.

The following example should not point out the incompatibility with Matlab, but the inaccuracy of Octave implementation.
e.g. try the following:
Octave's results are:
while e.g. Matlab or Wolfram Alpha (CDF[BetaDistribution[250.005, 49750.995], 0.00780]) yields:
To my opinion Octave function betainc.cc
returns double precision, while the underlying
Fortran77 code betai.f:
returns single precision only (according to the source header).
Betainc.cc distinguishes between double and single precision.

All implemented tests performed on betainc.cc go to single precision only (sqrt(eps) in asset function), even if declared as double precision tests.

The deviations have some real life consequences for e.g. Harrell-Davis Estimator, which would return negative weights if no error handling is performed.

Can you please comment on that?



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 15 Jun 2017 04:18:43 PM UTCrik5Release4.2.0=>dev
      Operating SystemMicrosoft Windows=>Any
    Sat 10 Jun 2017 01:44:37 AM UTCrik5Operating SystemAny=>Microsoft Windows
    Sat 10 Jun 2017 01:33:22 AM UTCrik5Operating SystemMicrosoft Windows=>Any
    Thu 01 Jun 2017 04:30:45 PM UTCrik5StatusNone=>Confirmed

    Back to the top

    Powered by Savane 3.1-cleanup1