npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
QuantileRegression1D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_QUANTILEREGRESSION1D_HH_
2 #define NPSTAT_QUANTILEREGRESSION1D_HH_
3 
4 /*!
5 // \file QuantileRegression1D.hh
6 //
7 // \brief Local or global quantile regression with single predictor
8 //
9 // Author: I. Volobouev
10 //
11 // April 2011
12 */
13 
14 namespace npstat {
15  /**
16  // This functor simply evaluates the function to be minimized;
17  // the minimization itself is up to some external optimization
18  // engine. The modeling of the regression curve is performed
19  // by either Legendre or Gegenbauer polynomials. The former
20  // is appropriate for global models, while the latter is useful for
21  // local models in which the weights are assigned by a symmetric
22  // beta function.
23  //
24  // There is a high-level driver function for this class which uses
25  // Minuit as the optimization engine: npsi::minuitLocalQuantileRegression1D
26  */
27  template <typename Pair, typename Wnum=double>
29  {
30  public:
31  /**
32  // Constructor arguments are as follows:
33  //
34  // points -- The data to regress. Predictor is the first
35  // member of the pair and response is the second.
36  //
37  // weights -- Localizing weights. Can be NULL in which case
38  // it is assumed that each weight is 1.0 (this is
39  // appropriate for global regression).
40  //
41  // nPoints -- Number of elements in the "points" array and,
42  // if provided, in the "weights" array as well.
43  //
44  // location -- Can be used to shift all points.
45  //
46  // scale -- Can be used to scale distances between all points.
47  // The coordinates at which the regression polynomials
48  // will be evaluated will be transformed according to
49  // x_poly = (points[i].first - location)/scale.
50  //
51  // quantile -- The target quantile.
52  //
53  // polyDegree -- Maximum polynomial degree in the fit.
54  //
55  // useGegenbauerPolys -- Set to "true" to use Gegenbauer polynomials
56  // (appropriate for local fit), and to "false" to use
57  // Legendre polynomials (appropriate for global
58  // regression).
59  //
60  // gegenbauerLambda -- set this to 0.5 + "power" parameter of the
61  // SymmetricBeta1D if you are using Gegenbauer
62  // polynomials for regression. This parameter is
63  // ignored in case Legendre polynomials are used.
64  //
65  // This class will not make an internal copy and will not own
66  // the provided data and weights.
67  */
68  QuantileRegression1D(const Pair* points,
69  const Wnum* weights, unsigned long nPoints,
70  double location, double scale, double quantile,
71  unsigned polyDegree, bool useGegenbauerPolys,
72  double gegenbauerLambda);
73 
74  /**
75  // This operator takes the polynomial coefficients and their number
76  // as arguments (the number of the coefficients must be equal to
77  // polyDegree + 1). 0th degree coefficient comes first.
78  */
79  template <typename Numeric2>
80  double operator()(const Numeric2 *coeffs, unsigned lenCoeffs) const;
81 
82  private:
85  QuantileRegression1D& operator=(const QuantileRegression1D&);
86 
87  const Pair* points_;
88  const Wnum* weights_;
89  const unsigned long nPoints_;
90  const long double location_;
91  const long double scale_;
92  const long double quantile_;
93  const long double onemq_;
94  const long double lambda_;
95  const unsigned degree_;
96  const bool useGegen_;
97  };
98 }
99 
100 #include "npstat/stat/QuantileRegression1D.icc"
101 
102 #endif // NPSTAT_QUANTILEREGRESSION1D_HH_
Definition: QuantileRegression1D.hh:29
double operator()(const Numeric2 *coeffs, unsigned lenCoeffs) const
QuantileRegression1D(const Pair *points, const Wnum *weights, unsigned long nPoints, double location, double scale, double quantile, unsigned polyDegree, bool useGegenbauerPolys, double gegenbauerLambda)
Definition: AbsArrayProjector.hh:14