I have forgotten

• http://facebook.com/
• https://www.google.com/accounts/o8/id
• https://me.yahoo.com COST (GBP) 0.20 0.75 0

# Median

Returns the median of the given population.
Controller: CodeCogs Contents  ## Dependents C++

## Median

 template doublemedian( int n T* data )[inline]
The median is the number in the middle of a set of numbers; that is, half the numbers have values that are greater than the median, and half have values that are less. If there is an even number of numbers in the set, then it calculates the average of the two numbers in the middle. In order to calculate the median, this algorithm uses the Smallest function.

## Example:

```#include <codecogs/statistics/moments/median.h>
#include <iostream>
int main()
{
double
x = {0.2, 1.24, 0.5, 2.54, 2.3, 0.3},
y = {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.html

### Parameters

 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.