npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
Trig2GOFTest1D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_TRIG2GOFTEST1D_HH_
2 #define NPSTAT_TRIG2GOFTEST1D_HH_
3 
4 /*!
5 // \file Trig2GOFTest1D.hh
6 //
7 // \brief Goodness-of-fit test based on the trigonometric expansion
8 // of the empirical comparison density
9 //
10 // Author: I. Volobouev
11 //
12 // May 2023
13 */
14 
16 
17 namespace npstat {
19  {
20  public:
21  // The mask, if provided, should contain nTrig2Terms
22  // elements. Put some number in the mask in order to
23  // discard the corresponding term and put 0 there to
24  // keep it. The ordering of terms is as follows:
25  //
26  // sin(2 Pi x) -> mask[0]
27  // cos(2 Pi x) -> mask[1]
28  // sin(4 Pi x) -> mask[2]
29  // cos(4 Pi x) -> mask[3]
30  // ........................
31  // sin(2 k Pi x) -> mask[2 k - 2]
32  // cos(2 k Pi x) -> mask[2 k - 1]
33  // ........................
34  //
35  // Maximum value of k equals nTrig2Terms / 2 (integer division)
36  // in case nTrig2Terms is even. In case nTrig2Terms is odd,
37  // it is nTrig2Terms / 2 + 1, but only the sine term is used.
38  //
39  inline Trig2GOFTest1D(const AbsDistribution1D& distro,
40  const unsigned nTrig2Terms,
41  const unsigned char* mask=0,
42  const unsigned lenMask=0)
43  : AbsSmoothGOFTest1D(distro, nTrig2Terms, mask, lenMask) {}
44 
45  inline Trig2GOFTest1D(const AbsDistribution1D& distro,
46  const std::vector<int>& mask)
47  : AbsSmoothGOFTest1D(distro, mask) {}
48 
49  inline virtual ~Trig2GOFTest1D() {}
50 
51  inline virtual std::string shortName() const
52  {return testNameWithMask("Trig2");}
53 
54  virtual unsigned normalizedDeviations(
55  const double* data, unsigned long sz,
56  bool isDataSorted,
57  double* deviations, unsigned lenDeviations) const;
58 
59  virtual unsigned normalizedDeviations(
60  const float* data, unsigned long sz,
61  bool isDataSorted,
62  double* deviations, unsigned lenDeviations) const;
63 
64  private:
65  template<typename Numeric>
66  unsigned normalizedDeviationsHelper(
67  const Numeric* data, unsigned long lenData,
68  double* deviations) const;
69  };
70 }
71 
72 #include "npstat/stat/Trig2GOFTest1D.icc"
73 
74 #endif // NPSTAT_TRIG2GOFTEST1D_HH_
Base class for smooth tests for goodness-of-fit.
Definition: AbsSmoothGOFTest1D.hh:20
Definition: Trig2GOFTest1D.hh:19
virtual unsigned normalizedDeviations(const double *data, unsigned long sz, bool isDataSorted, double *deviations, unsigned lenDeviations) const
Definition: AbsArrayProjector.hh:14
Definition: AbsDistribution1D.hh:31