1 #ifndef NPSTAT_LORPE1DFIXEDDEGREECVRUNNER_HH_
2 #define NPSTAT_LORPE1DFIXEDDEGREECVRUNNER_HH_
28 const double i_bwFactorGuess,
30 : fixedDegree_(i_fixedDegree),
31 bwFactorGuess_(i_bwFactorGuess),
34 assert(fixedDegree_ >= 0.0);
35 assert(bwFactorGuess_ > 0.0);
39 inline double fixedDegree()
const {
return fixedDegree_;}
40 inline double bwFactorGuess()
const {
return bwFactorGuess_;}
41 inline double tol()
const {
return tol_;}
46 const double oldDeg = lorpe.boundFilterDegree();
47 lorpe.bindFilterDegree(fixedDegree_);
49 const double sqr2 = 1.414213562373095;
50 double bwFactor = 0.0, bestFcn, divider = 1.0;
51 bool bestBwFound =
false;
53 const unsigned maxtries = 11;
55 for (
unsigned itry=0; itry<maxtries && !bestBwFound; ++itry)
58 fcn, bwFactorGuess_/divider, tol_, &bwFactor, &bestFcn);
62 assert(bwFactor > 0.0);
65 const double fstep = 1.0 + tol_;
66 const double bwMin = bwFactor/fstep;
67 const double bwMax = bwFactor*fstep;
69 double extremumCoordinate, extremumValue;
71 std::log(bwMin), fcn(bwMin),
72 std::log(bwFactor), bestFcn,
73 std::log(bwMax), fcn(bwMax),
74 &extremumCoordinate, &extremumValue);
78 lorpe.unbindFilterDegree();
80 lorpe.bindFilterDegree(oldDeg);
83 fixedDegree_, std::exp(extremumCoordinate), -extremumValue,
89 double bwFactorGuess_;
An object representing the result of the 1-d LOrPE cross-validation procedure.
Various simple mathematical utilities which did not end up inside dedicated headers.
Definition: LOrPE1DCVResult.hh:19
Definition: LOrPE1DFixedDegreeCVRunner.hh:25
Search for 1-d function minimum in log space using the golden section method.
Definition: AbsArrayProjector.hh:14
MultiplyByConstHelper< Result, Arg1 > MultiplyByConst(const Functor1< Result, Arg1 > &fcn, const Numeric &factor)
Definition: SimpleFunctors.hh:1015
bool parabolicExtremum(double x0, double y0, double x1, double y1, double x2, double y2, double *extremumCoordinate, double *extremumValue)
bool goldenSectionSearchInLogSpace(const Functor1< Result, Arg1 > &f, const Arg1 &x0, double tol, Arg1 *minimum, Result *fmin=0, double logstep=0.5)