npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
PowerRatio1D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_POWERRATIO1D_HH_
2 #define NPSTAT_POWERRATIO1D_HH_
3 
4 /*!
5 // \file PowerRatio1D.hh
6 //
7 // \brief Distribution with unscaled density proportional to x^m/(1 + x)^n
8 // for x >= 0 (and 0 for x < 0). m can be integer or half-integer,
9 // starting with -1/2 and going up.
10 //
11 // Author: I. Volobouev
12 //
13 // September 2022
14 */
15 
17 
18 namespace npstat {
20  {
21  public:
22  /**
23  // Parameter "twom" is 2*m. Must have 2*n > twom + 2 (otherwise
24  // the density integral will not converge). twom must also be >= -1
25  // (so that m >= -1/2).
26  */
27  PowerRatio1D(double location, double scale, int twom, unsigned n);
28 
29  inline virtual PowerRatio1D* clone() const
30  {return new PowerRatio1D(*this);}
31 
32  inline virtual ~PowerRatio1D() {}
33 
34  inline unsigned twom() const {return twom_;}
35  inline unsigned n() const {return n_;}
36 
37  // Methods needed for I/O
38  virtual gs::ClassId classId() const {return gs::ClassId(*this);}
39  virtual bool write(std::ostream& os) const;
40 
41  static inline const char* classname() {return "npstat::PowerRatio1D";}
42  static inline unsigned version() {return 1;}
43  static PowerRatio1D* read(const gs::ClassId& id, std::istream& in);
44 
45  protected:
46  virtual bool isEqual(const AbsDistribution1D&) const;
47 
48  private:
50 
51  PowerRatio1D(double location, double scale,
52  const std::vector<double>& params);
53  inline static int nParameters() {return 2;}
54 
55  void initialize();
56 
57  double unscaledDensity(double x) const;
58  double unscaledCdf(double x) const;
59  double unscaledExceedance(double x) const;
60  double unscaledQuantile(double x) const;
61 
62  double calculateNorm() const;
63  double calculateXMax() const;
64 
65  int twom_;
66  unsigned n_;
67  double norm_;
68  double xmax_;
69  long double (*cdf_)(long double);
70  double rmax_;
71  double cdfSwitchX_;
72  std::vector<long double> cdfCoeffs_;
73  };
74 }
75 
76 #endif // NPSTAT_POWERRATIO1D_HH_
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: PowerRatio1D.hh:20
PowerRatio1D(double location, double scale, int twom, unsigned n)
virtual gs::ClassId classId() const
Definition: PowerRatio1D.hh:38
virtual bool isEqual(const AbsDistribution1D &) const
virtual PowerRatio1D * clone() const
Definition: PowerRatio1D.hh:29
Definition: Distribution1DFactory.hh:35
Definition: AbsArrayProjector.hh:14
Definition: AbsDistribution1D.hh:31