I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL
COST (GBP)
this unit 1.00
sub units 0.00
+
0

Harmonic

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

get GPL add to cart

Interface

C++

Harmonic

 
template<class T> doubleharmonicintn
T*data )
The harmonic mean of N numbers x_i (where, i=1,2...,N) is defined by

The special cases of N=2 and N=3 are therefore given by

and so on.

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

The harmonic mean is the special case M_{-1} 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

nthe size of the population
datathe 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.