npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
TruncatedDistribution1D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_TRUNCATEDDISTRIBUTION1D_HH_
2 #define NPSTAT_TRUNCATEDDISTRIBUTION1D_HH_
3 
4 /*!
5 // \file TruncatedDistribution1D.hh
6 //
7 // \brief 1-d continuous statistical distributions with truncated support
8 //
9 // Author: I. Volobouev
10 //
11 // December 2012
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 truncate
24  //
25  // xmin, xmax -- new limits for the support
26  //
27  // minAndMaxAreForCDF -- if this argument is "true" then the limits
28  // are given for the cumulative distribution
29  // values and must both be between 0 and 1.
30  // They will be internally converted into the
31  // new limits of the support region.
32  */
34  double xmin, double xmax,
35  bool minAndMaxAreForCDF = false);
36 
39 
40  inline virtual TruncatedDistribution1D* clone() const
41  {return new TruncatedDistribution1D(*this);}
42 
43  virtual ~TruncatedDistribution1D();
44 
45  /** Distribution density */
46  virtual double density(double x) const;
47 
48  /** Cumulative distribution function */
49  virtual double cdf(double x) const;
50 
51  /** 1 - cdf, avoiding subtractive cancellation */
52  virtual double exceedance(double x) const;
53 
54  /** The quantile function */
55  virtual double quantile(double x) const;
56 
57  //@{
58  /** Method needed for I/O */
59  virtual gs::ClassId classId() const {return gs::ClassId(*this);}
60  virtual bool write(std::ostream& os) const;
61  //@}
62 
63  static inline const char* classname()
64  {return "npstat::TruncatedDistribution1D";}
65  static inline unsigned version() {return 1;}
66  static TruncatedDistribution1D* read(
67  const gs::ClassId& id, std::istream&);
68 
69  protected:
70  virtual bool isEqual(const AbsDistribution1D&) const;
71 
72  private:
74 
75  AbsDistribution1D* distro_;
76  double xmin_;
77  double xmax_;
78  double cdfmin_;
79  double cdfmax_;
80  double exmin_;
81  };
82 }
83 
84 #endif // NPSTAT_TRUNCATEDDISTRIBUTION1D_HH_
Interface definition for 1-d continuous statistical distributions.
Definition: TruncatedDistribution1D.hh:18
virtual double cdf(double x) const
TruncatedDistribution1D(const AbsDistribution1D &distro, double xmin, double xmax, bool minAndMaxAreForCDF=false)
virtual double exceedance(double x) const
virtual bool isEqual(const AbsDistribution1D &) const
virtual TruncatedDistribution1D * clone() const
Definition: TruncatedDistribution1D.hh:40
virtual double density(double x) const
virtual gs::ClassId classId() const
Definition: TruncatedDistribution1D.hh:59
virtual double quantile(double x) const
Definition: AbsArrayProjector.hh:14
Definition: AbsDistribution1D.hh:31