Mode
Advanced Analysis Library Only
AnalysisLibErrType Mode (double inputArray[], ssize_t numberOfElements, double base, double top, ssize_t intervals, double *mode);
Purpose
![]() |
Note This function has been superseded by ModeEx. This function supports only unimodal analysis, while ModeEx supports multimodal analysis as well. |
Finds the mode of the input array.
Modes refer to the most common values obtained in a set of observations. For example, for a data set (3, 7, 3, 9, 9, 3, 5, 1, 8, 5), the unique mode is 3.
This function determines the mode in terms of the histogram of the input array.
Example Code
/* Generate a Gaussian distributed random array and find its mode. */
double x[2000], max, min, modeval;
int n, intervals, imax, imin;
n = 2000;
intervals = 50;
GaussNoise (n, 1.0E0, 17, x);
MaxMin1D (x, n, &max, &imax, &min, &imin);
Mode (x, n, min, max, intervals, &modeval);
Parameters
Input | ||
Name | Type | Description |
inputArray | double [] | The input data set used to determine the mode. |
numberOfElements | ssize_t | The length of inputArray. |
base | double | Lower range over which the mode value is determined. The mode value is in the range [base:top]. Default Value: 0.0. |
top | double | Upper range over which the mode value is determined. The mode value is in the range [base:top]. Default Value: 0.0. |
intervals | ssize_t | The number of bins of the histogram to use when computing the estimated mode. This value must be positive integer. Default Value: 1. |
Output | ||
Name | Type | Description |
mode | double | Mode value of the input array inputArray. |
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: Advanced Analysis Library
Include file: analysis.h
LabWindows/CVI compatibility: LabWindows/CVI 3.1 and later
Example
Refer to analysis\mode.cws for an example of using the Mode function.