DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
.
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=36450
------- Additional Comments From keithmcdonald@sympatico.ca 2005-09-01 13:55 -------
Thank you for responding to this bug report so quickly!
I hit the problem with a larger sample size than the two samples that I gave in
the code for reproducing the problem. I just wanted to provide a small program
that could reproduce the problem easily. I think the problem is caused by the
limitations of the precision of the variable "delta".
When delta is produced by dividing (max - min) / binCount in the method
fillBinStats, regardless of how many samples you have, it is possible to get a
number that, when multiplied by binCount, is slightly smaller than (max - min).
So, when inputArray[i] is equal to max, (inputArray[i] - min) / delta equals a
number slightly larger than binCount. When the Math.ceil method is applied to
this number, you get binCount + 1, which , even after subtracting 1 as is done
in the computeBinStats methods, is too large for binStats.get to take as an
argument and this leads to the RunTimeException.
My suggestion for fixing this would be to add a call to Math.min(x,
binStats.size()-1) before passing the result to binStats.get, where x is the
current expression in computeBinStats whose result is being passed to
binStats.get. This change would need to go into two places: the computeBinStats
method of ArrayDataAdapter and the computeBinStats method of StreamDataAdapter.
Here is a replacement program that reproduces the problem with 10,000 samples.
import org.apache.commons.math.random.EmpiricalDistributionImpl;
public class BreakEmpiricalDistributionImpl {
public static void main(String[] args) {
final int NUMBER_OF_SAMPLES = 10000;
double[] x = new double[NUMBER_OF_SAMPLES];
x[0] = 9474.94326071674;
x[1] = 2080107.8865462579;
for (int i = 2; i < NUMBER_OF_SAMPLES; i++) {
x[i] = Math.max(Math.min(x[0] + x[1] * Math.random(), x[1]), x[0]);
}
new EmpiricalDistributionImpl().load(x);
}
}
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org