Class for penalty function 1 for AIC. More...
Public Member Functions | |
PenAIC1 (double cc, double aa, double rr) | |
cxsc::real | operator() (const AdaptiveHistogram *const adh, int deltaLeaf) const |
the penalty function. |
Class for penalty function 1 for AIC.
real subpavings::PenAIC1::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); accumulate(penalty, c, logCatk); // pen = c*logCatk accumulate(penalty, alpha, k); // pen = c*logCatk + alpha*k accumulate(penalty, c*r, log(k+1.0)); // now pen = c*logCatk + alpha*k + c*r*log(k+1) dotprecision temp(0.0); accumulate(temp, c*alpha*k, logCatk); accumulate(temp, r, log(k+1.0)); // temp = c*alpha*k*logCatk + r*log(k+1) return (rnd(penalty) + 2*sqrt(rnd(temp))); // return c*logCatk + alpha*k + c*r*log(k+1) // + 2*sqrt(c*alpha*k*logCatk + r*log(k+1)) }