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