npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
CensoredQuantileRegression.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_CENSOREDQUANTILEREGRESSION_HH_
2 #define NPSTAT_CENSOREDQUANTILEREGRESSION_HH_
3 
4 /*!
5 // \file CensoredQuantileRegression.hh
6 //
7 // \brief Local linear and quadratic quantile regression with censoring
8 //
9 // Facilities for performing local linear and quadratic quantile
10 // regression on samples which experience point losses due to detection
11 // inefficiencies. It is assumed that the inefficiency is due to a cutoff
12 // on the response variable itself or on a variable which, for any given
13 // predictor, can be obtained from response by a monotonous transformation
14 // (so that an equivalent cut can be made for response). Typical example
15 // of such a quantity from particle physics is particle (or jet) transverse
16 // momentum.
17 //
18 // Classes declared in this header can be used with the
19 // top-level driver functions minuitQuantileRegression
20 // and minuitQuantileRegressionIncrBW declared in the
21 // minuitQuantileRegression.hh header (interfaces section).
22 //
23 // Author: I. Volobouev
24 //
25 // November 2011
26 */
27 
29 
30 namespace npstat {
31  /** A simple class to represent the necessary information about censoring */
33  {
34  inline CensoringInfo(const double cut, const double eff)
35  : cutoff(cut), efficiency(eff) {}
36 
37  double cutoff; ///< censoring cutoff value at this predictor
38  double efficiency; ///< censoring efficiency at this predictor
39  };
40 
41 
42  /**
43  // Class that facilitates censored quantile regression on data samples
44  // arranged into a k-d tree structure
45  */
46  template<class Point, class Numeric>
48  public QuantileRegressionOnKDTree<Point,Numeric>
49  {
50  public:
51  /**
52  // Constructor arguments are as follows:
53  //
54  // dataTree -- the tree of data points.
55  //
56  // regressedValue -- a functor that provides the observed
57  // value for the given input point. Typically,
58  // this value will be just one of the Point
59  // coordinates not used in k-d tree construction.
60  //
61  // censoringInfo -- a functor that provides information about
62  // censoring for the goven point.
63  //
64  // poly -- the set of orthogonal polynomials used to
65  // construct the local regression surface.
66  //
67  // quantile -- the target quantile (between 0.0 and 1.0).
68  //
69  // The "valueLimit" parameter plays the role of a far-away point
70  // which for sure lies below all uncut response values if the cut
71  // was response > cutoff or above all uncut values if the cut was
72  // response < cutoff. This limit should not be chosen extremely far
73  // away from the realistically possible response values because
74  // such a limit will contribute too much to the loss function and
75  // the loss value calculation will suffer excessively from round-off
76  // errors.
77  //
78  // This object will not own "dataTree", "regressedValue",
79  // "censoringInfo", or "poly" objects. These objects must still
80  // exist when the CensoredQuantileRegressionOnKDTree object is in use.
81  */
83  const KDTree<Point,Numeric>& dataTree,
84  const Functor1<double,Point>& regressedValue,
85  const Functor1<CensoringInfo,Point>& censoringInfo,
86  const QuadraticOrthoPolyND& poly,
87  double quantile, double valueLimit);
88 
90 
91  /** Method from AbsVisitor that we have to implement */
92  virtual void process(const Point& value);
93 
94  private:
95  const Functor1<CensoringInfo,Point>& censoringInfo_;
96  const double valueLimit_;
97  bool positiveTailPassing_;
98 
99  virtual double empiricalQuantile(double* err, double* npoints);
100  };
101 
102 
103  /**
104  // This class assumes that the histogram is filled with
105  // actual event counts and that the quantity which is being regressed
106  // is used for the last histogram axis. The dimensionality of the
107  // histogram therefore must be larger by 1 than the dimensionality
108  // of the QuadraticOrthoPolyND object. Histogram overflow bins will be
109  // ignored.
110  */
111  template <typename Numeric, typename Num2>
113  public QuantileRegressionOnHisto<Numeric>
114  {
115  public:
116  /**
117  // It is assumed that the arrays "efficiency" and "cutoff"
118  // contain the efficiency and cutoff values for the predictor
119  // values placed in the center of the argument histogram bins
120  // (all histogram dimensions except last are predictor dimensions).
121  // Therefore, they should be bin-compatible with the histogram
122  // binning constructed without last axis.
123  //
124  // "valueLimit" has the same meaning as in the class
125  // CensoredQuantileRegressionOnKDTree. Naturally, this value
126  // should be outside (or exactly on the boundary) of the range
127  // covered by the last histogram axis.
128  */
130  const ArrayND<Num2>& efficiency,
131  const ArrayND<Num2>& cutoff,
132  const QuadraticOrthoPolyND& poly,
133  double quantile, double valueLimit);
134 
136 
137  /** Method from AbsArrayProjector that we have to implement */
138  virtual void process(const unsigned *index, unsigned indexLen,
139  unsigned long linearIndex, const Numeric& value);
140  private:
141  const ArrayND<Num2>& efficiency_;
142  const ArrayND<Num2>& cutoff_;
143  const double valueLimit_;
144  bool positiveTailPassing_;
145 
146  virtual double empiricalQuantile(double* err, double* npoints);
147  };
148 }
149 
150 #include "npstat/stat/CensoredQuantileRegression.icc"
151 
152 #endif // NPSTAT_CENSOREDQUANTILEREGRESSION_HH_
Facilities for performing local linear and quadratic quantile regression.
Definition: CensoredQuantileRegression.hh:114
virtual void process(const unsigned *index, unsigned indexLen, unsigned long linearIndex, const Numeric &value)
CensoredQuantileRegressionOnHisto(const HistoND< Numeric > &histo, const ArrayND< Num2 > &efficiency, const ArrayND< Num2 > &cutoff, const QuadraticOrthoPolyND &poly, double quantile, double valueLimit)
Definition: CensoredQuantileRegression.hh:49
CensoredQuantileRegressionOnKDTree(const KDTree< Point, Numeric > &dataTree, const Functor1< double, Point > &regressedValue, const Functor1< CensoringInfo, Point > &censoringInfo, const QuadraticOrthoPolyND &poly, double quantile, double valueLimit)
virtual void process(const Point &value)
Definition: HistoND.hh:46
Definition: QuadraticOrthoPolyND.hh:24
Definition: LocalQuantileRegression.hh:191
Definition: LocalQuantileRegression.hh:135
Definition: AbsArrayProjector.hh:14
Definition: CensoredQuantileRegression.hh:33
double cutoff
censoring cutoff value at this predictor
Definition: CensoredQuantileRegression.hh:37
double efficiency
censoring efficiency at this predictor
Definition: CensoredQuantileRegression.hh:38