Statistics › Moments ›
Harmonic
Calculates the harmonic mean of a given population.
Controller: CodeCogs
Contents
Interface
C++
Harmonic
template<class T> doubleharmonic( | int | n | |
T* | data | ) |
Example 1
#include <codecogs/statistics/moments/harmonic.h> #include <iostream> int main() { double x[4] = {3.5 , 6.5 , 5.9 , 8.8}; double harm = Stats::Moments::harmonic<double>(4, x); std::cout << "The population harmonic mean is: " << harm << std::endl; return 0; }
Output:The population harmonic mean is:5.53489
Parameters
n the size of the population data the actual population data given as an array
Returns
- the harmonic mean of a given 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.