CHistogram:Calc
The Calc method computes the histogram of a 1-dimensional array.
tTable = CHistogram:Calc( Data )
tData is the input data 1-dimensional array containing the data.
tTable is a 1-dimensional array containing the histogram frequencies.
The computed histogram is dependent on the binning parameters which control the "size" of each bin and number of bins used over the range of data values. Several class methods are provided for setting the binning strategy. If you do not configure the binning strategy, then the histogram is computed using the full range of sample data values and a bin count equal to the square root of the number of sample points.
One reason to use this class and method rather than the Histogram function is that the class provides access to the actual binning parameters used after the histogram is calculated in "Auto" mode (the default or set using the SetBinAuto method).
The following script computes and plots a histogram of 1 million Gaussian random numbers. The 4th line creates a nice x-axis that makes the distribution symmetrical about 0 and places the center of each bin at the x-coordinate of the bin. Since there are 1,000,000 values in the data sample and the histogram uses auto binning, the number of elements in the histogram array y will be 100 (see above).
|
-- create a CHistogram object |
|
-- create 1,000,000 values |
|
-- compute the histogram |
|
-- separate the 3 parameters for clarity |
|
|
|
|
|
-- create a series for the histgram x axis |
|
-- plot the histogram |
|
|
This script created the plot shown below.
CHistogram Class, SetBinAuto, series, gaussdev, plot, Histogram
Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.