FUNCTION
Mode
Finds the most common value in an array.
Interface
#include <codecogs/statistics/moments/mode.h>
using namespace Statistics::Moments;
This function calculates the most common value in an array of data. Like Median, mode is a location measure.
Example:
#include<iostream>
#include <codecogs/statistics/moments/mode.h>
int main()
{
double x[11]={4, 4, 5, 5, 5, 8, 8, 8, 8, 9, 9},
res=Stats::Moments::mode(11, x);
std::cout<<"The mode of the x array is:"<<res<<std::endl;
return 0;
}
Output:
The mode of the x array is: 8
Parameters
n
the size of the array
data
the actual array of data
Returns
the most common value in the given array of data
This function's source code is only visible to registered users — documentation and the calculator above are free to use either way. Sign in to see it.