Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_shapiro_wilk.hpp
1/*
2##############################################################################
3# File: ms_shapiro_wilk.hpp #
4# Mascot Parser toolkit #
5# Include file for Shapiro-Wilk W test (statistical algorithm) #
6##############################################################################
7# $Source: parser/inc/ms_shapiro_wilk.hpp $
8# $Author: villek@matrixscience.com $
9# $Date: 2018-07-30 16:23:53 +0100 $
10# $Revision: 1b450440f9c97e1e41d0fc6016a27d68951d4532 | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $
11##############################################################################
12*/
13/*
14##############################################################################
15# Applied Statistics algorithms #
16# #
17# Translated and adapted from routines that originally appeared in the #
18# Journal of the Royal Statistical Society Series C (Applied Statistics) #
19# and made available through StatLib http://lib.stat.cmu.edu/ #
20# #
21# The implementation and source code for this algorithm is available as a #
22# free download from http://www.matrixscience.com/msparser.html #
23# to conform with the requirement that no fee is charged for their use #
24##############################################################################
25*/
26
27
28#ifndef MS_SHAPIRO_WILK_HPP
29#define MS_SHAPIRO_WILK_HPP
30
31
32// Includes from the standard template library
33#include <string>
34#include <deque>
35#include <list>
36#include <vector>
37#include <set>
38#include <map>
39
40namespace matrix_science {
41 class ms_quant_stats;
42
50
95 class MS_MASCOTRESFILE_API ms_shapiro_wilk
96 {
97 public:
100
102 ms_shapiro_wilk(std::deque<std::pair<size_t,double> > x, long n, long n1, long n2);
103
105 void calculate(long n, long n1, long n2);
106
108 void appendSampleValue(double y);
109
111 void clearSampleValues();
112
114 double getResult() const;
115
117 double getPValue() const;
118
120 double getErrorCode() const;
121
122 private:
123 bool init_;
124 double w_; // The Shapiro-Wilks W-statistic.
125 double pw_; // the P-value for w
126 int ifault_; // error indicator
127 std::deque<double> a_;
128 std::deque<std::pair<size_t,double> > x_;
129
130 public:
132 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);
133
134 private:
136 static double poly(const double *cc, int nord, double x);
138 static double ppnd7(double p,int &ifault);
140 static double alnorm(double x,bool upper);
141
142 static long sign(long x,long y);
143 };
144 // end of quantitation_group
146} // matrix_science
147
148
149#endif // MS_SHAPIRO_WILK_HPP
150/*------------------------------- End of File -------------------------------*/
The Shapiro-Wilk W test.
Definition: ms_shapiro_wilk.hpp:96