I have forgotten

• https://me.yahoo.com
COST (GBP)
1.00
0.00
0

Harmonic

Calculates the harmonic mean of a given population.
Controller: CodeCogs
Contents

C++

Harmonic

 template doubleharmonic( int n T* data )
The harmonic mean of N numbers  (where, ) is defined by


The special cases of  and  are therefore given by



and so on.

For , the harmonic mean is related to the arithmetic mean, A, and the geometric mean, G, by


The harmonic mean is the special case  of the power mean and is one of the Pythagorean means.

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.