Histogram
AnalysisLibErrType Histogram (double inputArray[], ssize_t numberOfElements, double base, double top, ssize_t histogramArray[], double axisArray[], ssize_t intervals);
Purpose
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
h(X) = {h0, h1, h2, h3, h4, h5, h6, h7} = {1, 1, 0, 2, 3, 2, 0, 1}
Notice that the histogram of the input sequence inputArray is a function of inputArray.
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 ith 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 inputArray 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) |
numberOfElements 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 ith interval.
Parameters
Input | ||
Name | Type | Description |
inputArray | double [] | The values from which the histogram is calculated. |
numberOfElements | ssize_t | Number of elements used in determining the histogram of the input array. |
base | double | 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 | 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 | ssize_t | Number of elements in the histogram and axis output arrays. |
Output | ||
Name | Type | Description |
histogramArray | ssize_t [] | Histogram of inputArray. The true plot of the histogram of the input array is obtained by plotting Histogram vs. Axis. |
axisArray | double [] | 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. |
Return Value
Name | Type | Description |
status | AnalysisLibErrType | A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants. |
Additional Information
Library: Analysis Library
Include file: analysis.h
LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later