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