1 #ifndef NPSTAT_LORPE1DFIXEDDEGREECVSCANNER_HH_
2 #define NPSTAT_LORPE1DFIXEDDEGREECVSCANNER_HH_
30 const std::vector<double>& bandwidthFactors)
31 : bandwidthFactors_(bandwidthFactors),
32 logBw_(bandwidthFactors.size()),
35 if (fixedDegree_ < 0.0)
throw std::invalid_argument(
36 "In npstat::LOrPE1DFixedDegreeCVScanner constructor: "
37 "degree argument must be non-negative");
38 const unsigned nscan = bandwidthFactors_.size();
39 if (nscan < 2U)
throw std::invalid_argument(
40 "In npstat::LOrPE1DFixedDegreeCVScanner constructor: "
41 "insufficient number of bandwidth factors");
43 throw std::invalid_argument(
44 "In npstat::LOrPE1DFixedDegreeCVScanner constructor: "
45 "sequence of bandwidth factors must be strictly increasing");
46 for (
unsigned i=0; i<nscan; ++i)
48 if (bandwidthFactors_[i] <= 0.0)
throw std::invalid_argument(
49 "In npstat::LOrPE1DFixedDegreeCVScanner constructor: "
50 "all bandwidth factors must be positive");
51 logBw_[i] = std::log(bandwidthFactors_[i]);
55 inline unsigned nBwFactors()
const {
return bandwidthFactors_.size();}
56 inline double getBwFactor(
const unsigned i)
const {
return bandwidthFactors_.at(i);}
61 const unsigned nscan = bandwidthFactors_.size();
62 std::vector<double> cvValues(nscan);
63 for (
unsigned i=0; i<nscan; ++i)
64 cvValues[i] = lorpe(fixedDegree_, bandwidthFactors_[i]);
65 const ScanExtremum1D& scanMax = findScanMaximum1D(&logBw_[0], nscan,
68 fixedDegree_, std::exp(scanMax.location()), scanMax.value(),
69 true, scanMax.isOnTheBoundary());
73 std::vector<double> bandwidthFactors_;
74 std::vector<double> logBw_;
An object representing the result of the 1-d LOrPE cross-validation procedure.
Finding extrema of scanned 1-d curves.
Definition: LOrPE1DCVResult.hh:19
Definition: LOrPE1DFixedDegreeCVScanner.hh:27
Definition: ScanExtremum1D.hh:16
A few simple template functions for checking monotonicity of container values.
Definition: AbsArrayProjector.hh:14
bool isStrictlyIncreasing(Iter begin, Iter const end)
Definition: isMonotonous.hh:18