npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
BandwidthCVPseudoLogli1D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_BANDWIDTHCVPSEUDOLOGLI1D_HH_
2 #define NPSTAT_BANDWIDTHCVPSEUDOLOGLI1D_HH_
3 
4 /*!
5 // \file BandwidthCVPseudoLogli1D.hh
6 //
7 // \brief Cross-validating one-dimensional density estimates by optimizing
8 // regularized pseudo log-likelihood
9 //
10 // Author: I. Volobouev
11 //
12 // September 2010
13 */
14 
16 
17 namespace npstat {
18  /**
19  // Class for calculating KDE or LOrPE cross-validation pseudo
20  // log-likelihood, for 1-dimensional density estimates. This class
21  // is intended for use inside degree and/or bandwidth scans.
22  */
23  template<
24  typename Numeric,
25  typename Num2,
26  typename Num3 = double,
27  typename Num4 = double
28  >
30  public AbsBandwidthCV1D<Numeric,Num2,Num3,Num4>
31  {
32  public:
33  /**
34  // Parameter "regularizationPower" is used to limit the contributions
35  // into the overall pseudo log likelihood from points for which the
36  // "leaving one out" density is very low. For those points, instead
37  // of "leaving one out" density, we will use the density generated by
38  // that point itself divided by pow(N, regularizationPower). This
39  // method limits the effect of tails on bandwidth determination.
40  */
41  inline explicit BandwidthCVPseudoLogli1D(double regularizationPower=0.5)
42  : renormPow_(regularizationPower), nonZeroCount_(0), renormCount_(0) {}
43 
44  inline virtual ~BandwidthCVPseudoLogli1D() {}
45 
46  inline unsigned long getNonZeroCount() const {return nonZeroCount_;}
47  inline unsigned long getRenormCount() const {return renormCount_;}
48 
49  // Unweighted samples
50  virtual double operator()(
51  const HistoND<Numeric>& histo,
52  const Num2* densityEstimate,
53  unsigned lenEstimate,
54  const AbsPolyFilter1D& filterUsed) const;
55 
56  // Weighted samples
57  virtual double operator()(
58  const HistoND<Numeric>& histo,
59  double effectiveSampleSize,
60  const Num2* densityEstimate,
61  unsigned lenEstimate,
62  const AbsPolyFilter1D& filterUsed) const;
63 
64  // Weighted samples in case the sample is available
65  virtual double operator()(
66  const HistoND<Numeric>& histo,
67  const std::pair<Num3, Num4>* sample,
68  unsigned long lenSample,
69  const Num2* densityEstimate,
70  unsigned lenEstimate,
71  const AbsPolyFilter1D& filterUsed) const;
72 
73  private:
74  double renormPow_;
75  mutable unsigned long nonZeroCount_;
76  mutable unsigned long renormCount_;
77  };
78 }
79 
80 #include "npstat/stat/BandwidthCVPseudoLogli1D.icc"
81 
82 #endif // NPSTAT_BANDWIDTHCVPSEUDOLOGLI1D_HH_
Interface definitions for KDE or LOrPE cross-validation calculations.
Definition: BandwidthCVPseudoLogli1D.hh:31
virtual double operator()(const HistoND< Numeric > &histo, const Num2 *densityEstimate, unsigned lenEstimate, const AbsPolyFilter1D &filterUsed) const
BandwidthCVPseudoLogli1D(double regularizationPower=0.5)
Definition: BandwidthCVPseudoLogli1D.hh:41
virtual double operator()(const HistoND< Numeric > &histo, double effectiveSampleSize, const Num2 *densityEstimate, unsigned lenEstimate, const AbsPolyFilter1D &filterUsed) const
Definition: HistoND.hh:46
Definition: AbsArrayProjector.hh:14
Definition: AbsBandwidthCV.hh:48
Definition: AbsPolyFilter1D.hh:27