You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Bill Barker (JIRA)" <ji...@apache.org> on 2010/06/11 05:01:14 UTC

[jira] Issue Comment Edited: (MATH-373) StatUtils.sum returns NaN for zero-length arrays

    [ https://issues.apache.org/jira/browse/MATH-373?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12877689#action_12877689 ] 

Bill Barker edited comment on MATH-373 at 6/10/10 10:58 PM:
------------------------------------------------------------

The consensus of the commons-math developers is that, since the current behavior is documented in 2.x, that this will have to wait for 3.0.  Fixing this in 2.x would introduce a too large incompatibility change to include in 2.x.

I can attach a patch against 2.x that fixes this, as long as anybody using the patch understands that it isn't supported.



      was (Author: billbarker):
    The consensus of the commons-math developers is that, since the current behavior is documented in 2.x, that this will have to wait for 3.0.  Fixing this would introduce a too large incompatibility change to include in 2.x.

I can attach a patch against 2.x that fixes this, as long as anybody using the patch understands that it isn't supported.


  
> StatUtils.sum returns NaN for zero-length arrays
> ------------------------------------------------
>
>                 Key: MATH-373
>                 URL: https://issues.apache.org/jira/browse/MATH-373
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.1
>            Reporter: Roman Werpachowski
>             Fix For: 3.0
>
>
> StatUtils.sum returns NaN for zero-length arrays, which is:
> 1. inconsistent with the mathematical notion of sum: in maths, sum_{i=0}^{N-1} a_i will be 0 for N=0. In particular, the identity
> sum_{i=0}^{k-1} a_i + sum_{i=k}^{N-1} = sum_{i=0}^{N-1}
> is broken for k = 0, since NaN + x = NaN, not x.
> 2. introduces hard to debug erros (returning a NaN is one of the worst forms of reporting an exceptional condition, as NaNs propagate silently and require manual tracing during the debugging)
> 3. enforces "special case" handling when the user expects that the summed array can have a zero length.
> The correct behaviour is, in my opinion, to return 0.0, not NaN in the above case.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.