You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Benoit de Rancourt (JIRA)" <ji...@apache.org> on 2012/07/18 10:43:34 UTC
[jira] [Comment Edited] (MATH-805) Percentile calculation is very
slow when input data are constants
[ https://issues.apache.org/jira/browse/MATH-805?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13416943#comment-13416943 ]
Benoit de Rancourt edited comment on MATH-805 at 7/18/12 8:42 AM:
------------------------------------------------------------------
Hello,
Here is a simple test case :
{code:title=testPercentile.java|borderStyle=solid}
/**
* Test the Percentile calculation
*/
public static void testPercentile() {
final double CONST_NUMBER = 18.;
final double PERCENT = 5.;
final int DISTRIBUTION_SIZE = (int) 1e5;
double[] distribution = new double[DISTRIBUTION_SIZE];
Percentile percentile = new Percentile(PERCENT);
Random random = new Random(System.nanoTime());
// filling the array with random number
for (int i = 0; i < distribution.length; i++) {
distribution[i] = random.nextDouble() * 100.;
}
System.out.println("Start the calculation with random array");
long begin = System.currentTimeMillis();
double result = percentile.evaluate(distribution);
long end = System.currentTimeMillis();
System.out.println("duration : " + (end - begin) + "ms");
System.out.println("result : " + result);
// filling the array with a constant number
for (int i = 0; i < distribution.length; i++) {
distribution[i] = CONST_NUMBER;
}
System.out.println("Start the calculation with constant array");
begin = System.currentTimeMillis();
result = percentile.evaluate(distribution);
end = System.currentTimeMillis();
System.out.println("duration : " + (end - begin) + "ms");
System.out.println("result : " + result);
}
{code}
Thanks,
Benoit.
was (Author: teraben):
Hello,
Here is a simple test case :
/**
* Test the Percentile calculation
*/
public static void testQuantile() {
final double CONST_NUMBER = 18.;
final double PERCENT = 5.;
final int DISTRIBUTION_SIZE = (int) 1e5;
double[] distribution = new double[DISTRIBUTION_SIZE];
Percentile percentile = new Percentile(PERCENT);
Random random = new Random(System.nanoTime());
// filling the array with random number
for (int i = 0; i < distribution.length; i++) {
distribution[i] = random.nextDouble() * 100.;
}
System.out.println("Start the calculation with random array");
long begin = System.currentTimeMillis();
double result = percentile.evaluate(distribution);
long end = System.currentTimeMillis();
System.out.println("duration : " + (end - begin) + "ms");
System.out.println("result : " + result);
// filling the array with a constant number
for (int i = 0; i < distribution.length; i++) {
distribution[i] = CONST_NUMBER;
}
System.out.println("Start the calculation with constant array");
begin = System.currentTimeMillis();
result = percentile.evaluate(distribution);
end = System.currentTimeMillis();
System.out.println("duration : " + (end - begin) + "ms");
System.out.println("result : " + result);
}
Thanks,
Benoit.
> Percentile calculation is very slow when input data are constants
> -----------------------------------------------------------------
>
> Key: MATH-805
> URL: https://issues.apache.org/jira/browse/MATH-805
> Project: Commons Math
> Issue Type: Improvement
> Affects Versions: 3.0
> Reporter: Benoit de Rancourt
> 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira