npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
FoldedDistribution1D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_FOLDEDDISTRIBUTION1D_HH_
2 #define NPSTAT_FOLDEDDISTRIBUTION1D_HH_
3 
4 /*!
5 // \file FoldedDistribution1D.hh
6 //
7 // \brief 1-d continuous statistical distributions folded on some interval
8 //
9 // Author: I. Volobouev
10 //
11 // May 2022
12 */
13 
15 
16 namespace npstat {
18  {
19  public:
20  /**
21  // Constructor arguments are as follows:
22  //
23  // distro -- Distribution whose support we want to fold.
24  //
25  // xmin, xmax -- New limits for the support.
26  //
27  // maxFolds -- Maximum number of folds allowed. If this number
28  // is exceeded, an exception will be thrown.
29  */
31  double xmin, double xmax,
32  unsigned maxFolds = 10000U);
33 
35  FoldedDistribution1D& operator=(const FoldedDistribution1D&);
36 
37  inline virtual FoldedDistribution1D* clone() const
38  {return new FoldedDistribution1D(*this);}
39 
40  virtual ~FoldedDistribution1D();
41 
42  /** Distribution density */
43  virtual double density(double x) const;
44 
45  /** Cumulative distribution function */
46  virtual double cdf(double x) const;
47 
48  /** 1 - cdf, avoiding subtractive cancellation */
49  virtual double exceedance(double x) const;
50 
51  /** The quantile function */
52  virtual double quantile(double x) const;
53 
54  //@{
55  /** Method needed for I/O */
56  virtual gs::ClassId classId() const {return gs::ClassId(*this);}
57  virtual bool write(std::ostream& os) const;
58  //@}
59 
60  static inline const char* classname()
61  {return "npstat::FoldedDistribution1D";}
62  static inline unsigned version() {return 1;}
63  static FoldedDistribution1D* read(
64  const gs::ClassId& id, std::istream&);
65 
66  protected:
67  virtual bool isEqual(const AbsDistribution1D&) const;
68 
69  private:
71 
72  AbsDistribution1D* distro_;
73  double leftBoundary_;
74  double rightBoundary_;
75  double lo_;
76  double hi_;
77  double xmin_;
78  double xmax_;
79  unsigned maxFoldings_;
80  bool reallyFolded_;
81  };
82 }
83 
84 #endif // NPSTAT_FOLDEDDISTRIBUTION1D_HH_
Interface definition for 1-d continuous statistical distributions.
Definition: FoldedDistribution1D.hh:18
virtual double cdf(double x) const
virtual gs::ClassId classId() const
Definition: FoldedDistribution1D.hh:56
virtual bool isEqual(const AbsDistribution1D &) const
virtual double density(double x) const
virtual double exceedance(double x) const
FoldedDistribution1D(const AbsDistribution1D &distro, double xmin, double xmax, unsigned maxFolds=10000U)
virtual FoldedDistribution1D * clone() const
Definition: FoldedDistribution1D.hh:37
virtual double quantile(double x) const
Definition: AbsArrayProjector.hh:14
Definition: AbsDistribution1D.hh:31