double lower = minimum;
double upper;
List<HistogramBin> binList = new ArrayList<HistogramBin>(numOfBins);
for (int i = 0; i < numOfBins; i++) {
HistogramBin bin;
// make sure bins[bins.length]'s upper boundary ends at maximum
// to avoid the rounding issue. the bins[0] lower boundary is
// guaranteed start from min
if (i == numOfBins - 1) {
bin = new HistogramBin(lower, maximum);
} else {
upper = minimum + (i + 1) * binWidth;
bin = new HistogramBin(lower, upper);
lower = upper;
}
binList.add(bin);
}
// fill the bins
for (int i = 0; i < values.length; i++) {
int binIndex = numOfBins - 1;
if (values[i] < maximum) {
double fraction = (values[i] - minimum) / (maximum - minimum);
if (fraction < 0.0) {
fraction = 0.0;
}
binIndex = (int) (fraction * numOfBins);
if (binIndex >= numOfBins) {
binIndex = numOfBins - 1;
}
}
HistogramBin bin = (HistogramBin) binList.get(binIndex);
bin.incrementCount();
}
// generic map for each series
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("key", key);