commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 27524] New: - Percentile calculation is not correct
Date Mon, 08 Mar 2004 21:46:26 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=27524>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=27524

Percentile calculation is not correct

           Summary: Percentile calculation is not correct
           Product: Commons
           Version: Nightly Builds
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Math
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: scott@duchin.com


I took the microsoft excel example and plugged it in and got the wrong results:
Microsoft (1,3,2,4) 30% --> 1.9 (math returned 1.5)

Looking at the code I saw a few problems.
1) the pos = should be p * (n - 1) / 100.  (the code has a plus sign)
2) the current two conditionals after sorting should be replaced with one:
    if (intPos == length - 1) { return sorted[intPos]; }
3) the lower and upper should be retrieved from:
    lower = sorted[intPos] and upper = sorted[intPos + 1]
4) i believe passing in a zero percentile is okay so the top test should read
   || p < 0) ... (remove the = sign)

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message