npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
AbsPolyFilterND.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_ABSPOLYFILTERND_HH_
2 #define NPSTAT_ABSPOLYFILTERND_HH_
3 
4 /*!
5 // \file AbsPolyFilterND.hh
6 //
7 // \brief Interface definition for multivariate smoothers that can be
8 // cross-validated
9 //
10 // Author: I. Volobouev
11 //
12 // September 2010
13 */
14 
15 #include <vector>
16 
17 namespace npstat {
18  /**
19  // Base class for LOrPE, etc. smoothers which can be later used with
20  // cross-validation algorithms. These algorithms usually work according
21  // to the "leaving-one-out" method, in which the contribution of one
22  // point into the density estimate must be subtracted. Therefore, this
23  // contribution must be known to begin with, and this is precisely the
24  // info this class is intended to convey.
25  */
27  {
28  inline virtual ~AbsPolyFilterND() {}
29 
30  /** Dimensionality of the filter */
31  virtual unsigned dim() const = 0;
32 
33  /** Required shape of the data array */
34  virtual std::vector<unsigned> dataShape() const = 0;
35 
36  /**
37  // Contribution of a single point into the density estimate
38  // at that point (not normalized). This is needed for various
39  // leaving-one-out cross-validation procedures.
40  */
41  virtual double selfContribution(
42  const unsigned* index, unsigned lenIndex) const = 0;
43 
44  /**
45  // Contribution of a single point into the density estimate
46  // using the linear index of the point
47  */
48  virtual double linearSelfContribution(unsigned long index) const = 0;
49  };
50 
52  {
53  public:
54  inline BasicPolyFilterND(const std::vector<unsigned>& shape,
55  const double selfContrib)
56  : shape_(shape), selfContrib_(selfContrib) {}
57 
58  inline virtual ~BasicPolyFilterND() {}
59 
60  virtual unsigned dim() const {return shape_.size();}
61  virtual std::vector<unsigned> dataShape() const {return shape_;}
62  virtual double selfContribution(
63  const unsigned* /* index */, unsigned /* lenIndex */) const
64  {return selfContrib_;}
65  virtual double linearSelfContribution(unsigned long /* index */) const
66  {return selfContrib_;}
67 
68  private:
69  std::vector<unsigned> shape_;
70  double selfContrib_;
71  };
72 }
73 
74 #endif // NPSTAT_ABSPOLYFILTERND_HH_
Definition: AbsPolyFilterND.hh:52
virtual std::vector< unsigned > dataShape() const
Definition: AbsPolyFilterND.hh:61
virtual double linearSelfContribution(unsigned long) const
Definition: AbsPolyFilterND.hh:65
virtual double selfContribution(const unsigned *, unsigned) const
Definition: AbsPolyFilterND.hh:62
virtual unsigned dim() const
Definition: AbsPolyFilterND.hh:60
Definition: AbsArrayProjector.hh:14
Definition: AbsPolyFilterND.hh:27
virtual unsigned dim() const =0
virtual std::vector< unsigned > dataShape() const =0
virtual double linearSelfContribution(unsigned long index) const =0
virtual double selfContribution(const unsigned *index, unsigned lenIndex) const =0