|
Go to the documentation of this file. 1 #ifndef NPSTAT_KDE1DCV_HH_
2 #define NPSTAT_KDE1DCV_HH_
26 template < typename Numeric>
31 const double xmin, const double xmax,
32 const unsigned nIntegIntervals,
33 const unsigned nIntegPoints,
34 const Numeric* coords,
35 const unsigned long nCoords,
36 const bool coordinatesSorted,
37 const bool useReverseKde)
38 : kernel_(kernel), xmin_(xmin), xmax_(xmax),
39 nIntegIntervals_(nIntegIntervals), nIntegPoints_(nIntegPoints),
40 coords_(coords), nCoords_(nCoords),
41 coordinatesSorted_(coordinatesSorted),
42 useReverseKde_(useReverseKde) {}
46 inline double operator()( const double& bw) const
48 long double msum = 0.0L;
49 for ( unsigned long i=0; i<nCoords_; ++i)
51 const double x = coords_[i];
54 kde = kernel_. reverseKde(x, bw, coords_, nCoords_,
57 kde = kernel_. kde(x, bw, coords_, nCoords_,
59 const double loo = kernel_. looKde(bw, nCoords_, kde);
63 xmin_, xmax_, nIntegIntervals_, nIntegPoints_,
64 bw, useReverseKde_, coords_, nCoords_, coordinatesSorted_);
65 return -(integ - msum*2.0/nCoords_);
72 unsigned nIntegIntervals_;
73 unsigned nIntegPoints_;
74 const Numeric* coords_;
75 unsigned long nCoords_;
76 bool coordinatesSorted_;
81 template < typename Numeric>
84 const double xmin, const double xmax,
85 const unsigned nIntegIntervals,
86 const unsigned nIntegPoints,
87 const Numeric* coords,
88 const unsigned long nCoords,
89 const bool coordinatesSorted = false,
90 const bool useReverseKde = false)
93 kernel, xmin, xmax, nIntegIntervals, nIntegPoints,
94 coords, nCoords, coordinatesSorted, useReverseKde);
105 template < typename Numeric>
110 const double plcvAlpha,
111 const Numeric* coords,
112 const unsigned long nCoords,
113 const bool coordinatesSorted,
114 const bool useReverseKde)
115 : kernel_(kernel), plcvAlpha_(plcvAlpha),
116 coords_(coords), nCoords_(nCoords),
117 coordinatesSorted_(coordinatesSorted),
118 useReverseKde_(useReverseKde) {}
122 inline double operator()( const double& bw) const
124 const double nPt = nCoords_;
125 const double selfC = kernel_(0.0)/bw/nPt;
126 const double minDens = selfC/pow(nPt, plcvAlpha_);
127 const double logm = log(minDens);
129 long double msum = 0.0L;
130 for ( unsigned long i=0; i<nCoords_; ++i)
132 const double x = coords_[i];
135 kde = kernel_. reverseKde(x, bw, coords_, nCoords_,
138 kde = kernel_. kde(x, bw, coords_, nCoords_,
140 const double loo = kernel_. looKde(bw, nCoords_, kde);
152 const Numeric* coords_;
153 unsigned long nCoords_;
154 bool coordinatesSorted_;
159 template < typename Numeric>
162 const double plcvAlpha,
163 const Numeric* coords,
164 const unsigned long nCoords,
165 const bool coordinatesSorted = false,
166 const bool useReverseKde = false)
169 kernel, plcvAlpha, coords, nCoords,
170 coordinatesSorted, useReverseKde);
Brute-force non-discretized KDE in 1-d. No boundary correction.
Definition: AbsKDE1DKernel.hh:23
double reverseKde(double x, double bandwidth, const Numeric *coords, unsigned long nCoords, bool coordinatesSorted=false) const
double kde(double x, double bandwidth, const Numeric *coords, unsigned long nCoords, bool coordinatesSorted=false) const
double looKde(double bandwidth, unsigned long nCoords, double originalDensityEstimate) const
double integratedKdeSquared(double xmin, double xmax, unsigned nIntegIntervals, unsigned nIntegPoints, double bandwidth, bool useReverseKde, const Numeric *coords, unsigned long nCoords, bool coordinatesSorted=false) const
Definition: KDE1DCV.hh:28
Definition: KDE1DCV.hh:107
Definition: AbsArrayProjector.hh:14
KDE1DRLCVFunctorHelper< Numeric > KDE1DRLCVFunctor(const AbsKDE1DKernel &kernel, const double plcvAlpha, const Numeric *coords, const unsigned long nCoords, const bool coordinatesSorted=false, const bool useReverseKde=false) Definition: KDE1DCV.hh:160
KDE1DLSCVFunctorHelper< Numeric > KDE1DLSCVFunctor(const AbsKDE1DKernel &kernel, const double xmin, const double xmax, const unsigned nIntegIntervals, const unsigned nIntegPoints, const Numeric *coords, const unsigned long nCoords, const bool coordinatesSorted=false, const bool useReverseKde=false) Definition: KDE1DCV.hh:82
Definition: SimpleFunctors.hh:58
|