int Histogram (double inputArray[], int numberOfElements, double base, double top, int histogramArray[], double axisArray[], int intervals);
Calculates the histogram of the inputArray. The histogram is the count of the number of elements that fall within a specified set of intervals.
If the input sequence is
X = {0, 1, 3, 3, 4, 4, 4, 5, 5, 8}
the Histogram: h(X) of X for eight intervals is
Notice that the histogram of the input sequence X is a function of X.
The function obtains Histogram: h(X) as follows: Histogram scans the input sequence X to determine the range of values in it. Then the function establishes the interval width, ΔX, according to the specified number of intervals,
where | max is the maximum value found in the input sequence X |
min is the minimum value found in the input sequence X | |
m is the specified number of intervals |
Let χ represent the output sequence X because the histogram is a function of X. The function evaluates elements of χ using
χi = min + 0.5 × Δx + i × Δx
for i = 0, 1, 2, . . ., m 1
Histogram defines the interval Δi to be the range of values from χ — 0.5 × ΔX up to but not including χi + 0.5 × Δx.
Δi = [χi — 0.5 × Δx : χi + 0.5 × Δx]
for i = 0, 1, 2, . . ., m 1
and defines the function yi(X) to be
Histogram has unity value if the value of X falls within the specified interval. Otherwise it is zero. Notice that the interval Δi is centered about χi, and its width is Δx.
The last interval, Δm – 1, is defined as [χm — 1 — 0.5 × Δx : χm — 1 + 0.5 × Δx]. In other words, if a value equals max, it is counted as belonging to the last interval.
Finally, Histogram evaluates the histogram sequence h using
for i = 0, 1, 2, . . ., m 1
where | hi represents the elements of the output sequence Histogram: h(X) |
n is the number of elements in the input sequence X |
Histogram obtains the histogram by counting the number of times the elements in the input array fall in the interval.
Input | ||
Name | Type | Description |
inputArray | double-precision array | The values from which the histogram is calculated. |
numberOfElements | integer | Number of elements used in determining the histogram of the input array. |
base | double-precision | The lower bound of the range over which the histogram is calculated. If base is greater than top, the function returns an error code and does not calculate the histogram. Default Value: 0.0. |
top | double-precision | The upper bound of the range over which the histogram is calculated. If top is less than base, the function returns an error code and does not calculate the histogram. Default Value: 0.0. |
intervals | integer | Number of elements in the histogram and axis output arrays. |
Output | ||
Name | Type | Description |
histogramArray | integer array | Histogram of inputArray. The true plot of the histogram of the input array is obtained by plotting Histogram vs. Axis. |
axisArray | double-precision array | Histogram axis array; contains the midpoint values of the intervals used to determine the histogram. The true plot of the histogram of the input array is obtained by plotting Histogram vs. Axis. |
Name | Type | Description |
status | AnalysisLibErrType | A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants. |