Statistics › Moments ›
Median
Returns the median of the given population.
Controller: CodeCogs
Contents
Dependents
Interface
C++
Median
template<class T> doublemedian( | int | n | |
T* | data | )[inline] |
Example:
#include <codecogs/statistics/moments/median.h> #include <iostream> int main() { double x[6] = {0.2, 1.24, 0.5, 2.54, 2.3, 0.3}, y[6] = {1, 2, 3.2, 4, 5}, medx = Stats::Moments::median<double>(6, x), medy = Stats::Moments::median<double>(5, y); std::cout << "The median of the x array is: " << medx << std::endl; std::cout << "The median of the y array is: " << medy << std::endl; return 0; }
Output:
The median of the x array is: 0.87 The median of the y array is: 3.2
References:
SUBSET, a library of C++ combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.htmlParameters
n the size of the population data the actual population given as an array
Returns
- the median of the population
Authors
- Anca Filibiu (August 2005)
Source Code
Source code is available when you agree to a GP Licence or buy a Commercial Licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.