Matrix Science header

ms_shapiro_wilk.hpp

00001 /*
00002 ##############################################################################
00003 # File: ms_shapiro_wilk.hpp                                                  #
00004 # Mascot Parser toolkit                                                      #
00005 # Include file for Shapiro-Wilk W test (statistical algorithm)               #
00006 ##############################################################################
00007 #    $Source: /vol/cvsroot/parser/inc/ms_shapiro_wilk.hpp,v $
00008 #    $Author: martins $ 
00009 #      $Date: 2014/02/07 17:07:04 $ 
00010 #  $Revision: 1.6 $
00011 ##############################################################################
00012 */
00013 /*
00014 ##############################################################################
00015 # Applied Statistics algorithms                                              #
00016 #                                                                            #
00017 # Translated and adapted from routines that originally appeared in the       #
00018 # Journal of the Royal Statistical Society Series C (Applied Statistics)     #
00019 # and made available through StatLib http://lib.stat.cmu.edu/                #
00020 #                                                                            #
00021 # The implementation and source code for this algorithm is available as a    #
00022 # free download from http://www.matrixscience.com/msparser.html              #
00023 # to conform with the requirement that no fee is charged for their use       #
00024 ##############################################################################
00025 */
00026 
00027 
00028 #ifndef MS_SHAPIRO_WILK_HPP
00029 #define MS_SHAPIRO_WILK_HPP
00030 
00031 #ifdef _WIN32
00032 #pragma warning(disable:4251)   // Don't want all classes to be exported
00033 #pragma warning(disable:4786)   // Debug symbols too long
00034 #   ifndef _MATRIX_USE_STATIC_LIB
00035 #       ifdef MS_MASCOTRESFILE_EXPORTS
00036 #           define MS_MASCOTRESFILE_API __declspec(dllexport)
00037 #       else
00038 #           define MS_MASCOTRESFILE_API __declspec(dllimport)
00039 #       endif
00040 #   else
00041 #       define MS_MASCOTRESFILE_API
00042 #   endif
00043 #else
00044 #   define MS_MASCOTRESFILE_API
00045 #endif
00046 
00047 // Includes from the standard template library
00048 #include <string>
00049 #include <deque>
00050 #include <list>
00051 #include <vector>
00052 #include <set>
00053 #include <map>
00054 
00055 #ifdef __AIX__
00056 #undef SCORE
00057 #endif
00058 
00059 namespace matrix_science {
00060     class ms_quant_stats;
00061 
00068 
00069 
00114     class MS_MASCOTRESFILE_API ms_shapiro_wilk
00115     {
00116     public:
00117         ms_shapiro_wilk();
00118         ~ms_shapiro_wilk();
00119 
00121         ms_shapiro_wilk(std::deque<std::pair<size_t,double> > x, long n, long n1, long n2);
00122 
00124         void calculate(long n, long n1, long n2);
00125 
00127         void appendSampleValue(double y);
00128 
00130         void clearSampleValues();
00131 
00133         double getResult() const;
00134 
00136         double getPValue() const;
00137 
00139         double getErrorCode() const;
00140 
00141     private:
00142         bool   init_;
00143         double w_;       // The Shapiro-Wilks W-statistic.
00144         double pw_;      // the P-value for w
00145         int    ifault_;  // error indicator
00146         std::deque<double> a_;
00147         std::deque<std::pair<size_t,double> > x_;
00148 
00149     public:
00151         static void swilk(bool init, std::deque<std::pair<size_t,double> > x, long n, long n1, long n2, std::deque<double> &a, double &w, double &pw, int &ifault);
00152 
00153     private:
00155         static double poly(const double *cc, int nord, double x);
00157         static double ppnd7(double p,int &ifault);
00159         static double alnorm(double x,bool upper);
00160 
00161         static long sign(long x,long y);
00162     };
00163  // end of quantitation_group
00165 } // matrix_science
00166 
00167 
00168 #endif // MS_SHAPIRO_WILK_HPP
00169 /*------------------------------- End of File -------------------------------*/
Copyright © 2016 Matrix Science Ltd.  All Rights Reserved. Generated on Fri Jun 2 2017 01:44:51