npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
SeriesCGF1D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_SERIESCGF1D_HH_
2 #define NPSTAT_SERIESCGF1D_HH_
3 
4 /*!
5 // \file SeriesCGF1D.hh
6 //
7 // \brief Univariate cumulant generating function defined by cumulants
8 //
9 // Author: I. Volobouev
10 //
11 // December 2019
12 */
13 
14 #include <vector>
15 
16 #include "npstat/stat/AbsCGF1D.hh"
17 
18 namespace npstat {
19  class SeriesCGF1D : public AbsCGF1D
20  {
21  public:
22  /**
23  // At least the first two cumulants (mean and variance)
24  // must be provided in the "cumulants" array.
25  // cumulants[0] must contain the mean, cumulants[1] the
26  // variance, etc. "nCumulants" specifies the length of
27  // the array (and also the highest cumulant order).
28  // The variance must be positive (i.e., the degenerate
29  // distribution of a single point mass is excluded from
30  // consideration). The parameters "smin" and "smax"
31  // should be chosen in such a way that the CGF remains
32  // convex on the (smin, smax) interval.
33  */
34  SeriesCGF1D(const double* cumulants, unsigned nCumulants,
35  double smin, double smax);
36 
37  inline virtual SeriesCGF1D* clone() const
38  {return new SeriesCGF1D(*this);}
39 
40  inline virtual ~SeriesCGF1D() {}
41 
42  virtual SeriesCGF1D* shiftAndScale(double mu, double sigma) const;
43 
44  inline virtual double smin() const {return smin_;}
45  inline virtual double smax() const {return smax_;}
46 
47  virtual double derivative(unsigned order, double s) const;
48 
49  void setCumulant(unsigned order, double value);
50 
51  inline unsigned maxOrder() const {return cumulants_.size();}
52 
53  inline const std::vector<double>& allCumulants() const
54  {return cumulants_;}
55 
56  /**
57  // Check whether the CGF is convex on the interval (a, b].
58  // This method ignores smin and smax.
59  */
60  bool isConvex(double a, double b) const;
61 
62  /**
63  // Convexify this CFG on the given interval by adding the
64  // smallest possible higher order cumulant of the lowest
65  // even order not specified for this CGF.
66  */
67  SeriesCGF1D convexify(double a, double b) const;
68 
69  protected:
70  virtual bool isEqual(const AbsCGF1D& r) const;
71 
72  private:
73  void truncateLeadingZeros();
74 
75  std::vector<double> cumulants_;
76  double smin_;
77  double smax_;
78  };
79 }
80 
81 #endif // NPSTAT_SERIESCGF1D_HH_
Interface definition for univariate cumulant generating functions.
Definition: SeriesCGF1D.hh:20
virtual double smax() const
Definition: SeriesCGF1D.hh:45
virtual SeriesCGF1D * shiftAndScale(double mu, double sigma) const
virtual bool isEqual(const AbsCGF1D &r) const
bool isConvex(double a, double b) const
SeriesCGF1D(const double *cumulants, unsigned nCumulants, double smin, double smax)
SeriesCGF1D convexify(double a, double b) const
virtual double smin() const
Definition: SeriesCGF1D.hh:44
virtual double derivative(unsigned order, double s) const
virtual SeriesCGF1D * clone() const
Definition: SeriesCGF1D.hh:37
Definition: AbsArrayProjector.hh:14
Definition: AbsCGF1D.hh:18