npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
AbsDistro1DBuilder.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_ABSDISTRO1DBUILDER_HH_
2 #define NPSTAT_ABSDISTRO1DBUILDER_HH_
3 
4 /*!
5 // \file AbsDistro1DBuilder.hh
6 //
7 // \brief Interface definition for classes which reconstruct univariate
8 // distrubutions from data samples
9 //
10 // Author: I. Volobouev
11 //
12 // July 2015
13 */
14 
15 #include <vector>
16 #include <utility>
17 
18 #include "npstat/nm/BoxND.hh"
20 
21 namespace npstat {
22  /**
23  // Interface definition for classes which reconstruct univariate
24  // distrubutions out of data samples (typically, by fitting or smoothing)
25  */
26  template <class Point>
28  {
29  public:
31 
32  // Second element of the pairs defined below is the weight
33  typedef std::pair<const Point*, double> WeightedPointPtr;
34  typedef std::vector<WeightedPointPtr> WeightedPtrVec;
35  typedef std::pair<typename Point::value_type, double> WeightedValue;
36  typedef std::vector<WeightedValue> WeightedValueVec;
37 
38  inline virtual ~AbsDistro1DBuilder() {}
39 
40  /**
41  // This method will build an AbsDistribution1D
42  // object on the heap using a sample of points. It is
43  // a responsibility of the user to delete such an object
44  // when it is no longer needed.
45  */
47  unsigned long uniqueId,
48  const double* predictorCoords, unsigned nPredictors,
49  const BoxND<double>& predictorBox,
50  std::vector<typename Point::value_type>& data) const;
51 
52  /**
53  // This method will build an AbsDistribution1D
54  // object on the heap using a sample of weighted points.
55  // It is a responsibility of the user to delete such
56  // an object when it is no longer needed.
57  */
59  unsigned long uniqueId,
60  const double* predictorCoords, unsigned nPredictors,
61  const BoxND<double>& predictorBox, const WeightedPtrVec& data,
62  unsigned responseDimToUse) const;
63 
64  private:
65  // The following two methods should return an empty
66  // interval in case such an interval is not needed
67  virtual Interval<double> makeResponseInterval(
68  unsigned long uniqueId,
69  const double* predictorCoords, unsigned nPredictors,
70  const BoxND<double>& predictorBox,
71  std::vector<typename Point::value_type>& data) const = 0;
72 
73  virtual Interval<double> makeResponseIntervalW(
74  unsigned long uniqueId,
75  const double* predictorCoords, unsigned nPredictors,
76  const BoxND<double>& predictorBox, const WeightedPtrVec& data,
77  unsigned responseDimToUse) const = 0;
78 
79  // The following methods should construct the relevant
80  // objects on the heap
81  virtual AbsDistribution1D* buildDistro(
82  unsigned long uniqueId,
83  const Interval<double>& responseRange,
84  const std::vector<typename Point::value_type>& data) const = 0;
85 
86  virtual AbsDistribution1D* buildDistroW(
87  unsigned long uniqueId, unsigned responseDimToUse,
88  const Interval<double>& responseRange,
89  const WeightedValueVec& data) const = 0;
90  };
91 }
92 
93 #include "npstat/stat/AbsDistro1DBuilder.icc"
94 
95 #endif // NPSTAT_ABSDISTRO1DBUILDER_HH_
Interface definition for 1-d continuous statistical distributions.
Template to represent rectangles, boxes, and hyperboxes.
Definition: AbsDistro1DBuilder.hh:28
virtual AbsDistribution1D * buildWeighted(unsigned long uniqueId, const double *predictorCoords, unsigned nPredictors, const BoxND< double > &predictorBox, const WeightedPtrVec &data, unsigned responseDimToUse) const
virtual AbsDistribution1D * build(unsigned long uniqueId, const double *predictorCoords, unsigned nPredictors, const BoxND< double > &predictorBox, std::vector< typename Point::value_type > &data) const
Definition: Interval.hh:29
Definition: AbsArrayProjector.hh:14
Definition: AbsDistribution1D.hh:31