bugGNU Octave - Bugs: bug #40470, display routine for variables...

 
 

bug #40470: display routine for variables doesn't detect need for scientific format

Submitter:  None
Submitted:  Mon 04 Nov 2013 03:04:56 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Alan Genz Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 07 Nov 2013 06:44:27 PM UTC, comment #7: 

Verified the fix.  Closing report.

Rik <rik5>
Group administrator
Thu 07 Nov 2013 06:45:39 AM UTC, comment #6: 

I checked in the following changeset:

http://hg.savannah.gnu.org/hgweb/octave/rev/5ac0545fb4c0

John W. Eaton <jwe>
Group administrator
Thu 07 Nov 2013 03:15:30 AM UTC, comment #5: 

So the problem seems to be a regression in the print routine, rather than a problem with normcdf.  I'm re-titling the bug to reflect that.  Simple test code to replicate this is:


x = [1 2e-6]
x =

   1.00000   0.00000


Running the same code under 3.6.4 produces:

x = [1 2e-6]
x =

   1.0000e+00   2.0000e-06



Rik <rik5>
Group administrator
Thu 07 Nov 2013 01:50:35 AM UTC, comment #4: 

I don't think there's an underflow problem, I think it's simply that values are being displayed with a fixed format when combined in a matrix with other values.


octave:1> format
octave:2> -7, normcdf(-7)
ans = -7
ans =    1.2798e-12
octave:3> [-7, normcdf(-7)]
ans =

  -7.00000   0.00000

octave:4> format long
octave:5> [-7, normcdf(-7)]
ans =

  -7.000000000000000   0.000000000001280


Mike Miller <mtmiller>
Group Member
Thu 07 Nov 2013 01:47:09 AM UTC, comment #3: 

Here's some more results,  what I get with

3.6.4:


octave:1> disp([-7 normcdf(-7)])
  -7.0000e+00   1.2798e-12


dev:


octave:1> disp([-7 normcdf(-7)])
  -7.00000   0.00000


Mike Miller <mtmiller>
Group Member
Wed 06 Nov 2013 08:59:01 AM UTC, comment #2: 

I cannot reproduce the problem with 3.6.2, nor with http://octave-online.net/ (which is 3.7.2+).

Marco

Marco Caliari <caliari>
Group Member
Mon 04 Nov 2013 08:13:52 PM UTC, comment #1: 

Still present on the development branch.  Probably can't squeeze this in before the 3.8 release, but possibly in the first bug fix release.

Rik <rik5>
Group administrator
Mon 04 Nov 2013 03:04:56 PM UTC, original submission:  

octave:21> for t=-[7:10],disp([t exp(-t^2/2) normcdf(t)]),end
  -7.0000e+00   2.2897e-11   1.2798e-12
  -8.0000e+00   1.2664e-14   6.1062e-16
  -9.00000   0.00000   0.00000
  -10.00000    0.00000    0.00000
octave:22> for t=-[7:10],disp([t exp(-t^2/2)]),end
  -7.0000e+00   2.2897e-11
  -8.0000e+00   1.2664e-14
  -9.0000e+00   2.5768e-18
  -1.0000e+01   1.9287e-22
octave:23> for t=-[7:10],disp([t normcdf(t)]),end
  -7.0000e+00   1.2798e-12
  -8.0000e+00   6.1062e-16
  -9   0
  -10    0

The above results are inconsistent; normcdf should not
underflow to 0 until t is near -37.
But why is exp also affected?
This bug has been reported previously (see #29543).
The simple fix is to use normcdf(t) = erfc-t/sqrt(2))/2:
octave:27> for t=-[7:10],disp([t exp(-t^2/2) ...
                   erfc(-t/sqrt(2))/2]),end
  -7.0000e+00   2.2897e-11   1.2798e-12
  -8.0000e+00   1.2664e-14   6.2210e-16
  -9.0000e+00   2.5768e-18   1.1286e-19
  -1.0000e+01   1.9287e-22   7.6199e-24

Here are some Matlab results for comparison

>> for t=-[7:10],disp([t exp(-t^2/2) ...

     normcdf(t)]),end                    
           -7   2.2897e-11   1.2798e-12
           -8   1.2664e-14    6.221e-16
           -9   2.5768e-18   1.1286e-19
          -10   1.9287e-22   7.6199e-24


Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    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 group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-11-07 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2013-11-07 rik5 SummaryWrong output from normcdf (with exp?) for negatives display routine for variables doesn't detect need for scientific format
    2013-11-07 mtmiller Item GroupInaccurate Result Regression
        Release3.2.4 dev
    2013-11-04 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code