Replaced unnecessary bin search with direct computation.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141078 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
90be3c8e9d
commit
f6458ee9d0
|
@ -92,7 +92,7 @@ import org.apache.commons.math.stat.SummaryStatistics;
|
||||||
* entry per line.</li>
|
* entry per line.</li>
|
||||||
* </ol></p>
|
* </ol></p>
|
||||||
*
|
*
|
||||||
* @version $Revision: 1.14 $ $Date: 2004/01/25 21:30:41 $
|
* @version $Revision: 1.15 $ $Date: 2004/01/29 06:26:14 $
|
||||||
*/
|
*/
|
||||||
public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistribution {
|
public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistribution {
|
||||||
|
|
||||||
|
@ -213,23 +213,12 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
|
||||||
String str = null;
|
String str = null;
|
||||||
double val = 0.0d;
|
double val = 0.0d;
|
||||||
while ((str = in.readLine()) != null) {
|
while ((str = in.readLine()) != null) {
|
||||||
val = new Double(str).doubleValue();
|
val = Double.parseDouble(str);
|
||||||
|
SummaryStatistics stats =
|
||||||
// Find bin and add value to binStats for the bin
|
(SummaryStatistics) binStats.get(Math.max((int)Math.ceil((val - min) / delta) - 1, 0));
|
||||||
boolean found = false;
|
stats.addValue(val);
|
||||||
int i = 0;
|
|
||||||
while (!found) {
|
|
||||||
if (i >= binCount) {
|
|
||||||
throw new RuntimeException("bin alignment error");
|
|
||||||
}
|
|
||||||
if (val <= binUpperBounds[i]) {
|
|
||||||
found = true;
|
|
||||||
SummaryStatistics stats = (SummaryStatistics)binStats.get(i);
|
|
||||||
stats.addValue(val);
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
in.close();
|
in.close();
|
||||||
in = null;
|
in = null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue