Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1129

Percentile Computation errs

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.2
    • Fix Version/s: 3.4
    • Labels:
      None
    • Environment:

      Java 1.8.0

      Description

      In the following test, the 75th percentile is smaller than the 25th percentile, leaving me with a negative interquartile range.

      Bar.java
      @Test public void negativePercentiles(){
      
              double[] data = new double[]{
                      -0.012086732064244697, 
                      -0.24975668704012527, 
                      0.5706168483164684, 
                      -0.322111769955327, 
                      0.24166759508327315, 
                      Double.NaN, 
                      0.16698443218942854, 
                      -0.10427763937565114, 
                      -0.15595963093172435, 
                      -0.028075857595882995, 
                      -0.24137994506058857, 
                      0.47543170476574426, 
                      -0.07495595384947631, 
                      0.37445697625436497, 
                      -0.09944199541668033
              };
              DescriptiveStatistics descriptiveStatistics = new DescriptiveStatistics(data);
      
              double threeQuarters = descriptiveStatistics.getPercentile(75);
              double oneQuarter = descriptiveStatistics.getPercentile(25);
      
              double IQR = threeQuarters - oneQuarter;
              
              System.out.println(String.format("25th percentile %s 75th percentile %s", oneQuarter, threeQuarters ));
              
              assert IQR >= 0;
              
          }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              carlwitt Carl Witt
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: