npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
ChebyshevDistro1D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_CHEBYSHEVDISTRO1D_HH_
2 #define NPSTAT_CHEBYSHEVDISTRO1D_HH_
3 
4 /*!
5 // \file ChebyshevDistro1D.hh
6 //
7 // \brief Statistical distribution constructed using series in
8 // Chebyshev polynomials of the first kind
9 //
10 // Author: I. Volobouev
11 //
12 // February 2023
13 */
14 
16 
18 
19 namespace npstat {
20  /**
21  // A distribution whose density is a series in terms of
22  // Chebyshev polynomials of the first kind. The series
23  // coefficients start with degree 1 (note, not 0).
24  */
26  {
27  public:
28  ChebyshevDistro1D(double location, double scale,
29  const double* coeffs, unsigned maxdeg,
30  bool ensurePositivity = true);
31 
32  ChebyshevDistro1D(double location, double scale,
33  const std::vector<double>& coeffs,
34  bool ensurePositivity = true);
35 
36  inline virtual ChebyshevDistro1D* clone() const
37  {return new ChebyshevDistro1D(*this);}
38 
39  inline virtual ~ChebyshevDistro1D() {}
40 
41  inline bool isPositive() const {return isPositive_;};
42 
43  // Methods needed for I/O
44  virtual gs::ClassId classId() const {return gs::ClassId(*this);}
45  virtual bool write(std::ostream& os) const;
46 
47  static inline const char* classname()
48  {return "npstat::ChebyshevDistro1D";}
49  static inline unsigned version() {return 1;}
50  static ChebyshevDistro1D* read(const gs::ClassId& id, std::istream& in);
51 
52  protected:
53  virtual bool isEqual(const AbsDistribution1D&) const;
54 
55  private:
57 
58  inline static int nParameters() {return -1;}
59 
60  double unscaledDensity(double x) const;
61  double unscaledCdf(double x) const;
62  double unscaledQuantile(double x) const;
63  double unscaledExceedance(double x) const;
64 
65  void checkPositive(bool validatePositivity);
66  void setupCoeffs(const double* coeffs, unsigned maxdeg);
67 
68  std::vector<double> allCoeffs_;
69  std::vector<double> integCoeffs_;
70  bool isPositive_;
71  };
72 }
73 
74 #endif // NPSTAT_CHEBYSHEVDISTRO1D_HH_
Orthonormal versions of some classical orthogonal polynomials.
Factories for 1-d distributions for use in interpretive language environments.
Definition: AbsDistribution1D.hh:165
double scale() const
Definition: AbsDistribution1D.hh:183
double location() const
Definition: AbsDistribution1D.hh:180
Definition: ChebyshevDistro1D.hh:26
virtual ChebyshevDistro1D * clone() const
Definition: ChebyshevDistro1D.hh:36
virtual gs::ClassId classId() const
Definition: ChebyshevDistro1D.hh:44
virtual bool isEqual(const AbsDistribution1D &) const
Definition: Distribution1DFactory.hh:35
Definition: AbsArrayProjector.hh:14
Definition: AbsDistribution1D.hh:31