npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
AbsCGF1D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_ABSCGF1D_HH_
2 #define NPSTAT_ABSCGF1D_HH_
3 
4 /*!
5 // \file AbsCGF1D.hh
6 //
7 // \brief Interface definition for univariate cumulant generating functions
8 //
9 // Author: I. Volobouev
10 //
11 // December 2019
12 */
13 
14 #include <typeinfo>
15 
16 namespace npstat {
17  struct AbsCGF1D
18  {
19  inline virtual ~AbsCGF1D() {}
20 
21  /** Virtual copy constructor */
22  virtual AbsCGF1D* clone() const = 0;
23 
24  /**
25  // CGF for the variable (X - mu)/sigma. Created on the
26  // heap and must be later deleted by the user.
27  */
28  virtual AbsCGF1D* shiftAndScale(double mu, double sigma) const = 0;
29 
30  /** Infimum of the support */
31  virtual double smin() const = 0;
32 
33  /** Supremum of the support */
34  virtual double smax() const = 0;
35 
36  /** CGF value */
37  inline double operator()(double s) const
38  {return derivative(0U, s);}
39 
40  /** CGF derivatives. Get cum[order] by setting s to 0. */
41  virtual double derivative(unsigned order, double s) const = 0;
42 
43  /** Solution of the saddlepoint equation CGF'(s) == x */
44  virtual double saddlepoint(double x) const;
45 
46  /**
47  // Search empirically for the maximum value of s
48  // for which this CGF remains convex. This function
49  // should search for the closest to 0 root of the
50  // CGF second derivative on the interval [0, slimit].
51  // It should return 0.0 if no such root was found.
52  */
53  virtual double convexLimit(double slimit, double stepSize) const;
54 
55  /** Standardized cumulant for s-tilted density */
56  double standardizedCumulant(unsigned order, double s) const;
57 
58  /**
59  // Saddlepoint density approximation. Parameter "order" is the
60  // approximation order (e.g., order = 2 means O(N^-2)). This
61  // parameter must be positive. The raw, unnormalized approximation
62  // is returned.
63  */
64  double saddlepointDensityApprox(unsigned order, double x) const;
65 
66  /**
67  // Lugannani-Rice approximation for the survival function.
68  // The approximation employs a series which looks like
69  // c0/N^{1/2} + c1/N^{3/2} + c2/N^{5/2} + ...
70  // The parameter "nTerms" specifies the number of terms in
71  // the series to use and, thereby, the approximation order.
72  */
73  double lugannaniRiceSFApprox(unsigned nTerms, double x) const;
74 
75  /**
76  // Derived classes should not implement "operator==", implement
77  // "isEqual" instead
78  */
79  inline bool operator==(const AbsCGF1D& r) const
80  {return (typeid(*this) == typeid(r)) && this->isEqual(r);}
81 
82  /** Logical negation of operator== */
83  inline bool operator!=(const AbsCGF1D& r) const
84  {return !(*this == r);}
85 
86  protected:
87  /** Comparison for equality. To be implemented by derived classes. */
88  virtual bool isEqual(const AbsCGF1D&) const = 0;
89  };
90 }
91 
92 #endif // NPSTAT_ABSCGF1D_HH_
Definition: AbsArrayProjector.hh:14
Definition: AbsCGF1D.hh:18
virtual double saddlepoint(double x) const
bool operator==(const AbsCGF1D &r) const
Definition: AbsCGF1D.hh:79
virtual double smax() const =0
virtual AbsCGF1D * clone() const =0
double saddlepointDensityApprox(unsigned order, double x) const
virtual double derivative(unsigned order, double s) const =0
virtual bool isEqual(const AbsCGF1D &) const =0
double standardizedCumulant(unsigned order, double s) const
virtual double smin() const =0
double operator()(double s) const
Definition: AbsCGF1D.hh:37
virtual double convexLimit(double slimit, double stepSize) const
bool operator!=(const AbsCGF1D &r) const
Definition: AbsCGF1D.hh:83
virtual AbsCGF1D * shiftAndScale(double mu, double sigma) const =0
double lugannaniRiceSFApprox(unsigned nTerms, double x) const