npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
variableBandwidthSmooth1D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_VARIABLEBANDWIDTHSMOOTH1D_HH_
2 #define NPSTAT_VARIABLEBANDWIDTHSMOOTH1D_HH_
3 
4 /*!
5 // \file variableBandwidthSmooth1D.hh
6 //
7 // \brief Kernel density estimation with adaptive bandwidth
8 //
9 // Author: I. Volobouev
10 //
11 // August 2010
12 */
13 
14 #include "npstat/stat/HistoND.hh"
16 
17 namespace npstat {
18  /**
19  // This function performs kernel density estimation with variable
20  // bandwidth which changes for each bin of the data histogram in the
21  // inverse proportion to the pilot density estimate at that bin to some
22  // power given by the parameter "alpha" (it seems 0.5 works well as
23  // "alpha" argument in many contexts). The pilot estimate must be positive
24  // for any bin that has any data in it. This pilot can be created,
25  // for example, using fixed bandwidth polynomial filter of degree 0
26  // (which is equivalent to KDE with boundary kernels).
27  //
28  // It is assumed that the kernel has its "center" at 0. It should normally
29  // be symmetric around 0. Boundary kernel adjustment is performed
30  // automatically.
31  //
32  // The variable bandwidth values will be adjusted in such a way that their
33  // geometric mean will be equal to the argument "bandwidth".
34  //
35  // The "increaseBandwidthAtBoundary" argument allows the user to use wider
36  // kernels at the boundaries of density support region (to compensate for
37  // kernel leakage outside the support region). This adjustment comes after
38  // the geometric mean normalization, so that geometric mean normalization
39  // will not hold strictly in this case.
40  //
41  // Number of bins in the input histogram, length of the pilot density
42  // estimate array, and length of the result array must all be the same.
43  */
44  template<typename Numeric, typename Num2, typename NumOut>
46  const HistoND<Numeric>& histo,
47  const Num2* pilotDensityEstimate, unsigned lenEstimate,
48  const AbsDistribution1D& kernel, double bandwidth,
49  double alpha, bool increaseBandwidthAtBoundary,
50  NumOut* result, unsigned lenResult);
51 
52  /**
53  // High-level driver routine for "variableBandwidthSmooth1D". It is
54  // assumed that one of the symmetric beta family kernels (including
55  // the Gaussian for which "symbetaPower" parameter can be set to any
56  // negative number) is used to build both the pilot and the final
57  // density estimates. The "alpha" parameter is set to 0.5 and the
58  // bandwidth is not increased at the boundary. The pilot estimate
59  // is generated using the AMISE plugin bandwidth multiplied by the
60  // "bandwidthFactor". It is assumed that the correct sample size
61  // can be obtained by summing the histogram bin contents, so the
62  // histogram should not be scaled.
63  //
64  // The function returns the pilot bandwidth used.
65  */
66  template<typename Numeric, typename NumOut>
68  const HistoND<Numeric>& histo, int symbetaPower,
69  NumOut* result, unsigned lenResult, double bandwidthFactor = 1.0);
70 
71  /**
72  // High-level driver routine for "variableBandwidthSmooth1D". It is
73  // assumed that one of the symmetric beta family kernels (including
74  // the Gaussian for which "symbetaPower" parameter can be set to any
75  // negative number) is used to build both the pilot and the final
76  // density estimates. The "alpha" parameter is set to 0.5 and the
77  // bandwidth is not increased at the boundary. The pilot estimate
78  // is generated using the AMISE plugin bandwidth multiplied by the
79  // "bandwidthFactor". This code can be used with histograms that
80  // are scaled or filled with weighted points as long as the correct
81  // effective sample size is provided.
82  //
83  // The function returns the pilot bandwidth used.
84  */
85  template<typename Numeric, typename NumOut>
87  const HistoND<Numeric>& histo, double effectiveSampleSize,
88  int symbetaPower, NumOut* result, unsigned lenResult,
89  double bandwidthFactor = 1.0);
90 }
91 
92 #include "npstat/stat/variableBandwidthSmooth1D.icc"
93 
94 #endif // NPSTAT_VARIABLEBANDWIDTHSMOOTH1D_HH_
Interface definition for 1-d continuous statistical distributions.
Arbitrary-dimensional histogram template.
Definition: HistoND.hh:46
Definition: AbsArrayProjector.hh:14
double simpleVariableBandwidthSmooth1D(const HistoND< Numeric > &histo, int symbetaPower, NumOut *result, unsigned lenResult, double bandwidthFactor=1.0)
double weightedVariableBandwidthSmooth1D(const HistoND< Numeric > &histo, double effectiveSampleSize, int symbetaPower, NumOut *result, unsigned lenResult, double bandwidthFactor=1.0)
void variableBandwidthSmooth1D(const HistoND< Numeric > &histo, const Num2 *pilotDensityEstimate, unsigned lenEstimate, const AbsDistribution1D &kernel, double bandwidth, double alpha, bool increaseBandwidthAtBoundary, NumOut *result, unsigned lenResult)
Definition: AbsDistribution1D.hh:31