npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
BandwidthGCVPseudoLogli1D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_BANDWIDTHGCVPSEUDOLOGLI1D_HH_
2 #define NPSTAT_BANDWIDTHGCVPSEUDOLOGLI1D_HH_
3 
4 /*!
5 // \file BandwidthGCVPseudoLogli1D.hh
6 //
7 // \brief Cross-validating one-dimensional density estimates of grouped data
8 // by optimizing regularized pseudo log-likelihood
9 //
10 // Author: I. Volobouev
11 //
12 // June 2015
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<typename Numeric, typename Num2>
24  class BandwidthGCVPseudoLogli1D : public AbsBandwidthGCV1D<Numeric,Num2>
25  {
26  public:
27  /**
28  // Parameter "regularizationPower" is used to limit the contributions
29  // into the overall pseudo log likelihood from points for which the
30  // "leaving one out" density is very low. For those points, instead
31  // of "leaving one out" density, we will use the density generated by
32  // that point itself divided by pow(N, regularizationPower). This
33  // method limits the effect of tails on bandwidth determination.
34  */
35  inline explicit BandwidthGCVPseudoLogli1D(double regularizationPower=0.5)
36  : renormPow_(regularizationPower), nonZeroCount_(0), renormCount_(0) {}
37 
38  inline virtual ~BandwidthGCVPseudoLogli1D() {}
39 
40  inline unsigned long getNonZeroCount() const {return nonZeroCount_;}
41  inline unsigned long getRenormCount() const {return renormCount_;}
42 
43  // Unweighted samples
44  virtual double operator()(
45  const HistoND<Numeric>& histo,
46  const Num2* densityEstimate,
47  const Num2* leaveOneOutEstimate,
48  unsigned lenEstimate,
49  const AbsPolyFilter1D& filterUsed) const;
50 
51  // Weighted samples
52  virtual double operator()(
53  const HistoND<Numeric>& histo,
54  double effectiveSampleSize,
55  const Num2* densityEstimate,
56  const Num2* leaveOneOutEstimate,
57  unsigned lenEstimate,
58  const AbsPolyFilter1D& filterUsed) const;
59 
60  private:
61  double renormPow_;
62  mutable unsigned long nonZeroCount_;
63  mutable unsigned long renormCount_;
64  };
65 }
66 
67 #include "npstat/stat/BandwidthGCVPseudoLogli1D.icc"
68 
69 #endif // NPSTAT_BANDWIDTHGCVPSEUDOLOGLI1D_HH_
Interface definitions for cross-validation with grouped data.
Definition: BandwidthGCVPseudoLogli1D.hh:25
BandwidthGCVPseudoLogli1D(double regularizationPower=0.5)
Definition: BandwidthGCVPseudoLogli1D.hh:35
virtual double operator()(const HistoND< Numeric > &histo, double effectiveSampleSize, const Num2 *densityEstimate, const Num2 *leaveOneOutEstimate, unsigned lenEstimate, const AbsPolyFilter1D &filterUsed) const
virtual double operator()(const HistoND< Numeric > &histo, const Num2 *densityEstimate, const Num2 *leaveOneOutEstimate, unsigned lenEstimate, const AbsPolyFilter1D &filterUsed) const
Definition: HistoND.hh:46
Definition: AbsArrayProjector.hh:14
Definition: AbsBandwidthGCV.hh:38
Definition: AbsPolyFilter1D.hh:27