npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
MinuitQuantileRegressionNDFcn.hh
Go to the documentation of this file.
1 #ifndef NPSI_MINUITQUANTILEREGRESSIONNDFCN_HH_
2 #define NPSI_MINUITQUANTILEREGRESSIONNDFCN_HH_
3 
4 /*!
5 // \file MinuitQuantileRegressionNDFcn.hh
6 //
7 // \brief Minuit function to minimize for local quantile regression
8 // with multiple predictors
9 //
10 // Author: I. Volobouev
11 //
12 // October 2011
13 */
14 
16 
17 #include "Minuit2/FCNBase.h"
18 
19 namespace npsi {
20  /**
21  // Target minimization function adapter class for running local quantile
22  // regression fits with multiple predictors by Minuit2
23  */
24  template <typename Numeric>
25  class MinuitQuantileRegressionNDFcn : public ROOT::Minuit2::FCNBase
26  {
27  public:
28  /** This class will not own any pointers or references */
31  const unsigned maxdeg, const double up = 0.05)
32  : qr_(qr), up_(up)
33  {
34  assert(up_ > 0.0);
35  setMaxDeg(maxdeg);
36  }
37 
38  inline virtual ~MinuitQuantileRegressionNDFcn() {}
39 
40  /** Set maximum degree of the fitted polynomial (0, 1, or 2) */
41  inline void setMaxDeg(const unsigned maxdeg)
42  {
43  switch (maxdeg)
44  {
45  case 0U:
46  npara_ = 1U;
47  break;
48  case 1U:
49  npara_ = qr_.dim() + 1U;
50  break;
51  case 2U:
52  npara_ = ((qr_.dim() + 1U)*(qr_.dim() + 2U))/2U;
53  break;
54  default:
55  assert(!"Invalid maximum polynomial degree");
56  }
57  }
58 
59  inline unsigned nParameters() const {return npara_;}
60 
61  inline virtual double operator()(const std::vector<double>& x) const
62  {
63  const unsigned len = x.size();
64  assert(len >= npara_);
65  return (const_cast<npstat::QuantileRegressionBase<
66  Numeric>&>(qr_)).linearLoss(&x[0], len);
67  }
68 
69  inline double Up() const {return up_;}
70 
71  private:
73  double up_;
74  unsigned npara_;
75  };
76 }
77 
78 #endif // NPSI_MINUITQUANTILEREGRESSIONNDFCN_HH_
Facilities for performing local linear and quadratic quantile regression.
Definition: MinuitQuantileRegressionNDFcn.hh:26
void setMaxDeg(const unsigned maxdeg)
Definition: MinuitQuantileRegressionNDFcn.hh:41
MinuitQuantileRegressionNDFcn(npstat::QuantileRegressionBase< Numeric > &qr, const unsigned maxdeg, const double up=0.05)
Definition: MinuitQuantileRegressionNDFcn.hh:29
Definition: LocalQuantileRegression.hh:34
Definition: fitCompositeJohnson.hh:16