class="resources"
![]() |
X must contain at least one sample.
If X is empty, the histogram is undefined, the error returns through the Histogram VI, and the Mode VI sets mode to NaN.
If the following input sequence has a constant value, the Mode VI ignores the number of intervals and sets mode to the constant value in the input sequence: if X = a |
![]() |
intervals specifies the number of bins of the histogram. The number of intervals must be greater than zero. The default is 1. If the number of intervals is less than or equal to zero, the histogram is undefined, the error returns through the Histogram VI, and the Mode VI sets mode to NaN. |
![]() |
mode returns the center value of the histogram bin that contains the most values from X. |
![]() |
error returns any error or warning from the VI. You can wire error to the Error Cluster From Error Code VI to convert the error code or warning into an error cluster. |
As defined in statistics, mode is the most frequently occurring value in a sequence of numbers. For example, if the input sequence is
X = {0, 1, 3, 3, 4, 4, 4, 5, 5, 7},
the mode of X is 4 because that is the value that most often occurs in X. However, instead of finding the true mode of the input sequence, this VI uses a histogram to divide the input sequence into bins, or intervals, and returns the center value of the bin containing the most values from the input sequence. The center value of the bin containing the most values from the input sequence generally is more useful than the true mode in real-world applications where the data sequence contains even a small amount of noise.
The VI calculates mode by generating a discrete histogram h(x) with the specified number of intervals of the input sequence X. Each bin, or interval, specified by intervals covers a range of floating-point numbers. The VI scans h(x) for the interval
i that has the maximum count. After the VI identifies the interval, the VI selects the center value of the interval as the mode of the input sequence X.
h(mode) = max[h(x)]
For example, using the input sequence
X = {0, 1, 3, 3, 4, 4, 4, 5, 5, 7} with intervals set at 1,
the Mode VI calculates mode as 3.5 because 3.5 is the center value of the one interval specified by intervals.
Refer to the Histogram VI for more information about histograms.
Refer to the following VIs for examples of using the Mode VI: