private void calculatePosteriors() { if (mBestPosterior != null) { return; } final int best = best(); if (best == -1) { mBestPosterior = arithmetic().zero(); mNonIdentity = arithmetic().zero(); return; } double others = arithmetic().zero(); final int reference = mHyp.reference(); for (int i = 0; i < size(); i++) { if (i != best && i != reference) { others = arithmetic().add(others, measure(i)); } } final double refMeasure = reference == -1 ? arithmetic().zero() : measure(reference); final double bestOther = best == reference ? others : arithmetic().add(others, refMeasure); mBestPosterior = arithmetic().divide(measure(best), bestOther); if (reference == -1) { mNonIdentity = arithmetic().zero(); } else { final double refOther = best == reference ? others : arithmetic().add(others, measure(best)); mNonIdentity = arithmetic().divide(refOther, refMeasure); } }
@Override public int reference() { return mHyp.reference(); }