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 0.50
sub units 0.00
+
0

Mean

viewed 2258 times and licensed 130 times
Calculates the arithmetic mean of a given population
Controller: CodeCogs

get GPL add to cart

Interface

C++

Mean

 
template<class T> doublemeanintn
T*data )
The arithmetic mean of a set of values is the quantity commonly called the mean or the average. Given a set of samples \{x_i\} the arithmetic mean is

The arithmetic mean is the special case M_1 of the power mean and is one of the Pythagorean means. When viewed as an estimator for the mean of the underlying distribution (known as the population mean), the arithmetic mean of a sample is called the sample mean. The arithmetic mean satisfies :

where x and y are independent statistics. The sample mean which is the mean estimated from a statistical sample, is an unbiased estimator for the population mean.

Example 1

#include <codecogs/statistics/moments/mean.h>
#include <iostream>
int main() 
{
  int x[5] = {3 , 5 , 8 , 5 , 2};
  double avg = Stats::Moments::mean(5, x);
  std::cout << "The population mean is: " << avg << std::endl;
  return 0;
}
Output:
The population mean is: 4.6

Parameters

nthe size of the population
datathe actual population data given as an array

Returns

the arithmetic mean of the 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.