commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <>
Subject [jira] [Commented] (MATH-805) Percentile calculation is very slow when input data are constants
Date Wed, 18 Jul 2012 21:43:35 GMT


Thomas Neidhart commented on MATH-805:

The evaluation of the percentile uses a partition method to sort the data around a pivot element
(element that are smaller are before the pivot element, and elements that are larger are behind

Now in case of an array with lots of equal values, this can lead to some kind of staircase
situation, where the pivot element is just slowly increased from the bottom index and the
full array of values has to be evaluated in each iteration. The problem is in the partition
method of

    while (i < j) {
       while ((i < j) && (work[j] >= value)) {
       while ((i < j) && (work[i] <= value)) {

The comparisons here use >= and <= while it should be > and <.
> Percentile calculation is very slow when input data are constants
> -----------------------------------------------------------------
>                 Key: MATH-805
>                 URL:
>             Project: Commons Math
>          Issue Type: Improvement
>    Affects Versions: 3.0
>            Reporter: Benoit de Rancourt
>            Assignee: Thomas Neidhart
>            Priority: Minor
>              Labels: performance, test
> I use the Percentile class to calculate quantile on a big array (10^6 entries). When
I have to test the performance of my code, I notice that the calculation of quantile is at
least 100x slower when my data are constants (10^6 of the same nomber). Maybe the Percentile
calculation can be improved for this special case.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message