Statistics › Moments ›
Mean
Calculates the arithmetic mean of a given population
Controller: CodeCogs
Contents
Interface
C++
Mean
template<class T> doublemean( | int | n | |
T* | data | ) |
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
n the size of the population data the 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.