Uploaded image for project: 'Commons Statistics'
  1. Commons Statistics
  2. STATISTICS-83

Mean returns a non-finite value that can be incorrect

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Won't Fix
    • None
    • None
    • descriptive
    • None
    • Easy

    Description

      The Mean maintains a non-finite value to return in the event that the input contains non-finite values and the result is not finite.

      The non-finite value is a simple sum of the input. This returns the correct result for most cases of nan/infinte values. However if the values contain only one sign of infinity and the other finite values overflow to an opposite infinity before the infinity is encountered the result is incorrect (due to +inf + -inf == nan), e.g. the following test fails:

      double[] values = {Double.MAX_VALUE, Double.MAX_VALUE, Double.NEGATIVE_INFINITY};
      // Computed value = NaN
      Assertions.assertEquals(Double.NEGATIVE_INFINITY, Mean.of(values).getAsDouble());
      

      Investigate alternative options for non-finite results and either: correct the support; or drop support if performance is significantly impacted in order to handle for these rare cases.

      Attachments

        Activity

          People

            Unassigned Unassigned
            aherbert Alex Herbert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: