Index: trunk/npstat/stat/SineGOFTest1D.cc =================================================================== --- trunk/npstat/stat/SineGOFTest1D.cc (revision 841) +++ trunk/npstat/stat/SineGOFTest1D.cc (revision 842) @@ -1,128 +1,126 @@ #include #include #include "npstat/stat/SineGOFTest1D.hh" #include "npstat/stat/Distributions1D.hh" #define PI 3.1415926535897932385 #define SQR2 1.4142135623730950488 static npstat::Matrix sineTransformMatrix( const unsigned N, const unsigned K) { if (!N) throw std::invalid_argument( "In sineTransformMatrix: number of sine terms must be positive"); if (!K) throw std::invalid_argument( "In sineTransformMatrix: number of discretization points must be positive"); const double h = 1.0/K; const double norm = SQR2*h; npstat::Matrix result(N, K); for (unsigned n=1; n<=N; ++n) { - const double nPi = n*PI; + const double nPih = n*PI*h; + double* base = result[n - 1U]; for (unsigned j=0; j& mask) : AbsUnbinnedGOFTest1D(nullDistro), nSineTerms_(mask.size()), nPt_(nDiscretizationPoints), mask_(mask.size(), 0), sineM_(sineTransformMatrix(mask.size(), nDiscretizationPoints)), points_(0.0, 1.0, nDiscretizationPoints), quantiles_(nDiscretizationPoints), nUnmasked_(mask.size()), cdfValues_(nDiscretizationPoints), sineValues_(mask.size()), statBuf_(mask.size()) { if (!mask.empty()) initMask(&mask[0], mask.size()); else initMask((int*)0, 0); } double SineGOFTest1D::analyticPValue( const double stat, unsigned long /* sz */) const { Gamma1D chisq(0.0, 2.0, nUnmasked_/2.0); return chisq.exceedance(stat); } double SineGOFTest1D::inverseExceedance( const double pvalue, const unsigned long sz, const double smin, const double smax) const { if (pvalue <= 0.0 || pvalue >= 1.0) throw std::invalid_argument( "In npstat::SineGOFTest1D::inverseExceedance: " "p-value argument must be inside (0, 1) interval"); if (pvalue > 1.0e-10) { Gamma1D chisq(0.0, 2.0, nUnmasked_/2.0); return chisq.quantile(1.0 - pvalue); } else return AbsUnbinnedGOFTest1D::inverseExceedance( pvalue, sz, smin, smax); } std::string SineGOFTest1D::shortName() const { std::ostringstream os; os << "Sine_" << nSineTerms_ << '_' << nPt_; if (nUnmasked_ < nSineTerms_) { // Figure out the number of the last // masked term unsigned lastMasked = nSineTerms_; for (unsigned i=0; i