npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
betaKernelsBandwidth.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_BETAKERNELSBANDWIDTH_HH_
2 #define NPSTAT_BETAKERNELSBANDWIDTH_HH_
3 
4 /*!
5 // \file betaKernelsBandwidth.hh
6 //
7 // \brief Optimal bandwidth for density estimation with beta kernels
8 //
9 // The formulae implemented in this code come from the paper by
10 // S.X. Chen, "Beta kernel estimators for density functions",
11 // Computational Statistics & Data Analysis 31, pp. 131-145 (1999).
12 // Note that printed versions of formulae for AMISE contain algebraic
13 // mistakes. These formulae have instead been rederived starting from
14 // equations 4.2 and 4.3 in the paper.
15 //
16 // Bandwidth values returned by this function may not be optimal at all
17 // for finite samples as the precision of curve estimation by sums of
18 // beta functions drops very sharply as a function of derivative number
19 // (only the terms proportional to the first and the second derivatives
20 // are considered in the paper which is sufficient for asymptotic reasoning).
21 // Thus the returned bandwidth values should be used as an approximate guide
22 // only, perhaps as starting points for a cross validation bandwidth scan.
23 // Both b1* and b2* should be calculated -- the difference between them
24 // gives an idea about potential spread of the optimal bandwidth.
25 //
26 // Author: I. Volobouev
27 //
28 // June 2013
29 */
30 
31 namespace npstat {
32  /**
33  // AMISE optimal bandwidth for density estimation by beta kernels.
34  // The arguments are as follows:
35  //
36  // npoints -- Number of points in the data sample.
37  //
38  // fvalues -- Array of scanned values of the reference density.
39  // It is assumed that the density is scanned at the
40  // bin centers on the [0, 1] interval.
41  //
42  // nValues -- Number of elements in the array "fvalues".
43  //
44  // returnB2Star -- If "true", the function will return b_2* from Chen's
45  // paper (and corresponding AMISE), otherwise it will
46  // return b_1* (using corrected algebra).
47  //
48  // expectedAmise -- If this argument is provided, it will be filled
49  // with the expected AMISE value.
50  //
51  // The generalized Bernstein polynomial degree is simply the inverse
52  // of the bandwidth.
53  */
54  template<typename Real>
55  double betaKernelsBandwidth(double npoints, const Real* fvalues,
56  unsigned long nValues, bool returnB2Star,
57  double* expectedAmise = 0);
58 }
59 
60 #include "npstat/stat/betaKernelsBandwidth.icc"
61 
62 #endif // NPSTAT_BETAKERNELSBANDWIDTH_HH_
Definition: AbsArrayProjector.hh:14
double betaKernelsBandwidth(double npoints, const Real *fvalues, unsigned long nValues, bool returnB2Star, double *expectedAmise=0)