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: parser/inc/ms_shapiro_wilk.hpp $
00008 #    $Author: villek@matrixscience.com $ 
00009 #      $Date: 2018-07-30 16:23:53 +0100 $ 
00010 #  $Revision: 1b450440f9c97e1e41d0fc6016a27d68951d4532 | MSPARSER_REL_2_8_1-0-gea32989045 $
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 
00032 // Includes from the standard template library
00033 #include <string>
00034 #include <deque>
00035 #include <list>
00036 #include <vector>
00037 #include <set>
00038 #include <map>
00039 
00040 namespace matrix_science {
00041     class ms_quant_stats;
00042 
00049 
00050 
00095     class MS_MASCOTRESFILE_API ms_shapiro_wilk
00096     {
00097     public:
00098         ms_shapiro_wilk();
00099         ~ms_shapiro_wilk();
00100 
00102         ms_shapiro_wilk(std::deque<std::pair<size_t,double> > x, long n, long n1, long n2);
00103 
00105         void calculate(long n, long n1, long n2);
00106 
00108         void appendSampleValue(double y);
00109 
00111         void clearSampleValues();
00112 
00114         double getResult() const;
00115 
00117         double getPValue() const;
00118 
00120         double getErrorCode() const;
00121 
00122     private:
00123         bool   init_;
00124         double w_;       // The Shapiro-Wilks W-statistic.
00125         double pw_;      // the P-value for w
00126         int    ifault_;  // error indicator
00127         std::deque<double> a_;
00128         std::deque<std::pair<size_t,double> > x_;
00129 
00130     public:
00132         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);
00133 
00134     private:
00136         static double poly(const double *cc, int nord, double x);
00138         static double ppnd7(double p,int &ifault);
00140         static double alnorm(double x,bool upper);
00141 
00142         static long sign(long x,long y);
00143     };
00144  // end of quantitation_group
00146 } // matrix_science
00147 
00148 
00149 #endif // MS_SHAPIRO_WILK_HPP
00150 /*------------------------------- End of File -------------------------------*/

Copyright © 2022 Matrix Science Ltd.  All Rights Reserved. Generated on Thu Mar 31 2022 01:12:30