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: LibrariesSeverity: 3 - Normal
Priority: 3 - LowItem Group: Incorrect Result
Status: NoneAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: GNU/Linux

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

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

 

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 File(s):
   
   
Comment:
   

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
  • -unavailable- added by jwe (Updated the item)
  • -unavailable- added by rik5 (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 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 27 Sep 2011 04:55:06 PM UTCrik5Priority5 - Normal=>3 - Low
    Tue 27 Sep 2011 04:51:19 AM UTCjweAttached File-=>Added diffs.txt, #24030

    Back to the top


    Powered by Savane 3.1-cleanup