npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
PowerTransform1D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_POWERTRANSFORM1D_HH_
2 #define NPSTAT_POWERTRANSFORM1D_HH_
3 
4 /*!
5 // \file PowerTransform1D.hh
6 //
7 // \brief Transform y = a x^p (a > 0). Obviously, works only for
8 // non-negative x. x must be strictly positive if p is negative.
9 //
10 // Author: I. Volobouev
11 //
12 // September 2022
13 */
14 
16 
17 namespace npstat {
19  {
20  public:
21  PowerTransform1D(double a, double p);
22  inline virtual ~PowerTransform1D() {}
23 
24  inline virtual PowerTransform1D* clone() const
25  {return new PowerTransform1D(*this);}
26 
27  double transformForward(double x, double* dydx) const;
28  double transformBack(double y) const;
29  inline bool isIncreasing() const {return params_[1] > 0.0;}
30 
31  //@{
32  /** Prototype needed for I/O */
33  inline virtual gs::ClassId classId() const {return gs::ClassId(*this);}
34  virtual bool write(std::ostream&) const;
35  //@}
36 
37  static inline const char* classname()
38  {return "npstat::PowerTransform1D";}
39  static inline unsigned version() {return 1;}
40  static PowerTransform1D* read(const gs::ClassId& id, std::istream& is);
41 
42  protected:
43  virtual bool isEqual(const AbsDistributionTransform1D&) const;
44 
45  private:
46  void validateScale(double a);
47  void validatePower(double p);
48 
49  inline void setParameterChecked(const unsigned which, const double value)
50  {
51  if (which)
52  validatePower(value);
53  else
54  validateScale(value);
55  params_[which] = value;
56  }
57  inline void setAllParametersChecked(const double* p)
58  {
59  validateScale(p[0]);
60  validatePower(p[1]);
61  params_[0] = p[0];
62  params_[1] = p[1];
63  }
64  inline double getParameterChecked(const unsigned which) const
65  {return params_[which];}
66 
67  double params_[2];
68  };
69 }
70 
71 #endif // NPSTAT_POWERTRANSFORM1D_HH_
Interface definition for 1-d coordinate transformations used to build statistical distributions.
Definition: AbsDistributionTransform1D.hh:29
Definition: PowerTransform1D.hh:19
double transformForward(double x, double *dydx) const
bool isIncreasing() const
Definition: PowerTransform1D.hh:29
virtual PowerTransform1D * clone() const
Definition: PowerTransform1D.hh:24
virtual bool isEqual(const AbsDistributionTransform1D &) const
virtual gs::ClassId classId() const
Definition: PowerTransform1D.hh:33
Definition: AbsArrayProjector.hh:14