private void compute(double[] data) { // Create additional information this.m_total = Math.Matrix.Sum(data); // Create Bins this.m_binValues = new int[this.m_binCount]; HistogramBin[] bins = new HistogramBin[this.m_binCount]; for (int i = 0; i < this.m_binCount; i++) { bins[i] = new HistogramBin(this, i); } this.m_binCollection = new HistogramBinCollection(bins); // Populate Bins for (int i = 0; i < data.Length; i++) { // Convert the value to the range of histogram bins to detect to which bin the value belongs. int index = (int)System.Math.Floor(Math.Tools.Scale(m_range, new DoubleRange(0, this.m_binCount - 1), data[i])); this.m_binValues[index]++; } if (m_cumulative) { for (int i = 1; i < this.m_binCount; i++) { m_binValues[i] += m_binValues[i - 1]; } } }
/// <summary> /// Initializes the histogram's bins. /// </summary> /// private void initialize(int numberOfBins) { this.binValues = new int[numberOfBins]; this.binRanges = new double[numberOfBins + 1]; HistogramBin[] bins = new HistogramBin[numberOfBins]; for (int i = 0; i < numberOfBins; i++) { bins[i] = new HistogramBin(this, i); } binCollection = new HistogramBinCollection(bins); }
/// <summary> /// Initializes the histogram's bins. /// </summary> /// private void initialize(int numberOfBins) { this.binValues = new int[numberOfBins]; this.binRanges = new double[numberOfBins + 1]; HistogramBin[] bins = new HistogramBin[numberOfBins]; for (int i = 0; i < numberOfBins; i++) bins[i] = new HistogramBin(this, i); binCollection = new HistogramBinCollection(bins); }