Ignore:
Timestamp:
Jun 21, 2006, 5:43:29 PM (15 years ago)
Author:
Markus Ringnér
Message:

Added statistics functions to calculate the higher moments: skewness and kurtosis using gsl functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/statistics_test.cc

    r511 r588  
    77#include <cstdlib>
    88#include <iostream>
    9 
     9#include <cmath>
    1010
    1111int main()
     
    1818    gsl_vec(i)=i;
    1919  }
     20
    2021  double m=statistics::median(data);
    2122  double m_gsl=statistics::median(gsl_vec);
    2223  if (m!=4.5 || m!=m_gsl)
    2324    return -1;
     25
     26  double tolerance=1e-10;
     27  double skewness_gsl=statistics::skewness(gsl_vec);
     28  if (fabs(skewness_gsl)>tolerance)
     29    return -1;
     30  double kurtosis_gsl=statistics::kurtosis(gsl_vec);
     31  if (fabs(kurtosis_gsl+1.5616363636363637113)>tolerance)
     32    return -1; 
    2433  return 0;
    2534}
Note: See TracChangeset for help on using the changeset viewer.