npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
buildInterpolatedDistro1DNP.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_BUILDINTERPOLATEDDISTRO1DNP_HH_
2 #define NPSTAT_BUILDINTERPOLATEDDISTRO1DNP_HH_
3 
4 /*!
5 // \file buildInterpolatedDistro1DNP.hh
6 //
7 // \brief Univariate density estimation in the regression context
8 //
9 // Author: I. Volobouev
10 //
11 // June 2015
12 */
13 
14 #include "geners/CPP11_auto_ptr.hh"
15 
18 
19 namespace npstat {
20  /*
21  // Arguments of this function are as follows:
22  //
23  // data -- The data points. The "Point" class should
24  // be subscriptable and should publish
25  // "value_type" typedef (std::array works).
26  //
27  // dimPredictors -- These arguments define which dimensions of the
28  // nPredictors data points should be treated as predictors.
29  //
30  // predictorNames -- Names of the predictor variables. This argument
31  // can be 0 in which case the predictor grid axes
32  // will not have any labels.
33  //
34  // predictorNumBins -- Number of bins to use in each predictor
35  // dimension. These bins will be defined in
36  // the predictor cdf space.
37  //
38  // predictorSymbetaPower -- This parameter defines the type of the
39  // symmetric beta or Gaussian kernel to use
40  // in the predictor cdf space.
41  //
42  // effectiveEventsPerBin -- Approximate number of effective events to use
43  // per predictor bin in the middle of the range.
44  //
45  // stretchPredKernels -- Should the kernels be stretched near the
46  // boundaries in the predictor space?
47  //
48  // responseDimToUse -- Which dimension of the data points should be
49  // treated as the response variable.
50  //
51  // builder -- Builder of univariate distributions using
52  // data points weighted by kernels in the
53  // predictor cdf space.
54  //
55  // interpolateVertically -- Initial interpolation method setting for
56  // InterpolatedDistro1DNP. If "true", densities
57  // will be interpolated linearly, otherwise
58  // quantile functions will be interpolated
59  // linearly.
60  //
61  // reportFrequency -- The code will print a message to the standard
62  // output periodically, after processing this
63  // number of bins. Set this parameter to 0
64  // in order to disable such messages.
65  */
66  template <class Point>
67  CPP11_auto_ptr<InterpolatedDistro1DNP>
68  buildInterpolatedDistro1DNP(
69  const std::vector<Point>& data,
70  const unsigned* dimPredictors, unsigned nPredictors,
71  const std::string* predictorNames,
72  const unsigned* predictorNumBins, int predictorSymbetaPower,
73  double effectiveEventsPerBin, bool stretchPredKernels,
74  unsigned responseDimToUse,
75  const AbsDistro1DBuilder<Point>& builder,
76  bool interpolateVertically = false, unsigned reportFrequency = 0);
77 
78 #ifdef SWIG
79  template <class Point>
80  inline InterpolatedDistro1DNP*
81  buildInterpolatedDistro1DNP_2(
82  const std::vector<Point>& data,
83  const unsigned* dimPredictors, unsigned nPredictors,
84  const std::vector<std::string> predictorNames,
85  const unsigned* predictorNumBins, unsigned lenBins,
86  int predictorSymbetaPower,
87  double effectiveEventsPerBin, bool stretchPredKernels,
88  unsigned responseDimToUse,
89  const AbsDistro1DBuilder<Point>& builder,
90  bool interpolateVertically = false, unsigned reportFrequency = 0)
91  {
92  if (nPredictors != lenBins) throw std::invalid_argument(
93  "In npstat::buildInterpolatedDistro1DNP_2: "
94  "incompatible arguments");
95  const unsigned namesSz = predictorNames.size();
96  const std::string* predNames = 0;
97  if (namesSz)
98  {
99  if (namesSz != nPredictors) throw std::invalid_argument(
100  "In npstat::buildInterpolatedDistro1DNP_2: "
101  "incompatible set of predictor names");
102  predNames = &predictorNames[0];
103  }
104  CPP11_auto_ptr<InterpolatedDistro1DNP> ptr =
105  buildInterpolatedDistro1DNP(
106  data, dimPredictors, nPredictors, predNames,
107  predictorNumBins, predictorSymbetaPower,
108  effectiveEventsPerBin, stretchPredKernels,
109  responseDimToUse, builder,
110  interpolateVertically, reportFrequency);
111  return ptr.release();
112  }
113 #endif // SWIG
114 }
115 
116 #include "npstat/stat/buildInterpolatedDistro1DNP.icc"
117 
118 #endif // NPSTAT_BUILDINTERPOLATEDDISTRO1DNP_HH_
Interface definition for classes which reconstruct univariate distrubutions from data samples.
Interpolation of 1-d distributions as a function of multiple parameters.
Definition: AbsArrayProjector.hh:14