1 #ifndef NPSTAT_LORPE1DSYMBETAKERNEL_HH_
2 #define NPSTAT_LORPE1DSYMBETAKERNEL_HH_
31 double leftBoundary,
double rightBoundary,
33 bool memoizeBoundaryPolys =
false);
40 inline double filterDegree()
const {
return filterDegree_;}
41 inline double leftBoundary()
const {
return leftBoundary_;}
42 inline double rightBoundary()
const {
return rightBoundary_;}
44 inline bool isMemoizing()
const {
return memoizingBoundaryPolys_;}
45 inline void memoize(
const bool b) {memoizingBoundaryPolys_ = b;}
46 inline void clearMemoizedInfo() {bpMap_.clear();}
60 const double x,
const double bandwidth)
const
62 return std::shared_ptr<AbsClassicalOrthoPoly1D>(
63 buildBoundaryPolyOnTheHeap(x, bandwidth));
71 inline double normFactor()
const {
return norm_;}
78 template <
typename Numeric>
79 double lorpe(
double x,
double bandwidth,
80 const Numeric* coords,
unsigned long nCoords,
81 bool coordinatesSorted =
false)
const;
100 {
return !(*
this == r);}
103 struct BoundaryPolyInfo
105 std::shared_ptr<AbsClassicalOrthoPoly1D> boundaryPoly;
106 std::vector<long double> polyAt0;
108 typedef std::map<std::pair<double,double>, BoundaryPolyInfo> BoundaryPolyMap;
110 void deallocateThings();
111 void copyInternals(
const LOrPE1DSymbetaKernel& r);
112 double kernelValue(
const AbsClassicalOrthoPoly1D& poly,
113 const long double* poly0,
double x_i)
const;
114 AbsClassicalOrthoPoly1D* buildBoundaryPolyOnTheHeap(
115 double x,
double bandwidth)
const;
119 double filterDegree_;
120 double leftBoundary_;
121 double rightBoundary_;
122 double lastShrinkage_;
125 mutable double lastCenterValue_;
126 BoundaryHandling bh_;
127 AbsClassicalOrthoPoly1D* poly_;
128 std::vector<long double> polyAt0_;
129 bool memoizingBoundaryPolys_;
131 mutable std::vector<long double> polyBuf_;
132 mutable bool usingBoundaryCorr_;
133 mutable BoundaryPolyMap bpMap_;
137 inline double lorpe_2(
double x,
double bandwidth,
138 const double* coordsd,
unsigned long nCoords,
139 bool coordsSorted =
false)
const
141 return this->
lorpe(x, bandwidth, coordsd, nCoords, coordsSorted);
144 inline double lorpe_2(
double x,
double bandwidth,
145 const std::vector<std::pair<double, double> >& vec,
146 bool coordsSorted =
false)
const
148 const unsigned long n = vec.size();
149 const std::pair<double, double>* points = 0;
152 return this->
lorpe(x, bandwidth, points, n, coordsSorted);
155 inline AbsClassicalOrthoPoly1D* buildBoundaryPoly_2(
156 double x,
double bandwidth)
const
158 return buildBoundaryPolyOnTheHeap(x, bandwidth);
171 template <
typename Numeric,
class Fcn>
176 Fcn bandwidthFunctor,
177 const Numeric* coords,
178 const unsigned long nCoords,
179 const bool coordinatesSorted)
180 : kernel_(kernel), bandwidthFunctor_(bandwidthFunctor),
181 coords_(coords), nCoords_(nCoords),
182 coordinatesSorted_(coordinatesSorted) {}
186 inline double operator()(
const double& x)
const
188 const double h = fcnOrConst(bandwidthFunctor_, x);
189 return kernel_.
lorpe(x, h, coords_, nCoords_, coordinatesSorted_);
194 Fcn bandwidthFunctor_;
195 const Numeric* coords_;
196 unsigned long nCoords_;
197 bool coordinatesSorted_;
201 template <
typename Numeric,
class Fcn>
204 const Numeric* coords,
const unsigned long nCoords,
205 const bool coordinatesSorted =
false)
208 kernel, bandwidthFunctor, coords, nCoords, coordinatesSorted);
212 template <
typename Numeric,
class Fcn>
219 : distro_(distro), densityFcn_(fcn) {}
223 inline double operator()(
const double& x)
const
225 const double delta = densityFcn_(x) - distro_.
density(x);
235 #include "npstat/stat/LOrPE1DSymbetaKernel.icc"
Base class for classical continuous orthonormal polynomials.
Interface definition for 1-d continuous statistical distributions.
API for LOrPE boundary handling methods.
Interface definitions and concrete simple functors for a variety of functor-based calculations.
Definition: BoundaryHandling.hh:21
Definition: LOrPE1DSymbetaKernel.hh:173
Definition: LOrPE1DSymbetaKernel.hh:214
Definition: LOrPE1DSymbetaKernel.hh:28
bool isBoundaryCorrectionNeeded(double x, double bandwidth) const
void setNormFactor(double normfactor)
bool usedBoundaryCorrection() const
std::shared_ptr< AbsClassicalOrthoPoly1D > buildBoundaryPoly(const double x, const double bandwidth) const
Definition: LOrPE1DSymbetaKernel.hh:59
double lorpe(double x, double bandwidth, const Numeric *coords, unsigned long nCoords, bool coordinatesSorted=false) const
double getLastKernelAt0() const
Templated utilities for use in various density estimation codes, etc.
Definition: AbsArrayProjector.hh:14
LOrPE1DFunctorHelper< Numeric, Fcn > LOrPE1DFunctor(const LOrPE1DSymbetaKernel &kernel, Fcn bandwidthFunctor, const Numeric *coords, const unsigned long nCoords, const bool coordinatesSorted=false)
Definition: LOrPE1DSymbetaKernel.hh:202
Definition: AbsDistribution1D.hh:31
virtual double density(double x) const =0
Definition: SimpleFunctors.hh:58