npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
CVCopulaSmoother.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_CVCOPULASMOOTHER_HH_
2 #define NPSTAT_CVCOPULASMOOTHER_HH_
3 
4 /*!
5 // \file CVCopulaSmoother.hh
6 //
7 // \brief Smoothing copulas with AbsBandwidthCVND cross-validation
8 //
9 // Author: I. Volobouev
10 //
11 // June 2015
12 */
13 
16 
17 namespace npstat {
18  template<class F>
20  {
21  public:
23  typedef F Filter;
24 
25  virtual ~CVCopulaSmoother();
26 
27  protected:
28  /**
29  // Constructor arguments are as follows:
30  //
31  // nBinsInEachDim -- number of copula bins in each dimension
32  //
33  // dim -- copula dimensionality
34  //
35  // marginTolerance -- tolerance for the margin to be uniform
36  //
37  // maxNormCycles -- max number of copula normalization cycles
38  //
39  // initialBw -- "central" bandwidth for cross validation
40  // calculations (or the actual bandwidth used
41  // in case cross validation is not performed).
42  // Set this parameter to 0.0 in order to
43  // disable filtering altogether.
44  //
45  // cvCalc -- calculator for the quantity being optimized
46  // in the cross validation process. May be NULL
47  // in which case cross validation will not
48  // be used.
49  //
50  // becomeCvCalcOwner -- tells us whether we should destroy cvCalc
51  // in our own destructor
52  //
53  // cvRange -- we will scan bandwidth values between
54  // initialBw/cvRange and initialBw*cvRange
55  // uniformly in the log space.
56  //
57  // nCV -- number of bandwidth values to try in the
58  // bandwidth scan. If this number is even, it
59  // will be increased by 1 internally so that
60  // the "central" bandwidth is included in
61  // the scan. If this parameter is 0 or 1, the
62  // value given by "initialBw" will be used.
63  //
64  // useConvolve -- if "true", use "convolve" method of the
65  // filter rather than "filter" method.
66  */
67  CVCopulaSmoother(const unsigned* nBinsInEachDim, unsigned dim,
68  double marginTolerance,
69  unsigned maxNormCycles, double initialBw,
70  const CVCalc* cvCalc, bool becomeCvCalcOwner,
71  double cvRange, unsigned nCV, bool useConvolve);
72  /**
73  // Constructor which explicitly specifies the complete set of
74  // bandwidth values to use in cross-validation
75  */
76  CVCopulaSmoother(const unsigned* nBinsInEachDim, unsigned dim,
77  double marginTolerance, unsigned maxNormCycles,
78  const std::vector<double>& bandwidthValues,
79  const CVCalc* cvCalc, bool becomeCvCalcOwner,
80  bool useConvolve);
81  /**
82  // Constructors of the derived classes should call
83  // this method for each bandwidth value. "i" is
84  // the bandwidth value number, while the bandwidth
85  // corresponding to this number should be obtained from
86  // the "bandwidthValues()" vector.
87  //
88  // This base class will assume the ownership of the filter object.
89  */
90  void setFilter(unsigned i, Filter* filter);
91 
92  private:
93  double smoothAndCV(const HistoND<double>& histo,
94  double effectiveSampleSize,
95  bool isSampleWeighted,
96  unsigned bandwidthIndex,
97  bool runCrossValidation,
98  ArrayND<double>* result,
99  double* regularizedFraction,
100  bool* isNonNegativeAndNormalized);
101 
102  std::vector<Filter*> filters_;
103  const CVCalc* cvCalc_;
104  bool assumeCvCalcOwnership_;
105  };
106 }
107 
108 #include "npstat/stat/CVCopulaSmoother.icc"
109 
110 #endif // NPSTAT_CVCOPULASMOOTHER_HH_
Interface definitions for KDE or LOrPE cross-validation calculations.
Interface definition for smoothing copulas with cross-validation.
Definition: AbsCVCopulaSmoother.hh:21
const std::vector< double > & bandwidthValues() const
Definition: AbsCVCopulaSmoother.hh:36
Definition: CVCopulaSmoother.hh:20
void setFilter(unsigned i, Filter *filter)
CVCopulaSmoother(const unsigned *nBinsInEachDim, unsigned dim, double marginTolerance, unsigned maxNormCycles, const std::vector< double > &bandwidthValues, const CVCalc *cvCalc, bool becomeCvCalcOwner, bool useConvolve)
CVCopulaSmoother(const unsigned *nBinsInEachDim, unsigned dim, double marginTolerance, unsigned maxNormCycles, double initialBw, const CVCalc *cvCalc, bool becomeCvCalcOwner, double cvRange, unsigned nCV, bool useConvolve)
Definition: AbsArrayProjector.hh:14
Definition: AbsBandwidthCV.hh:176