public void Compute(double[] values)
{
// Compute values' range
DoubleRange range = values.GetRange();
// Check if there are no values
if (values.Length == 0)
{
initialize(0);
}
// Check if we have a constant value
else if (range.Length == 0)
{
// Yes, we will create a special histogram
// bin to accommodate those constant values.
initialize(1);
ranges[0] = range.Min;
ranges[1] = range.Max;
}
// Check if we have to auto-adjust the histogram
// bins according to some selection choice.
else if (rule != BinAdjustmentRule.None)
{
// Yes, we will be recomputing the optimal number of bins
int numberOfBins = NumberOfBins(values, range, rule);
// Determine bin width based on the given number of bins
double binWidth = range.Length / (double)numberOfBins;
// Create bin structure
initialize(numberOfBins);
// Create ranges w/ fixed width
initialize(range.Min, binWidth);
}
// Create histogram
this.compute(values);
}