npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
NonparametricDistro1DBuilder.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_NONPARAMETRICDISTRO1DBUILDER_HH_
2 #define NPSTAT_NONPARAMETRICDISTRO1DBUILDER_HH_
3 
4 /*!
5 // \file NonparametricDistro1DBuilder.hh
6 //
7 // \brief 1-d density estimation implementing AbsDistro1DBuilder interface
8 //
9 // Author: I. Volobouev
10 //
11 // July 2015
12 */
13 
17 
18 namespace npstat {
19  /**
20  // A class for building conditional nonparametric estimates of univariate
21  // densities
22  */
23  template <class Point>
25  {
26  public:
28  typedef typename B::WeightedPointPtr WeightedPointPtr;
29  typedef typename B::WeightedPtrVec WeightedPtrVec;
30  typedef typename B::WeightedValue WeightedValue;
31  typedef typename B::WeightedValueVec WeightedValueVec;
32 
33  /**
34  // Constructor arguments are as follows:
35  //
36  // smoother1D -- distribution smoother pointer
37  //
38  // intervalBuilder -- pointer for the response interval builder
39  //
40  // takePointerOwnership -- if true, delete smoother1D and
41  // intervalBuilder in the destructor
42  //
43  // interpolationDegree -- interpolation degree for the density
44  // array. Currently must be 0 or 1, limited
45  // by the abilities of BinnedDensity1D class.
46  */
48  AbsMarginalSmootherBase* smoother1D,
49  AbsResponseIntervalBuilder<Point>* intervalBuilder,
50  bool takePointerOwnership,
51  unsigned interpolationDegree = 1U);
52 
54 
55  /** Bandwidth used in the most recent smoothing of the marginals */
56  inline double lastBandwidth() const {return smoother1D_->lastBandwidth();}
57 
58  /** Set the archive for storing the histograms */
59  void setArchive(gs::AbsArchive* ar, const char* category = 0);
60 
61  private:
66 
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;
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;
78 
79  virtual AbsDistribution1D* buildDistro(
80  unsigned long uniqueId,
81  const Interval<double>& responseRange,
82  const std::vector<typename Point::value_type>&) const;
83 
84  virtual AbsDistribution1D* buildDistroW(
85  unsigned long uniqueId, unsigned responseDimToUse,
86  const Interval<double>& responseRange,
87  const WeightedValueVec& data) const;
88 
89  AbsMarginalSmootherBase* smoother1D_;
90  AbsResponseIntervalBuilder<Point>* intervalBuilder_;
91  unsigned iDegMarginals_;
92  bool takePointerOwnership_;
93  };
94 }
95 
96 #include "npstat/stat/NonparametricDistro1DBuilder.icc"
97 
98 #endif // NPSTAT_NONPARAMETRICDISTRO1DBUILDER_HH_
Interface definition for classes which reconstruct univariate distrubutions from data samples.
Interface definition for 1-d nonparametric density estimation.
Base class for building response boxes for univariate density estimation in the regression context.
Definition: AbsDistro1DBuilder.hh:28
Definition: AbsMarginalSmootherBase.hh:29
double lastBandwidth() const
Definition: AbsMarginalSmootherBase.hh:55
Definition: AbsResponseIntervalBuilder.hh:23
Definition: Interval.hh:29
Definition: NonparametricDistro1DBuilder.hh:25
void setArchive(gs::AbsArchive *ar, const char *category=0)
double lastBandwidth() const
Definition: NonparametricDistro1DBuilder.hh:56
NonparametricDistro1DBuilder(AbsMarginalSmootherBase *smoother1D, AbsResponseIntervalBuilder< Point > *intervalBuilder, bool takePointerOwnership, unsigned interpolationDegree=1U)
Definition: AbsArrayProjector.hh:14
Definition: AbsDistribution1D.hh:31