bugGNU Octave - Bugs: bug #34405, Validation for betainc() inputs


bug #34405: Validation for betainc() inputs

Submitted by:  Rik <rik5>
Submitted on:  Tue 27 Sep 2011 03:30:07 AM UTC  
Category:  Libraries Severity:  3 - Normal
Priority:  3 - Low Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  dev Operating System:  GNU/Linux

Add a New Comment(Rich Markup)

You are not logged in

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


Tue 27 Mar 2018 12:20:18 AM UTC, comment #4:

Fixes from GSOC2018 special function project were incorporated during OctConf 2018. Closing report.

Rik <rik5>
Project Administrator
Sat 19 Nov 2016 03:31:52 PM UTC, comment #3:

This issue is still present in Octave 4.2.0.

Hartmut <hardy>
Tue 27 Sep 2011 04:55:06 PM UTC, comment #2:

I'm moving the priority down a few notches. I would like to see this fixed since it impacts betacdf.m, binocdf.m, fcdf.m, nbincdf.m, and tcdf.m. On the other hand, those functions mostly already validate their inputs before calling betainc(). The validation isn't perfect but I'm willing to let the corner case of a,b=Inf slide for now.

Since the revisions to the statistics distribution functions were done on the default branch I would say we are safe to go slow there and implement any proper fix you like (templates, etc.). For the existing stable branch let's apply the lo-specfun.cc patch.

Rik <rik5>
Project Administrator
Tue 27 Sep 2011 04:51:19 AM UTC, comment #1:

A simple fix would be to just add the checks in the betainc functions in lo-specfun.cc that accept scalar values. See the attached patch.

But then we are checking all inputs all the time, even when one or two are scalars and the others are large arrays. But before attempting to fix this in the code that performs the loops, I think it would be better to first convert those functions to use templates to avoid some duplication.

I can work on this if you would like, but I don't want to change the stable branch to use templates, and I don't want to have to add the checks to all the current functions in lo-specfun.cc. So what do you think we should do? Add the simple but slow check to the stable branch, then make a better fix using templates for the default branch?

(file #24030)

John W. Eaton <jwe>
Project Administrator
Tue 27 Sep 2011 03:30:07 AM UTC, original submission:

betainc which calculates the incomplete Beta function needs better input validation.

Example 1 : NaN inputs

The correct answer should be NaN.

Example 2 : negative or Inf parameters

It would be much nicer on the user to simply return NaN for values which are invalid.

Example 3 : x outside range [0, 1]

One possible strategy would be to validate the inputs and only pass computable values to Fortran. An m-file implementation might be the following

This isn't quite right because betainc is implemented in C++ in the file betainc.cc but the concept could be translated.

Rik <rik5>
Project Administrator


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

Attach Files:

Attached Files
file #24030:  diffs.txt added by jwe (887B - text/plain)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by jwe (Updated the item)
  • -email is unavailable- added by rik5 (Submitted the item)

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

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-03-27 rik5 StatusPostponed => Fixed
        Open/ClosedOpen => Closed
    2016-11-18 mtmiller StatusNone => Postponed
    2011-09-27 rik5 Priority5 - Normal => 3 - Low
    2011-09-27 jwe Attached File- => Added diffs.txt, #24030

    Back to the top

    Powered by Savane 3.4