npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
LegendreCDTruncation.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_LEGENDRECDTRUNCATION_HH_
2 #define NPSTAT_LEGENDRECDTRUNCATION_HH_
3 
4 /*!
5 // \file LegendreCDTruncation.hh
6 //
7 // \brief Optimal truncation degree for OSDE by Legendre polynomials
8 // on [0, 1] (typical for OSDE of a comparison density)
9 //
10 // Author: I. Volobouev
11 //
12 // March 2023
13 */
14 
15 #include <vector>
16 
17 namespace npstat {
19  {
20  public:
22 
23  // The length of array "coeffs" should be at least 2*lambda.
24  // The coefficients start with degree 1 (it is assumed that
25  // the coefficient for degree 0 is 1). n is the sample size.
26  double calculateR(const double* coeffs, unsigned lambda,
27  unsigned n) const;
28 
29  // The length of array "coeffs" should be at least 2*maxLambda.
30  // The coefficients start with degree 1 (it is assumed that
31  // the coefficient for degree 0 is 1). The best lambda will
32  // minimize R calculated by "calculateR". Basically, this
33  // returns optimal OSDE truncation degree according to the
34  // Hart scheme. n is the sample size.
35  unsigned bestLambda(const double* coeffs, unsigned maxLambda,
36  unsigned n) const;
37 
38  private:
39  void fillCoeffs(unsigned lambda) const;
40 
41  // The length of "buf" array should be at least 2*lambda + 1
42  void calcSeriesCoeffs(double* buf, unsigned lambda) const;
43 
44  mutable std::vector<std::vector<long double> > squaredPolyCoeffs_;
45  mutable std::vector<double> dbuf_;
46  };
47 }
48 
49 #endif // NPSTAT_LEGENDRECDTRUNCATION_HH_
Definition: LegendreCDTruncation.hh:19
Definition: AbsArrayProjector.hh:14