Accord.Statistics.Visualizations.Histogram.Compute C# (CSharp) Méthode

Compute() public méthode

Computes (populates) an Histogram mapping with values from a sample.
public Compute ( double values ) : void
values double The values to be binned in the histogram.
Résultat void
        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);
        }

Same methods

Histogram::Compute ( double values, double binWidth ) : void
Histogram::Compute ( double values, int numberOfBins ) : void
Histogram::Compute ( double values, int numberOfBins, bool extraUpperBin ) : void
Histogram::Compute ( double values, int numberOfBins, double binWidth ) : void

Usage Example

Exemple #1
0
        /// <summary>
        ///   Creates a histogram of values from a sample.
        /// </summary>
        ///
        /// <param name="values">The values to be binned in the histogram.</param>
        ///
        /// <returns>A histogram reflecting the distribution of values in the sample.</returns>
        ///
        public Histogram FromData(double[] values)
        {
            var hist = new Histogram();

            hist.Compute(values);
            return(hist);
        }
All Usage Examples Of Accord.Statistics.Visualizations.Histogram::Compute