FUNCTION
Largest
Finds the largest value of order k in the given array.
Interface
#include <codecogs/statistics/moments/largest.h>
using namespace Statistics::Moments;
This function makes a call to the Smallest function to return the k-th largest value in a data set, therefore using the Hoare selection algorithm. If on input the order k is 1 the maximum entry is sought, while if k is equal to the size of the array, the minimum is calculated.
Example:
#include <codecogs/statistics/moments/largest.h>
#include <iostream>
int main()
{
double a[6] = {0.2, 1.24, 0.5, 2.54, 2.3, 0.3},
large = Stats::Moments::largest<double>(6, a, 3);
std::cout << "The 3rd largest value of the array is: " << large;
std::cout << std::endl;
return 0;
}
Output:
The 3rd largest value of the array is: 1.24
References
SUBSET, a library of C++ combinatorial routines, www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.html
Parameters
n
the size of the array
data
an array of numerical data for which you want to determine the k-th smallest value
k
the order of the largest value to return
Returns
the k-th largest value in the given data set
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.