* Recurse through the particle filter
*/
for (int i = 0; i < T; i++) {
final double x = DoubleMath.roundToInt(samples.get(i).getState(), RoundingMode.HALF_EVEN);
viterbiRate.accumulate(new MutableDouble((x == viterbiResults.get(i) ? 1d : 0d)));
final T y = samples.get(i).getObservedValue();
final ObservedValue<T, Void> obsState = ObservedValue.create(i, y);
rsFilter.update(rsDistribution, obsState);
/*
* Compute and output RS forward errors
*/
ResampleType rsResampleType = rsDistribution.getMaxValueKey().getResampleType();
Vector rsStateProbDiffs = computeStateDiffs(i, hmm.getNumStates(), rsDistribution, forwardResults);
String[] rsLine = {Integer.toString(k), Integer.toString(i), "p(x_t=0|y^t)",
rsResampleType.toString(),
Double.toString(rsStateProbDiffs.getElement(0))};
writer.writeNext(rsLine);
log.info("rsStateProbDiffs=" + rsStateProbDiffs);
if (i > numPreRuns) {
wfFilter.update(wfDistribution, obsState);
RingAccumulator<MutableDouble> pfAtTRate = new RingAccumulator<MutableDouble>();
for (P state : wfDistribution.getDomain()) {
final double err = (x == state.getClassId()) ? wfDistribution.getFraction(state) : 0d;
pfAtTRate.accumulate(new MutableDouble(err));
}
pfRunningRate.accumulate(new MutableDouble(pfAtTRate.getSum()));
ResampleType wfResampleType = wfDistribution.getMaxValueKey().getResampleType();
Vector wfStateProbDiffs = computeStateDiffs(i, hmm.getNumStates(), wfDistribution, forwardResults);
String[] wfLine = {Integer.toString(k), Integer.toString(i), "p(x_t=0|y^t)", "water-filling",
wfResampleType.toString(),