I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
this unit 3.00
sub units 0.00


Calculates the statistics for a set of data that may change size frequently.
Controller: CodeCogs




template<...> classStatistics )
This class allows the calculation of key statistics for a set of data that may change its size frequently. The main advantage of this class is the ability of updating the key statistics while storing minimum information about previous data into a set of main variables given below, rather than storing the actual data. Based on the next main variables, that are recalculated with each new value that is added to the population,

S=\sum_{i=1}^N x_i \qquad S_1=\sum_{i=1}^N \frac{1}{x_i} \qquad S_2=\sum_{i=1}^N x_i^2 \f] \f[ S_3=\sum_{i=1}^N x_i^3 \qquad S_4=\sum_{i=1}^N x_i^4 \qquad prod=\prod_{i=1}^N x_i

it calculates the statistics using the following formulas
mean=\frac{S}{N}\f] \f[geomean=\sqrt[N]{prod}\f] \f[harmean=\frac{N}{S_1}\f] \f[var=\frac{S_2-2\overline{x}S+N\overline{x}^2}{N-1}\f] \f[stdev=\sqrt{var}

where mean is the arithmetic mean, geomean is the geometric mean, harmean is the harmonic mean,var </em> is the variance and stdev is the standard deviation. The skewness and kurtosis are calculated using similar formulas.

A C# version of this class is available when you obtain a licence


Example 1

#include <codecogs/statistics/moments/statistics.h>
    #include <iostream>
    int main()
      double a[15];
      for (int i = 0; i < 15; i++)
      Stats::Moments::Statistics<double> stats(15, a);
      return 0;
Total = 123.0000000000
    Arithmetic Mean = 8.2000000000
     Geometric Mean = 6.8280387111
      Harmonic Mean = 4.9698018386
           Variance = 18.0285714286
 Standard Deviation = 4.2460065271
           Skewness = 0.0403100873
           Kurtosis = -1.0487842858


Anca Filibiu (August 2005)
Source Code

Source code is available when you buy a Commercial licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.