Page MenuHomeHEPForge

No OneTemporary

Index: trunk/npstat/stat/AbsUnbinnedGOFTest1D.hh
===================================================================
--- trunk/npstat/stat/AbsUnbinnedGOFTest1D.hh (revision 737)
+++ trunk/npstat/stat/AbsUnbinnedGOFTest1D.hh (revision 738)
@@ -1,69 +1,69 @@
#ifndef NPSTAT_ABSUNBINNEDGOFTEST1D_HH_
#define NPSTAT_ABSUNBINNEDGOFTEST1D_HH_
/*!
// \file AbsUnbinnedGOFTest1D.hh
//
// \brief Interface definition for goodness-of-fit tests for 1-d distributions
//
// Author: I. Volobouev
//
// November 2020
*/
#include <vector>
#include <stdexcept>
#include "npstat/rng/AbsRandomGenerator.hh"
#include "npstat/stat/AbsDistribution1D.hh"
namespace npstat {
class AbsUnbinnedGOFTest1D
{
public:
inline explicit AbsUnbinnedGOFTest1D(const AbsDistribution1D& d)
: distro_(d.clone()) {}
inline AbsUnbinnedGOFTest1D(const AbsUnbinnedGOFTest1D& r)
: distro_(r.distro_->clone()) {}
inline AbsUnbinnedGOFTest1D& operator=(const AbsUnbinnedGOFTest1D& r)
{
if (this != &r)
{
delete distro_;
distro_ = 0;
distro_ = r.distro_->clone();
}
return *this;
}
inline virtual ~AbsUnbinnedGOFTest1D() {delete distro_;}
virtual double testStatistic(
const double* data, unsigned long sz, bool isDataSorted) const=0;
virtual double testStatistic(
const float* data, unsigned long sz, bool isDataSorted) const=0;
inline virtual double analyticPValue(
double /* stat */, unsigned long /* sz */) const
{
throw std::runtime_error(
"In npstat::AbsUnbinnedGOFTest1D::analyticPValue: "
"this function is not implemented by the derived class");
}
inline virtual bool hasAnalyticPValue() const {return false;}
- // The following method should sort the statistics values
+ // The following method should sort the statistic values
// in the increasing order
virtual void simulateStatistic(
AbsRandomGenerator& g, unsigned long sz,
unsigned nPseudo, std::vector<double>* stats) const;
protected:
AbsDistribution1D* distro_;
};
}
#endif // NPSTAT_ABSUNBINNEDGOFTEST1D_HH_
Index: trunk/npstat/stat/AbsUnbinnedGOFTest1D.cc
===================================================================
--- trunk/npstat/stat/AbsUnbinnedGOFTest1D.cc (revision 737)
+++ trunk/npstat/stat/AbsUnbinnedGOFTest1D.cc (revision 738)
@@ -1,30 +1,31 @@
#include <algorithm>
#include "npstat/stat/AbsUnbinnedGOFTest1D.hh"
namespace npstat {
void AbsUnbinnedGOFTest1D::simulateStatistic(
AbsRandomGenerator& g, const unsigned long sz,
const unsigned nPseudo, std::vector<double>* stats) const
{
if (!sz) throw std::invalid_argument(
"In npstat::AbsUnbinnedGOFTest1D::simulateStatistic: "
"sample size must be positive");
if (nPseudo < 2U) std::invalid_argument(
"In npstat::AbsUnbinnedGOFTest1D::simulateStatistic: "
"insufficient number od pseudo experiments");
assert(stats);
stats->clear();
stats->reserve(nPseudo);
std::vector<double> sampleVec(sz);
double* sample = &sampleVec[0];
for (unsigned ips=0; ips<nPseudo; ++ips)
{
for (unsigned long i=0; i<sz; ++i)
distro_->random(g, sample+i);
- stats->push_back(this->testStatistic(sample, sz, false));
+ std::sort(sampleVec.begin(), sampleVec.end());
+ stats->push_back(this->testStatistic(sample, sz, true));
}
std::sort(stats->begin(), stats->end());
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sat, May 3, 6:52 AM (16 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4983167
Default Alt Text
(3 KB)

Event Timeline