Admin Production ni-theme
Current Publication

ModeEx

LabWindows/CVI

ModeEx

Advanced Analysis Library Only

AnalysisLibErrType ModeEx (double inputArray[], ssize_t numberOfElements, ssize_t intervals, double *modes, ssize_t *numberOfModes);

Purpose

Finds the mode(s) of a list of numbers. 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. There can be more than one mode. For example, for a data set (2, 4, 9, 6, 4, 6, 6, 2, 8, 2), there are two modes: 2 and 6. A distribution with a single mode is said to be unimodal. A distribution with more than one mode is said to be bimodal, trimodal, and so on, or in general, multimodal. If no number occurs more than once in the set, then there is no mode for that set of numbers.

To find the exact modes of a set of observations, call this function with intervals <=0. If your observations contain noise, you may want to use the histogram algorithm to estimate the modes. In this case, intervals specifies the number of bins of the histogram. The function returns the center values of the histogram bins that contain the most values from the input data set.

Parameters

Input
Name Type Description
inputArray double [] The input data set.
numberOfElements ssize_t The length of inputArray.
intervals ssize_t The number of bins of the histogram.
  • If intervals > 0, the function uses the histogram algorithm to find the modes.
  • Otherwise, the function finds the exact modes of the input set. Any two elements, a and b, from the input data set, are regarded as equal if |a-b|<=DBL_EPSILON*|a|.
Output
Name Type Description
modes double The modes found. Estimate how many modes might exist in the data set and allocate enough memory space for modes before calling this function.
numberOfModes ssize_t On input, numberOfModes specifies the size of the buffer pointed to by modes, as the number of double-precision float numbers. On output, numberOfModes specifies how many modes actually exist in the input data set.

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 8.0 and later