Add a New Comment (Rich Markup)
Comment Type & Canned Response: None None > Multiple Canned Responses Fixed in development Crash with no stack trace Already fixed in newer version Fixed in stable Bad description Bad description and crash Bad stack trace Obsolete version Duplicate and not fixed Duplicate and needs more info Duplicate and fixed Need info and old
Fixes from GSOC2018 special function project were incorporated during OctConf 2018. Closing report.
This issue is still present in Octave 4.2.0.
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.
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)
betainc which calculates the incomplete Beta function needs better input validation.
Example 1 : NaN inputs
betainc (NaN, 1, 2) ans =
The correct answer should be NaN.
Example 2 : negative or Inf parameters
betainc (0.5, 1, Inf) ***MESSAGE FROM ROUTINE D9LGMC IN LIBRARY SLATEC. ***POTENTIALLY RECOVERABLE ERROR, PROG ABORTED, TRACEBACK REQUESTED * X SO BIG D9LGMC UNDERFLOWS * ERROR NUMBER = 2 * ***END OF MESSAGE ***JOB ABORT DUE TO UNRECOVERED ERROR. 0 ERROR MESSAGE SUMMARY LIBRARY SUBROUTINE MESSAGE START NERR LEVEL COUNT SLATEC DBETAI X IS NOT IN THE RANG 1 2 2 SLATEC D9LGMC X SO BIG D9LGMC UNDE 2 1 4 SLATEC DBETAI P AND/OR Q IS LE ZER 2 2 2 error: betainc: exception encountered in Fortran subroutine xdbetai_
It would be much nicer on the user to simply return NaN for values which are invalid.
Example 3 : x outside range [0, 1]
betainc (2, 1, 2) ***MESSAGE FROM ROUTINE DBETAI IN LIBRARY SLATEC. ***FATAL ERROR, PROG ABORTED, TRACEBACK REQUESTED * X IS NOT IN THE RANGE (0,1) * ERROR NUMBER = 1 * ***END OF MESSAGE ***JOB ABORT DUE TO FATAL ERROR. 0 ERROR MESSAGE SUMMARY LIBRARY SUBROUTINE MESSAGE START NERR LEVEL COUNT SLATEC DBETAI X IS NOT IN THE RANG 1 2 3 SLATEC D9LGMC X SO BIG D9LGMC UNDE 2 1 4 SLATEC DBETAI P AND/OR Q IS LE ZER 2 2 2 error: betainc: exception encountered in Fortran subroutine xdbetai_
One possible strategy would be to validate the inputs and only pass computable values to Fortran. An m-file implementation might be the following
retval = NaN (size (x)); ok = (!isnan (x) & !isnan (a) & !isnan (b) & (a > 0) & (a < Inf) & (b > 0) & (b < Inf) & (x >= 0) & (x <= 1)); retval(ok) = betainc (x(ok), a(ok), b(ok));
This isn't quite right because betainc is implemented in C++ in the file betainc.cc but the concept could be translated.
(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)
Attach Files: Comment:
Depends on the following items: None found
Items that depend on this one: None found
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
Only project members can vote.
Please enter the title of George Orwell's famous dystopian book (it's a date):
Follow 5 latest changes.
Copyright © 2022 Free Software Foundation, Inc. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. The Levitating, Meditating, Flute-playing Gnu logo is a GNU GPL'ed image provided by the Nevrax Design Team. Source Code
Powered by Savane 3.9