Class for penalty function 2 for AIC. More...
Public Member Functions | |
PenAIC2 (double cc, double aa, double rr) | |
cxsc::real | operator() (const AdaptiveHistogram *const adh, int deltaLeaf) const |
the penalty function. |
Class for penalty function 2 for AIC.
real subpavings::PenAIC2::operator() | ( | const AdaptiveHistogram *const | adh, |
int | deltaLeaf | ||
) | const [virtual] |
the penalty function.
adh | is the histogram object to calculate the penalty on. |
deltaLeaf | change in number leaves to take into account. |
Implements subpavings::PenObj.
{ dotprecision penalty(0.0); int k = adh->getRootLeaves() + deltaLeaf - 1; // leaves-1 double logCatk= lCk(k); size_t counter = adh->getRootCounter(); // total number points accumulate(penalty, c, logCatk); // pen = c*logCatk real s = adh->getRootSumLeafCountOverVol(); accumulate(penalty, s/(1.0*counter), alpha); //now pen = c*logCatk + (alpha/counter)*sum(leaf counts/vols) accumulate(penalty, 2*r, log(k+1)); //now pen = c*logCatk + (alpha/counter)*sum(leaf counts/vols) + 2*r*log(k+1) return rnd(penalty); }